Skip to content

Commit 49e2912

Browse files
paulmckIngo Molnar
authored andcommitted
rcu: Fix thinko, actually initialize full tree
Commit de078d8 ("rcu: Need to update rnp->gpnum if preemptable RCU is to be reliable") repeatedly and incorrectly initializes the root rcu_node structure's ->gpnum field rather than initializing the ->gpnum field of each node in the tree. Fix this. Also add an additional consistency check to catch this in the future. Signed-off-by: Paul E. McKenney <paulmck@linux.vnet.ibm.com> Cc: laijs@cn.fujitsu.com Cc: dipankar@in.ibm.com Cc: akpm@linux-foundation.org Cc: mathieu.desnoyers@polymtl.ca Cc: josh@joshtriplett.org Cc: dvhltc@us.ibm.com Cc: niv@us.ibm.com Cc: peterz@infradead.org Cc: rostedt@goodmis.org Cc: Valdis.Kletnieks@vt.edu LKML-Reference: <125329262011-git-send-email-> Signed-off-by: Ingo Molnar <mingo@elte.hu>
1 parent e7d8842 commit 49e2912

File tree

2 files changed

+7
-8
lines changed

2 files changed

+7
-8
lines changed

kernel/rcutree.c

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -601,8 +601,6 @@ rcu_start_gp(struct rcu_state *rsp, unsigned long flags)
601601
{
602602
struct rcu_data *rdp = rsp->rda[smp_processor_id()];
603603
struct rcu_node *rnp = rcu_get_root(rsp);
604-
struct rcu_node *rnp_cur;
605-
struct rcu_node *rnp_end;
606604

607605
if (!cpu_needs_another_gp(rsp, rdp)) {
608606
spin_unlock_irqrestore(&rnp->lock, flags);
@@ -659,13 +657,12 @@ rcu_start_gp(struct rcu_state *rsp, unsigned long flags)
659657
* one corresponding to this CPU, due to the fact that we have
660658
* irqs disabled.
661659
*/
662-
rnp_end = &rsp->node[NUM_RCU_NODES];
663-
for (rnp_cur = &rsp->node[0]; rnp_cur < rnp_end; rnp_cur++) {
664-
spin_lock(&rnp_cur->lock); /* irqs already disabled. */
660+
for (rnp = &rsp->node[0]; rnp < &rsp->node[NUM_RCU_NODES]; rnp++) {
661+
spin_lock(&rnp->lock); /* irqs already disabled. */
665662
rcu_preempt_check_blocked_tasks(rnp);
666-
rnp_cur->qsmask = rnp_cur->qsmaskinit;
663+
rnp->qsmask = rnp->qsmaskinit;
667664
rnp->gpnum = rsp->gpnum;
668-
spin_unlock(&rnp_cur->lock); /* irqs already disabled. */
665+
spin_unlock(&rnp->lock); /* irqs already disabled. */
669666
}
670667

671668
rsp->signaled = RCU_SIGNAL_INIT; /* force_quiescent_state now OK. */

kernel/rcutree_plugin.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -476,10 +476,12 @@ static void rcu_print_task_stall(struct rcu_node *rnp)
476476

477477
/*
478478
* Because there is no preemptable RCU, there can be no readers blocked,
479-
* so there is no need to check for blocked tasks.
479+
* so there is no need to check for blocked tasks. So check only for
480+
* bogus qsmask values.
480481
*/
481482
static void rcu_preempt_check_blocked_tasks(struct rcu_node *rnp)
482483
{
484+
WARN_ON_ONCE(rnp->qsmask);
483485
}
484486

485487
/*

0 commit comments

Comments
 (0)