Skip to content

Commit de078d8

Browse files
paulmckIngo Molnar
authored andcommitted
rcu: Need to update rnp->gpnum if preemptable RCU is to be reliable
Without this patch, tasks preempted in RCU read-side critical sections can fail to block the grace period, given that rnp->gpnum is used to determine which rnp->blocked_tasks[] element the preempted task is enqueued on. Before the patch, rnp->gpnum is always zero, so preempted tasks are always enqueued on rnp->blocked_tasks[0], which is correct only when the current CPU has not checked into the current grace period and the grace-period number is even, or, similarly, if the current CPU -has- checked into the current grace period and the grace-period number is odd. Signed-off-by: Paul E. McKenney <paulmck@linux.vnet.ibm.com> Acked-by: Steven Rostedt <rostedt@goodmis.org> Cc: laijs@cn.fujitsu.com Cc: dipankar@in.ibm.com Cc: akpm@linux-foundation.org Cc: mathieu.desnoyers@polymtl.ca Cc: josht@linux.vnet.ibm.com Cc: dvhltc@us.ibm.com Cc: niv@us.ibm.com Cc: peterz@infradead.org LKML-Reference: <12524504771622-git-send-email-> Signed-off-by: Ingo Molnar <mingo@elte.hu>
1 parent de55a89 commit de078d8

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

kernel/rcutree.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -632,6 +632,7 @@ rcu_start_gp(struct rcu_state *rsp, unsigned long flags)
632632
/* Special-case the common single-level case. */
633633
if (NUM_RCU_NODES == 1) {
634634
rnp->qsmask = rnp->qsmaskinit;
635+
rnp->gpnum = rsp->gpnum;
635636
rsp->signaled = RCU_SIGNAL_INIT; /* force_quiescent_state OK. */
636637
spin_unlock_irqrestore(&rnp->lock, flags);
637638
return;
@@ -657,8 +658,10 @@ rcu_start_gp(struct rcu_state *rsp, unsigned long flags)
657658
*/
658659

659660
rnp_end = rsp->level[NUM_RCU_LVLS - 1];
660-
for (rnp_cur = &rsp->node[0]; rnp_cur < rnp_end; rnp_cur++)
661+
for (rnp_cur = &rsp->node[0]; rnp_cur < rnp_end; rnp_cur++) {
661662
rnp_cur->qsmask = rnp_cur->qsmaskinit;
663+
rnp->gpnum = rsp->gpnum;
664+
}
662665

663666
/*
664667
* Now set up the leaf nodes. Here we must be careful. First,
@@ -679,6 +682,7 @@ rcu_start_gp(struct rcu_state *rsp, unsigned long flags)
679682
for (; rnp_cur < rnp_end; rnp_cur++) {
680683
spin_lock(&rnp_cur->lock); /* irqs already disabled. */
681684
rnp_cur->qsmask = rnp_cur->qsmaskinit;
685+
rnp->gpnum = rsp->gpnum;
682686
spin_unlock(&rnp_cur->lock); /* irqs already disabled. */
683687
}
684688

0 commit comments

Comments
 (0)