Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

rcu: Shrink RCU based on number of CPUs

Currently, rcu_init_geometry() only reshapes RCU's combining trees
if the leaf fanout is changed at boot time. This means that by
default, kernels compiled with (say) NR_CPUS=4096 will keep oversized
data structures, even when running on systems with (say) four CPUs.

This commit therefore checks to see if the maximum number of CPUs on
the actual running system (nr_cpu_ids) differs from NR_CPUS, and if so
reshapes the combining trees accordingly.

Reported-by: Mike Galbraith <efault@gmx.de>
Signed-off-by: Paul E. McKenney <paulmck@linux.vnet.ibm.com>

+2 -1
+2 -1
kernel/rcutree.c
··· 2821 2821 int rcu_capacity[MAX_RCU_LVLS + 1]; 2822 2822 2823 2823 /* If the compile-time values are accurate, just leave. */ 2824 - if (rcu_fanout_leaf == CONFIG_RCU_FANOUT_LEAF) 2824 + if (rcu_fanout_leaf == CONFIG_RCU_FANOUT_LEAF && 2825 + nr_cpu_ids == NR_CPUS) 2825 2826 return; 2826 2827 2827 2828 /*