From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on inbox.vuxu.org X-Spam-Level: X-Spam-Status: No, score=-8.6 required=5.0 tests=DKIMWL_WL_MED,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HTML_MESSAGE,MAILING_LIST_MULTI, RCVD_IN_MSPIKE_H2,USER_IN_DEF_DKIM_WL autolearn=ham autolearn_force=no version=3.4.4 Received: (qmail 9446 invoked from network); 27 Jul 2022 18:05:53 -0000 Received: from second.openwall.net (193.110.157.125) by inbox.vuxu.org with ESMTPUTF8; 27 Jul 2022 18:05:53 -0000 Received: (qmail 12258 invoked by uid 550); 27 Jul 2022 18:05:50 -0000 Mailing-List: contact musl-help@lists.openwall.com; run by ezmlm Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-ID: Reply-To: musl@lists.openwall.com Received: (qmail 12221 invoked from network); 27 Jul 2022 18:05:49 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=mime-version:references:in-reply-to:from:date:message-id:subject:to; bh=WI+5lU5yMjb2JD+ROLlaSnOdDgS2lnEvelOlcJJxa30=; b=l4zTwX5RTxv7ykUudvfq570OtonfJVU+UbRQ8bca88lN/ukJhhInnGcnTn48kSStaf 22OCUtDoyH5Qq8g6BtPHvHpul1dLn86hNVFXniL4TGXXqtwSpPlDyHv8Fm6NKwUPwthZ tfZKX4K5fKBjo7tmOkh3hBsS9kIX0EZn+0oNjrRFD8sQHycz+FaL+IuWGG2su+KTwqGQ Mam2gO9SuJ+nzlvI2plh23YiGpefRv5U3NL6SWMNTJzaKC4ZxeiTFSWoa06qal2A9/Rm 8qGVKqX4WYeCAa5py2euthnktNLxVzwFRGSrBdoqKB85pimYL5gtCGlDKE7TpMFsagXO 7+pw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to; bh=WI+5lU5yMjb2JD+ROLlaSnOdDgS2lnEvelOlcJJxa30=; b=ffwvcz+0+WTTUdX3dhOJwGnXsMb5cYU3SJpeENg4F7LZ0Zja20kteVwYiRbwC7XaC2 sFNlkVMtm5Red7rneIn7aSjbdqQYqM5YebsXOK5YSWWbVmx6j9l2IZgRoTIU3siqmz6i EpII+UQzdKhBJ/VEgAoWUp/pWt8OfII2HXDa83Ifwwf/wid2GwVdBWeq6aA+Nxp/KEbB T7JBynchyK+WREUBO3IPVeah729NqSxU12RMP3fvk1uAeErP/big2Fw8gY3nQ+UhiB5b 9/IcgetXBJ9lBG4YPuSTelj8fMWtdAUacjjc7kW9+xTGqJvhZ9KbNrDsd3hqBbs9D6Vn rGyg== X-Gm-Message-State: AJIora+m47jxaPiXPow+8+iVO0xbovcJ0J/h6R0wMjYys+kL0dwEdLjq 0rRzPhMldjF8P9OY4zo+6i9Krujgl5+yzNwR7sJNJOqX2kg= X-Google-Smtp-Source: AGRyM1sFkRgjRh4kvkKYQb7yPWX0qeABjzOwC++fFolMD4uncGFKAoJfrXeBfz2AB5L795WdrapZrj8RsTLzbUCwJYg= X-Received: by 2002:a05:6512:3691:b0:48a:81ff:343d with SMTP id d17-20020a056512369100b0048a81ff343dmr8652676lfs.553.1658945138014; Wed, 27 Jul 2022 11:05:38 -0700 (PDT) MIME-Version: 1.0 References: <43e9ad2b-d53c-5fd5-0211-766f946c90f9@landley.net> <48546934-5ccd-0b1e-bf2b-306133101c6b@landley.net> In-Reply-To: <48546934-5ccd-0b1e-bf2b-306133101c6b@landley.net> From: enh Date: Wed, 27 Jul 2022 11:05:26 -0700 Message-ID: To: musl@lists.openwall.com Content-Type: multipart/alternative; boundary="000000000000a811a305e4cd43f7" Subject: Re: [musl] Re: sysconf(_SC_NPROCESSORS_CONF) broken. --000000000000a811a305e4cd43f7 Content-Type: text/plain; charset="UTF-8" On Tue, Jul 26, 2022 at 11:27 PM Rob Landley 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 > --000000000000a811a305e4cd43f7 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable


=
On Tue, Jul 26, 2022 at 11:27 PM Rob = Landley <rob@landle= y.net> wrote:
On 7/27/22 01:28, Rob Landley wrote:
> NPROCESSORS_CONF is supposed to show total processors, NPROCESSORS_ONL= N shows
> available processors using the tasket mask sched_getaffinity()).
>
> Musl is (uniquely) using the getaffinity() version for both. Neither g= libc 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) =3D 3
fstat(3, {st_mode=3DS_IFDIR|0755, st_size=3D0, ...}) =3D 0
getdents64(3, /* 22 entries */, 32768)=C2=A0 =3D 656
getdents64(3, /* 0 entries */, 32768)=C2=A0 =C2=A0=3D 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 "avail= able"
processors there, not total processors...

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

note that my claim in that comment abo= ut x86 may not be strictly correct. i'm not sure i'd ever seen an x= 86 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 l= ike "on systems where cores are hotplugged", and that this probab= ly can happen on intel too (i'm guessing their recent big.LITTLE equiva= lent will have brought this kind of thing to their world too).
= =C2=A0
Rob
--000000000000a811a305e4cd43f7--