]> git.baikalelectronics.ru Git - kernel.git/commit
rcu: Handle unbalanced rcu_node configurations with few CPUs
authorPaul E. McKenney <paulmck@linux.vnet.ibm.com>
Thu, 6 Sep 2012 04:43:57 +0000 (21:43 -0700)
committerPaul E. McKenney <paulmck@linux.vnet.ibm.com>
Sun, 23 Sep 2012 14:41:56 +0000 (07:41 -0700)
commit7b9dce6839d5623a3c62112cdc59cb9857d08a47
treedb9a40357ca52d6b135c95ea3186c3f89205520e
parente4f8d5a98281e56ad0c4d2af91b6eeec4debea5a
rcu: Handle unbalanced rcu_node configurations with few CPUs

If CONFIG_RCU_FANOUT_EXACT=y, if there are not enough CPUs (according
to nr_cpu_ids) to require more than a single rcu_node structure, but if
NR_CPUS is larger than would fit into a single rcu_node structure, then
the current rcu_init_levelspread() code is subject to integer overflow
in the eight-bit ->levelspread[] array in the rcu_state structure.

In this case, the solution is -not- to increase the size of the
elements in this array because the values in that array should be
constrained to the number of bits in an unsigned long.  Instead, this
commit replaces NR_CPUS with nr_cpu_ids in the rcu_init_levelspread()
function's initialization of the cprv local variable.  This results in
all of the arithmetic being consistently based off of the nr_cpu_ids
value, thus avoiding the overflow, which was caused by the mixing of
nr_cpu_ids and NR_CPUS.

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