mailing list of musl libc
 help / color / mirror / code / Atom feed
* [musl] about sysconf(_SC_NPROCESSORS_CONF) issue
@ 2022-11-21  8:51 =?gb18030?B?zcPX09bt?=
  2022-11-21 20:34 ` Markus Wichmann
  0 siblings, 1 reply; 2+ messages in thread
From: =?gb18030?B?zcPX09bt?= @ 2022-11-21  8:51 UTC (permalink / raw)
  To: =?gb18030?B?bXVzbA==?=

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain; charset="gb18030", Size: 505 bytes --]

Hi


currently, we use "sysconf(_SC_NPROCESSORS_CONF)" to get the number of the CPU,  and the musl implements this function by SYS_sched_getaffinity system call,  when some of CPUs are isolated, the return value is not correct.


I have searched the history maillist of musl and found the same issue: https://www.openwall.com/lists/musl/2021/05/05/,  but there is no final conclusion. I wonder why musl is doing this?


I'm Looking forward to your reply, Thanks.


Tony Gan

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

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

* Re: [musl] about sysconf(_SC_NPROCESSORS_CONF) issue
  2022-11-21  8:51 [musl] about sysconf(_SC_NPROCESSORS_CONF) issue =?gb18030?B?zcPX09bt?=
@ 2022-11-21 20:34 ` Markus Wichmann
  0 siblings, 0 replies; 2+ messages in thread
From: Markus Wichmann @ 2022-11-21 20:34 UTC (permalink / raw)
  To: musl

On Mon, Nov 21, 2022 at 04:51:49PM +0800, 兔子猪 wrote:

> Hi
>
>
> currently, we use "sysconf(_SC_NPROCESSORS_CONF)" to get the number of
> the CPU,  and the musl implements this function by
> SYS_sched_getaffinity system call,  when some of CPUs are
> isolated, the return value is not correct.
>

Define "correct". That is actually the problem. See below.

>
> I have searched the history maillist of musl and found the same
> issue: https://www.openwall.com/lists/musl/2021/05/05/,  but
> there is no final conclusion. I wonder why musl is doing this?
>

The problem is that the definition of that value is rather lacking.
Nobody really knows what the value is supposed to be, or what it could
be used for. At least for sysconf(_SC_NPROCESSORS_ONLN), we have a rough
idea, even though no conforming program could really tell the difference
between running on 16 processors and running on 1 processor. But _CONF?

_CONF could conceivably be the number of processors in the system, but
that is unstable under CPU hotplug. So maybe the maximum number of
processors the system can support? Or else the maximum number of
processors the kernel can support? The smaller of both? What about
disabled cores, do they count? And what would the value be used for?

We found one program that uses the value to get kernel CPU IDs, and
found that to be a bad use. That program should just have read
/proc/cpuinfo itself, then it could also have coped with non-contiguous
CPU IDs. Other than that, we could find no use of that value where the
value returned by musl was really wrong.

HTH,
Markus

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

end of thread, other threads:[~2022-11-21 20:36 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-11-21  8:51 [musl] about sysconf(_SC_NPROCESSORS_CONF) issue =?gb18030?B?zcPX09bt?=
2022-11-21 20:34 ` Markus Wichmann

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).