Skip to content

Commit 89440d2

Browse files
committed
rcutorture: Fix rcu_fwd_mutex deadlock
The rcu_torture_fwd_cb_hist() function acquires rcu_fwd_mutex, but is invoked from rcutorture_oom_notify() function, which hold this same mutex across this call. This commit fixes the resulting deadlock. Reported-by: kernel test robot <oliver.sang@intel.com> Tested-by: Oliver Sang <oliver.sang@intel.com> Signed-off-by: Paul E. McKenney <paulmck@kernel.org>
1 parent 02b51a1 commit 89440d2

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

kernel/rcu/rcutorture.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2180,7 +2180,6 @@ static void rcu_torture_fwd_cb_hist(struct rcu_fwd *rfp)
21802180
for (i = ARRAY_SIZE(rfp->n_launders_hist) - 1; i > 0; i--)
21812181
if (rfp->n_launders_hist[i].n_launders > 0)
21822182
break;
2183-
mutex_lock(&rcu_fwd_mutex); // Serialize histograms.
21842183
pr_alert("%s: Callback-invocation histogram %d (duration %lu jiffies):",
21852184
__func__, rfp->rcu_fwd_id, jiffies - rfp->rcu_fwd_startat);
21862185
gps_old = rfp->rcu_launder_gp_seq_start;
@@ -2193,7 +2192,6 @@ static void rcu_torture_fwd_cb_hist(struct rcu_fwd *rfp)
21932192
gps_old = gps;
21942193
}
21952194
pr_cont("\n");
2196-
mutex_unlock(&rcu_fwd_mutex);
21972195
}
21982196

21992197
/* Callback function for continuous-flood RCU callbacks. */
@@ -2431,7 +2429,9 @@ static void rcu_torture_fwd_prog_cr(struct rcu_fwd *rfp)
24312429
n_launders, n_launders_sa,
24322430
n_max_gps, n_max_cbs, cver, gps);
24332431
atomic_long_add(n_max_cbs, &rcu_fwd_max_cbs);
2432+
mutex_lock(&rcu_fwd_mutex); // Serialize histograms.
24342433
rcu_torture_fwd_cb_hist(rfp);
2434+
mutex_unlock(&rcu_fwd_mutex);
24352435
}
24362436
schedule_timeout_uninterruptible(HZ); /* Let CBs drain. */
24372437
tick_dep_clear_task(current, TICK_DEP_BIT_RCU);

0 commit comments

Comments
 (0)