linux: Use /sys/devices/system/cpu on __get_nprocs_conf (BZ#28991)
authorAdhemerval Zanella <adhemerval.zanella@linaro.org>
Wed, 23 Mar 2022 20:29:03 +0000 (17:29 -0300)
committerAdhemerval Zanella <adhemerval.zanella@linaro.org>
Mon, 16 May 2022 17:26:49 +0000 (14:26 -0300)
commit97a912f7a832a662960749948049e15f3aecb2a7
tree1cbe5852bd6175c6554cc2a405517de9a8787a0e
parentf787e138aa0bf677bf74fa2a08595c446292f3d7
linux: Use /sys/devices/system/cpu on __get_nprocs_conf (BZ#28991)

Currently on Linux __get_nprocs_conf first tries to enumerate the
cpus present in the system by iterating on /sys/devices/system/cpuX
directories.  This only enumerates the CPUs that are present in
system (but possibly offline), not taking in account possible CPU
that might added in the system through hotplugging.

Linux provides the maximum number of configured cpus on the
/sys/devices/system/cpu file.  Although it might present a larger
value of possible active CPUs on some system (where kernel either
get the information from firmaware or is configured at boot time),
the information is what kernel presents to userland.

This also change the returned value of _SC_NPROCESSORS_CONF, which
aligns as the maximum configure cpu in the system.

Checked on x86_64-linux-gnu.

Reviewed-by: Florian Weimer <fweimer@redhat.com>
sysdeps/unix/sysv/linux/getsysstats.c