public inbox for glibc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug libc/25817] New: __get_nprocs reads a file rather than calling sched_getaffinity
@ 2020-04-13 22:02 ian at airs dot com
  2020-04-14  9:13 ` [Bug malloc/25817] Tune the number of malloc arenas based on the CPU affinity mask fweimer at redhat dot com
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: ian at airs dot com @ 2020-04-13 22:02 UTC (permalink / raw)
  To: glibc-bugs

https://sourceware.org/bugzilla/show_bug.cgi?id=25817

            Bug ID: 25817
           Summary: __get_nprocs reads a file rather than calling
                    sched_getaffinity
           Product: glibc
           Version: unspecified
            Status: NEW
          Severity: normal
          Priority: P2
         Component: libc
          Assignee: unassigned at sourceware dot org
          Reporter: ian at airs dot com
                CC: drepper.fsp at gmail dot com
  Target Milestone: ---

The function __get_nprocs, which is called by arena_get2 in malloc/arena.c,
reads the file /sys/devices/system/cpu/online.  As far as I can tell,
essentially the same information can be obtained more efficiently and more
accurately by calling sched_getaffinity and counting the number of CPUs
returned.

I would encourage glibc to change the code in malloc/arena.c to call
sched_getaffinity if possible.

(This came up in a lengthy investigation of https://golang.org/issue/25628, in
which a Go program that tried to test that there were no unexpected open file
descriptors would fail because it would occasionally encounter the file
descriptor opened by __get_nprocs.)

-- 
You are receiving this mail because:
You are on the CC list for the bug.

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2024-01-11  9:41 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-04-13 22:02 [Bug libc/25817] New: __get_nprocs reads a file rather than calling sched_getaffinity ian at airs dot com
2020-04-14  9:13 ` [Bug malloc/25817] Tune the number of malloc arenas based on the CPU affinity mask fweimer at redhat dot com
2020-04-17  0:50 ` ian at airs dot com
2024-01-11  9:41 ` fweimer at redhat dot com

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).