Skip to content

Commit 6e91f8c

Browse files
committed
rcu: Correctly handle non-empty Tiny RCU callback list with none ready
If, at the time __rcu_process_callbacks() is invoked, there are callbacks in Tiny RCU's callback list, but none of them are ready to be invoked, the current list-management code will knit the non-ready callbacks out of the list. This can result in hangs and possibly worse. This commit therefore inserts a check for there being no callbacks that can be invoked immediately. This bug is unlikely to occur -- you have to get a new callback between the time rcu_sched_qs() or rcu_bh_qs() was called, but before we get to __rcu_process_callbacks(). It was detected by the addition of RCU-bh testing to rcutorture, which in turn was instigated by Iftekhar Ahmed's mutation testing. Although this bug was made much more likely by 915e8a4 (rcu: Remove fastpath from __rcu_process_callbacks()), this did not cause the bug, but rather made it much more probable. That said, it takes more than 40 hours of rcutorture testing, on average, for this bug to appear, so this fix cannot be considered an emergency. Signed-off-by: Paul E. McKenney <paulmck@linux.vnet.ibm.com> Cc: <stable@vger.kernel.org> Reviewed-by: Josh Triplett <josh@joshtriplett.org>
1 parent f13bad9 commit 6e91f8c

1 file changed

Lines changed: 5 additions & 0 deletions

File tree

‎kernel/rcu/tiny.c‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,11 @@ static void __rcu_process_callbacks(struct rcu_ctrlblk *rcp)
137137

138138
/* Move the ready-to-invoke callbacks to a local list. */
139139
local_irq_save(flags);
140+
if (rcp->donetail == &rcp->rcucblist) {
141+
/* No callbacks ready, so just leave. */
142+
local_irq_restore(flags);
143+
return;
144+
}
140145
RCU_TRACE(trace_rcu_batch_start(rcp->name, 0, rcp->qlen, -1));
141146
list = rcp->rcucblist;
142147
rcp->rcucblist = *rcp->donetail;

0 commit comments

Comments
 (0)