public inbox for glibc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "ian at airs dot com" <sourceware-bugzilla@sourceware.org>
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	[thread overview]
Message-ID: <bug-25817-131@http.sourceware.org/bugzilla/> (raw)

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.

             reply	other threads:[~2020-04-13 22:02 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-04-13 22:02 ian at airs dot com [this message]
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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=bug-25817-131@http.sourceware.org/bugzilla/ \
    --to=sourceware-bugzilla@sourceware.org \
    --cc=glibc-bugs@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).