rcu.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] rcu: fix an infinite loop in rcu_gp_cleanup()
@ 2019-12-15  6:52 Qian Cai
  2019-12-15 20:16 ` Paul E. McKenney
  0 siblings, 1 reply; 3+ messages in thread
From: Qian Cai @ 2019-12-15  6:52 UTC (permalink / raw)
  To: paulmck, josh
  Cc: rostedt, mathieu.desnoyers, jiangshanlai, joel, tj, rcu,
	linux-kernel, Qian Cai

The commit 82150cb53dcb ("rcu: React to callback overload by
aggressively seeking quiescent states") introduced an infinite loop
during boot here,

// Reset overload indication for CPUs no longer overloaded
for_each_leaf_node_cpu_mask(rnp, cpu, rnp->cbovldmask) {
	rdp = per_cpu_ptr(&rcu_data, cpu);
	check_cb_ovld_locked(rdp, rnp);
}

because on an affected machine,

rnp->cbovldmask = 0
rnp->grphi = 127
rnp->grplo = 0

It ends up with "cpu" is always 64 and never be able to get out of the
loop due to "cpu <= rnp->grphi". It is pointless to enter the loop when
the cpumask is 0 as there is no CPU would be able to match it.

Fixes: 82150cb53dcb ("rcu: React to callback overload by aggressively seeking quiescent states")
Signed-off-by: Qian Cai <cai@lca.pw>
---
 kernel/rcu/rcu.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/kernel/rcu/rcu.h b/kernel/rcu/rcu.h
index ab504fbc76ca..fb691ec86df4 100644
--- a/kernel/rcu/rcu.h
+++ b/kernel/rcu/rcu.h
@@ -363,7 +363,7 @@ static inline void rcu_init_levelspread(int *levelspread, const int *levelcnt)
 	((rnp)->grplo + find_next_bit(&(mask), BITS_PER_LONG, (cpu)))
 #define for_each_leaf_node_cpu_mask(rnp, cpu, mask) \
 	for ((cpu) = rcu_find_next_bit((rnp), 0, (mask)); \
-	     (cpu) <= rnp->grphi; \
+	     (cpu) <= rnp->grphi && (mask); \
 	     (cpu) = rcu_find_next_bit((rnp), (cpu) + 1 - (rnp->grplo), (mask)))
 
 /*
-- 
2.21.0 (Apple Git-122.2)


^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2019-12-16 14:13 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-12-15  6:52 [PATCH] rcu: fix an infinite loop in rcu_gp_cleanup() Qian Cai
2019-12-15 20:16 ` Paul E. McKenney
2019-12-16 14:12   ` Qian Cai

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).