mailing list of musl libc
 help / color / mirror / code / Atom feed
From: enh <enh@google.com>
To: musl@lists.openwall.com
Subject: Re: [musl] Re: sysconf(_SC_NPROCESSORS_CONF) broken.
Date: Wed, 27 Jul 2022 11:05:26 -0700	[thread overview]
Message-ID: <CAJgzZorBeyJqp+8n-j3M6eSYHBROT+rJDuHJRb0HM75zTX1hFw@mail.gmail.com> (raw)
In-Reply-To: <48546934-5ccd-0b1e-bf2b-306133101c6b@landley.net>

[-- Attachment #1: Type: text/plain, Size: 1727 bytes --]

On Tue, Jul 26, 2022 at 11:27 PM Rob Landley <rob@landley.net> wrote:

> On 7/27/22 01:28, Rob Landley wrote:
> > NPROCESSORS_CONF is supposed to show total processors, NPROCESSORS_ONLN
> shows
> > available processors using the tasket mask sched_getaffinity()).
> >
> > Musl is (uniquely) using the getaffinity() version for both. Neither
> glibc nor
> > bionic have that bug.
> >
> > Test: my laptop has 4 processors:
> >
> > $ taskset 7 nproc
> > 3
> > $ taskset 7 nproc --all
> > 4
> >
> > With musl, both show 3.
>
> P.S. According to strace, devuan's nprocs --all is reading sysfs:
>
> openat(AT_FDCWD, "/sys/devices/system/cpu",
> O_RDONLY|O_NONBLOCK|O_CLOEXEC|O_DIRECTORY) = 3
> fstat(3, {st_mode=S_IFDIR|0755, st_size=0, ...}) = 0
> getdents64(3, /* 22 entries */, 32768)  = 656
> getdents64(3, /* 0 entries */, 32768)   = 0
>
> At a guess, counting the cpu[0-9]* entries? I looked at bionic's source
> and it
> had a comment that x86 can use /proc/cpuinfo but arm only shows "available"
> processors there, not total processors...
>

yeah, bionic uses /sys/devices/system/cpu and
/sys/devices/system/cpu/online and we haven't had to touch that code since
we switched to doing it that way.

note that my claim in that comment about x86 may not be strictly correct.
i'm not sure i'd ever seen an x86 cpu powering down cores at that time, and
i'm not sure i have since either, but i assume that -- if such a thing is
possible -- they'd look the same as arm? i'd guess the comment should
actually say something like "on systems where cores are hotplugged", and
that this probably can happen on intel too (i'm guessing their recent
big.LITTLE equivalent will have brought this kind of thing to their world
too).


> Rob
>

[-- Attachment #2: Type: text/html, Size: 2430 bytes --]

  parent reply	other threads:[~2022-07-27 18:05 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-07-27  6:28 [musl] " Rob Landley
2022-07-27  6:34 ` [musl] " Rob Landley
2022-07-27 17:58   ` Szabolcs Nagy
2022-07-27 21:29     ` Jonathan Rajotte-Julien
2022-07-28 17:27       ` enh
2022-07-29 18:42         ` enh
2022-07-29 18:53           ` NRK
2022-07-29 19:39             ` enh
2022-07-27 18:05   ` enh [this message]
2022-07-27 23:06     ` [musl] dynamic linker is capturing "reserved" library names erroneously Christopher Sean Morrison
2022-07-28  9:18       ` Szabolcs Nagy
2022-07-28 20:39         ` Christopher Sean Morrison
2022-07-29  0:07           ` Rich Felker
2022-07-29  6:19             ` Christopher Sean Morrison

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=CAJgzZorBeyJqp+8n-j3M6eSYHBROT+rJDuHJRb0HM75zTX1hFw@mail.gmail.com \
    --to=enh@google.com \
    --cc=musl@lists.openwall.com \
    /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.
Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/musl/

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 NNTP newsgroup(s).