Skip to content

Commit a56ca56

Browse files
committed
rcutorture: Update ->extendables check for lazy preemption
The rcutorture_one_extend_check() function's second last check assumes that "preempt_count() & PREEMPT_MASK" is non-zero only if RCUTORTURE_RDR_PREEMPT or RCUTORTURE_RDR_SCHED bit is set. This works for preemptible RCU and for non-preemptible RCU running in a non-preemptible kernel. But it fails for non-preemptible RCU running in a preemptible kernel because then rcu_read_lock() is just preempt_disable(), which increases preempt count. This commit therefore adjusts this check to take into account the case fo non-preemptible RCU running in a preemptible kernel. Reviewed-by: Paul E. McKenney <paulmck@kernel.org> Signed-off-by: Boqun Feng <boqun.feng@gmail.com>
1 parent 0be4b19 commit a56ca56

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

kernel/rcu/rcutorture.c

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1901,8 +1901,16 @@ static void rcutorture_one_extend_check(char *s, int curstate, int new, int old,
19011901
WARN_ONCE(cur_ops->extendables &&
19021902
!(curstate & (RCUTORTURE_RDR_BH | RCUTORTURE_RDR_RBH)) &&
19031903
(preempt_count() & SOFTIRQ_MASK), ROEC_ARGS);
1904-
WARN_ONCE(cur_ops->extendables &&
1905-
!(curstate & (RCUTORTURE_RDR_PREEMPT | RCUTORTURE_RDR_SCHED)) &&
1904+
1905+
/*
1906+
* non-preemptible RCU in a preemptible kernel uses preempt_disable()
1907+
* as rcu_read_lock().
1908+
*/
1909+
mask = RCUTORTURE_RDR_PREEMPT | RCUTORTURE_RDR_SCHED;
1910+
if (!IS_ENABLED(CONFIG_PREEMPT_RCU))
1911+
mask |= RCUTORTURE_RDR_RCU_1 | RCUTORTURE_RDR_RCU_2;
1912+
1913+
WARN_ONCE(cur_ops->extendables && !(curstate & mask) &&
19061914
(preempt_count() & PREEMPT_MASK), ROEC_ARGS);
19071915

19081916
/*

0 commit comments

Comments
 (0)