From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 752043887022; Mon, 13 Apr 2020 22:02:25 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 752043887022 From: "ian at airs dot com" To: glibc-bugs@sourceware.org Subject: [Bug libc/25817] New: __get_nprocs reads a file rather than calling sched_getaffinity Date: Mon, 13 Apr 2020 22:02:25 +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: unspecified X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: ian at airs dot com X-Bugzilla-Status: NEW 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 X-BeenThere: glibc-bugs@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Glibc-bugs mailing list List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 13 Apr 2020 22:02:25 -0000 https://sourceware.org/bugzilla/show_bug.cgi?id=3D25817 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 fi= le descriptors would fail because it would occasionally encounter the file descriptor opened by __get_nprocs.) --=20 You are receiving this mail because: You are on the CC list for the bug.=