fix: sysconf(_SC_NPROCESSORS_CONF) can be less than max cpu id
authorMichael Jeanson <mjeanson@efficios.com>
Wed, 27 Jul 2022 14:44:00 +0000 (10:44 -0400)
committerMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Wed, 3 Aug 2022 19:02:40 +0000 (15:02 -0400)
commit6b6204e4fa85ff8e9a909bc2a029b62c3f5c6793
treea2e48db8194f7b12abb63ade90d4584b0dc552db
parentc17d7f44e29a4295d80e20a648c3975e8e226eeb
fix: sysconf(_SC_NPROCESSORS_CONF) can be less than max cpu id

We rely on sysconf(_SC_NPROCESSORS_CONF) to get the maximum possible
number of CPUs that can be attached to the system for the lifetime of an
application.

As such we expect that the highest possible CPU id would be one less
than the number returned by sysconf(_SC_NPROCESSORS_CONF) which is
unfortunatly not always the case and can vary across libc
implementations and versions.

Glibc up to 2.35 will count the number of "cpuX" directories in
"/sys/devices/system/cpu" which doesn't include CPUS that were
hot-unplugged.

This information is however provided by the Linux kernel in
"/sys/devices/system/cpu/possible" in the form of a mask listing all the
CPUs that could possibly be hot-plugged in the system.

This patch replaces sysconf(_SC_NPROCESSORS_CONF) with an internal
function that first tries parsing the possible CPU mask to extract the
highest possible value and if this fails fallback to the previous
behavior.

Change-Id: I68dfed42ebbab02728a02eeefd4a395a22bb1bea
Signed-off-by: Michael Jeanson <mjeanson@efficios.com>
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
src/Makefile.am
src/compat-smp.h [new file with mode: 0644]
src/rculfhash.c
src/urcu-call-rcu-impl.h
This page took 0.026418 seconds and 4 git commands to generate.