Skip to content

Commit 5bef8da

Browse files
committed
rcu: Add per-task state to RCU CPU stall warnings
Currently, an RCU-preempt CPU stall warning simply lists the PIDs of those tasks holding up the current grace period. This can be helpful, but more can be even more helpful. To this end, this commit adds the nesting level, whether the task thinks it was preempted in its current RCU read-side critical section, whether RCU core has asked this task for a quiescent state, whether the expedited-grace-period hint is set, and whether the task believes that it is on the blocked-tasks list (it must be, or it would not be printed, but if things are broken, best not to take too much for granted). Signed-off-by: Paul E. McKenney <[email protected]>
1 parent 2beaf32 commit 5bef8da

File tree

1 file changed

+36
-2
lines changed

1 file changed

+36
-2
lines changed

kernel/rcu/tree_stall.h

Lines changed: 36 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -192,14 +192,40 @@ static void rcu_print_detail_task_stall_rnp(struct rcu_node *rnp)
192192
raw_spin_unlock_irqrestore_rcu_node(rnp, flags);
193193
}
194194

195+
// Communicate task state back to the RCU CPU stall warning request.
196+
struct rcu_stall_chk_rdr {
197+
int nesting;
198+
union rcu_special rs;
199+
bool on_blkd_list;
200+
};
201+
202+
/*
203+
* Report out the state of a not-running task that is stalling the
204+
* current RCU grace period.
205+
*/
206+
static bool check_slow_task(struct task_struct *t, void *arg)
207+
{
208+
struct rcu_node *rnp;
209+
struct rcu_stall_chk_rdr *rscrp = arg;
210+
211+
if (task_curr(t))
212+
return false; // It is running, so decline to inspect it.
213+
rscrp->nesting = t->rcu_read_lock_nesting;
214+
rscrp->rs = t->rcu_read_unlock_special;
215+
rnp = t->rcu_blocked_node;
216+
rscrp->on_blkd_list = !list_empty(&t->rcu_node_entry);
217+
return true;
218+
}
219+
195220
/*
196221
* Scan the current list of tasks blocked within RCU read-side critical
197222
* sections, printing out the tid of each.
198223
*/
199224
static int rcu_print_task_stall(struct rcu_node *rnp)
200225
{
201-
struct task_struct *t;
202226
int ndetected = 0;
227+
struct rcu_stall_chk_rdr rscr;
228+
struct task_struct *t;
203229

204230
if (!rcu_preempt_blocked_readers_cgp(rnp))
205231
return 0;
@@ -208,7 +234,15 @@ static int rcu_print_task_stall(struct rcu_node *rnp)
208234
t = list_entry(rnp->gp_tasks->prev,
209235
struct task_struct, rcu_node_entry);
210236
list_for_each_entry_continue(t, &rnp->blkd_tasks, rcu_node_entry) {
211-
pr_cont(" P%d", t->pid);
237+
if (!try_invoke_on_locked_down_task(t, check_slow_task, &rscr))
238+
pr_cont(" P%d", t->pid);
239+
else
240+
pr_cont(" P%d/%d:%c%c%c%c",
241+
t->pid, rscr.nesting,
242+
".b"[rscr.rs.b.blocked],
243+
".q"[rscr.rs.b.need_qs],
244+
".e"[rscr.rs.b.exp_hint],
245+
".l"[rscr.on_blkd_list]);
212246
ndetected++;
213247
}
214248
pr_cont("\n");

0 commit comments

Comments
 (0)