Skip to content

Commit 52b1fc3

Browse files
committed
rcutorture: Add test of holding scheduler locks across rcu_read_unlock()
Now that it should be safe to hold scheduler locks across rcu_read_unlock(), even in cases where the corresponding RCU read-side critical section might have been preempted and boosted, the commit adds a test of this capability to rcutorture. This has been tested on current mainline (which can deadlock in this situation), and lockdep duly reported the expected deadlock. On -rcu, lockdep is silent, thus far, anyway. Cc: Ingo Molnar <[email protected]> Cc: Peter Zijlstra <[email protected]> Cc: Juri Lelli <[email protected]> Cc: Vincent Guittot <[email protected]> Signed-off-by: Paul E. McKenney <[email protected]>
1 parent 5f5fa7e commit 52b1fc3

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

kernel/rcu/rcutorture.c

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1147,6 +1147,7 @@ static void rcutorture_one_extend(int *readstate, int newstate,
11471147
struct torture_random_state *trsp,
11481148
struct rt_read_seg *rtrsp)
11491149
{
1150+
unsigned long flags;
11501151
int idxnew = -1;
11511152
int idxold = *readstate;
11521153
int statesnew = ~*readstate & newstate;
@@ -1181,8 +1182,15 @@ static void rcutorture_one_extend(int *readstate, int newstate,
11811182
rcu_read_unlock_bh();
11821183
if (statesold & RCUTORTURE_RDR_SCHED)
11831184
rcu_read_unlock_sched();
1184-
if (statesold & RCUTORTURE_RDR_RCU)
1185+
if (statesold & RCUTORTURE_RDR_RCU) {
1186+
bool lockit = !statesnew && !(torture_random(trsp) & 0xffff);
1187+
1188+
if (lockit)
1189+
raw_spin_lock_irqsave(&current->pi_lock, flags);
11851190
cur_ops->readunlock(idxold >> RCUTORTURE_RDR_SHIFT);
1191+
if (lockit)
1192+
raw_spin_unlock_irqrestore(&current->pi_lock, flags);
1193+
}
11861194

11871195
/* Delay if neither beginning nor end and there was a change. */
11881196
if ((statesnew || statesold) && *readstate && newstate)

0 commit comments

Comments
 (0)