Openwall GNU/*/Linux - a small security-enhanced Linux distro for servers
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Date: Tue, 2 Apr 2019 18:38:18 -0400 (EDT)
From: Mathieu Desnoyers <>
To: Szabolcs Nagy <>
Cc: musl <>, Michael Jeanson <>, 
	Richard Purdie <>, 
	Jonathan Rajotte <>
Subject: Re: sysconf(_SC_NPROCESSORS_CONF) returns the wrong value

----- On Apr 2, 2019, at 3:02 PM, Szabolcs Nagy wrote:

> * Mathieu Desnoyers <> [2019-03-26 14:01:08
> -0400]:
>> ----- On Mar 26, 2019, at 1:45 PM, Szabolcs Nagy wrote:
>> > i agree that the current behaviour is not ideal, but
>> > iterating over /sys/devices/system/cpu/cpu* may not
>> > be correct either.. based on current linux api docs.
>> > 
>> > i don't understand why is that number different from the
>> > cpu set in /sys/devices/system/cpu/possible
>> I suspect both iteration over /sys/devices/system/cpu/cpu* and
>> content of /sys/devices/system/cpu/possible should provide the
>> same result. However, looking at Linux
>> Documentation/ABI/testing/sysfs-devices-system-cpu ,
>> it appears that /sys/devices/system/cpu/possible was introduced
>> in December 2008, whereas /sys/devices/system/cpu/cpu#/ was there
>> pre-git history.
>> This could explain why glibc uses the iteration method.
>> Thoughts ?
> as far as i can tell the cpu iteration method is valid,
> and that directory list cannot change after boot (is this
> guaranteed by the linux abi in the future?), so as long
> as /sys is mounted we can get the number, but it's fairly
> ugly.. does lttng have fallback code if sysconf returns -1?
> if it does maybe musl should just do that (or somebody has
> to write cancellation safe directory traversal code)

Nope, the lttng-ust ring buffer won't be usable anyway. I
*think* we need to improve the error handling for that scenario
within our consumer daemon which is responsible for buffer
allocation. I don't think we properly error out if the internal
variable tracking the number of CPUs in the system stays at its
unitialized value of 0.



Mathieu Desnoyers
EfficiOS Inc.

Powered by blists - more mailing lists

Your e-mail address:

Confused about mailing lists and their use? Read about mailing lists on Wikipedia and check out these guidelines on proper formatting of your messages.