From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 4A5983858D3C; Sat, 18 Feb 2023 20:25:33 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 4A5983858D3C DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1676751933; bh=N3tep+0b42Hj+taViWtmYUKLsIyheYuP/fmwO854BQg=; h=From:To:Subject:Date:From; b=yZOUMiv3CUvZiMvgipgtM8dzJ0ieTQo8/H7cNtjaYXpPY39a73wdDUT595VGCzMkF zkvoininL/b9OfP32E8c2rCQOgIwzsg9GKn3uJGCOqkm9R7ia5YULGFRtx/+Xp5mmI gTGYmz4pwtujgLv68v6JONd9FgbrC+hSRc1a8Xqc= From: "steffen at sdaoden dot eu" To: glibc-bugs@sourceware.org Subject: [Bug libc/30135] New: sysconf: _SC_NPROCESSORS*: tweak? Date: Sat, 18 Feb 2023 20:25:32 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: glibc X-Bugzilla-Component: libc X-Bugzilla-Version: 2.36 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: steffen at sdaoden dot eu X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Resolution: X-Bugzilla-Priority: P2 X-Bugzilla-Assigned-To: unassigned at sourceware dot org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: bug_id short_desc product version bug_status bug_severity priority component assigned_to reporter cc target_milestone Message-ID: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: http://sourceware.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 List-Id: https://sourceware.org/bugzilla/show_bug.cgi?id=3D30135 Bug ID: 30135 Summary: sysconf: _SC_NPROCESSORS*: tweak? Product: glibc Version: 2.36 Status: UNCONFIRMED Severity: normal Priority: P2 Component: libc Assignee: unassigned at sourceware dot org Reporter: steffen at sdaoden dot eu CC: drepper.fsp at gmail dot com Target Milestone: --- #?0|kent:tmp$ cat t.c #include #include int main(void){ long c,o; c =3D sysconf(_SC_NPROCESSORS_CONF); o =3D sysconf(_SC_NPROCESSORS_ONLN); printf("c=3D%ld o=3D%ld\n", c, o); return 0; } On bare metal: #?0|kent:tmp$ tcc -run t.c c=3D8 o=3D4 #?0|kent:tmp$ nproc 4 But in a box with cgroup-limited CPUs: bash-5.2$ tcc -run t.c c=3D4 o=3D4 bash-5.2$ nproc 3 Could this be a "bug" in the C library, as this checks /sys/devices/system/cpu/online, /proc/stat, and only then (iirc now) uses sched_getaffinity. It documents get_nprocs(3) as "number of processors currently available in the system". But POSIX standardized these[1] as _SC_NPROCESSORS_CONF + _SC_NPROCESSORS_ONLN for sysconf(3) as well as NPROCESSORS_CONF and NPROCESSORS_ONLN for getconf(1), saying ... The maximum number of execution units | _SC_NPROCESSORS_ONLN currently available to run threads=E2=80=A0 | .... =E2=80=A0 The nature of an execution unit and the precise conditions under which an execution unit is considered to be available, or can be made available, or how many threads it can execute in parallel, are implementation-defined. Which is not the same. Implementation-defined though. But i mean if it is easy to give correct results for an execution context (i would). [1] https://austingroupbugs.net/view.php?id=3D339 --=20 You are receiving this mail because: You are on the CC list for the bug.=