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.
Showing the changes to kernel (1 of 1 file). Show all
Unified · Split
| @@ -2180,7 +2180,6 @@ static void rcu_torture_fwd_cb_hist(struct rcu_fwd *rfp) · 2179 unmodified lines | ||
| 2180 | 2180 | for (i = ARRAY_SIZE(rfp->n_launders_hist) - 1; i > 0; i--) |
| 2181 | 2181 | if (rfp->n_launders_hist[i].n_launders > 0) |
| 2182 | 2182 | break; |
| 2183 | − mutex_lock(&rcu_fwd_mutex); // Serialize histograms. | |
| 2184 | 2183 | pr_alert("%s: Callback-invocation histogram %d (duration %lu jiffies):", |
| 2185 | 2184 | __func__, rfp->rcu_fwd_id, jiffies - rfp->rcu_fwd_startat); |
| 2186 | 2185 | gps_old = rfp->rcu_launder_gp_seq_start; |
| @@ -2193,7 +2192,6 @@ static void rcu_torture_fwd_cb_hist(struct rcu_fwd *rfp) · 6 unmodified lines | ||
| 2193 | 2192 | gps_old = gps; |
| 2194 | 2193 | } |
| 2195 | 2194 | pr_cont("\n"); |
| 2196 | − mutex_unlock(&rcu_fwd_mutex); | |
| 2197 | 2195 | } |
| 2198 | 2196 | |
| 2199 | 2197 | /* Callback function for continuous-flood RCU callbacks. */ |
| @@ -2431,7 +2429,9 @@ static void rcu_torture_fwd_prog_cr(struct rcu_fwd *rfp) · 231 unmodified lines | ||
| 2431 | 2429 | n_launders, n_launders_sa, |
| 2432 | 2430 | n_max_gps, n_max_cbs, cver, gps); |
| 2433 | 2431 | atomic_long_add(n_max_cbs, &rcu_fwd_max_cbs); |
| 2432 | + mutex_lock(&rcu_fwd_mutex); // Serialize histograms. | |
| 2434 | 2433 | rcu_torture_fwd_cb_hist(rfp); |
| 2434 | + mutex_unlock(&rcu_fwd_mutex); | |
| 2435 | 2435 | } |
| 2436 | 2436 | schedule_timeout_uninterruptible(HZ); /* Let CBs drain. */ |
| 2437 | 2437 | tick_dep_clear_task(current, TICK_DEP_BIT_RCU); |