]> git.baikalelectronics.ru Git - kernel.git/commit
cpu/hotplug: Cache number of online CPUs
authorThomas Gleixner <tglx@linutronix.de>
Tue, 9 Jul 2019 14:23:40 +0000 (16:23 +0200)
committerThomas Gleixner <tglx@linutronix.de>
Thu, 25 Jul 2019 13:48:01 +0000 (15:48 +0200)
commit0b280d34fa70b4fb2de7567d3459baecd6dae724
tree813c75e34ed913bf7dbe7b8e7dfbda997ac27071
parente2ced5011fb724ace5c2903c9bfd753fa4e5db9c
cpu/hotplug: Cache number of online CPUs

Re-evaluating the bitmap wheight of the online cpus bitmap in every
invocation of num_online_cpus() over and over is a pretty useless
exercise. Especially when num_online_cpus() is used in code paths
like the IPI delivery of x86 or the membarrier code.

Cache the number of online CPUs in the core and just return the cached
variable. The accessor function provides only a snapshot when used without
protection against concurrent CPU hotplug.

The storage needs to use an atomic_t because the kexec and reboot code
(ab)use set_cpu_online() in their 'shutdown' handlers without any form of
serialization as pointed out by Mathieu. Regular CPU hotplug usage is
properly serialized.

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Reviewed-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Link: https://lkml.kernel.org/r/alpine.DEB.2.21.1907091622590.1634@nanos.tec.linutronix.de
include/linux/cpumask.h
kernel/cpu.c