rcu-tasks: Maintain a count of tasks blocking RCU Tasks Trace grace period
authorPaul E. McKenney <paulmck@kernel.org>
Thu, 2 Jun 2022 04:26:57 +0000 (21:26 -0700)
committerPaul E. McKenney <paulmck@kernel.org>
Tue, 21 Jun 2022 22:49:38 +0000 (15:49 -0700)
This commit maintains a new n_trc_holdouts counter that tracks the number
of tasks blocking the RCU Tasks grace period.  This counter is useful
for debugging, and its value has been added to a diagostic message.

Signed-off-by: Paul E. McKenney <paulmck@kernel.org>
Cc: Neeraj Upadhyay <quic_neeraju@quicinc.com>
Cc: Eric Dumazet <edumazet@google.com>
Cc: Alexei Starovoitov <ast@kernel.org>
Cc: Andrii Nakryiko <andrii@kernel.org>
Cc: Martin KaFai Lau <kafai@fb.com>
Cc: KP Singh <kpsingh@kernel.org>
kernel/rcu/tasks.h

index fe05520..9d7d6fd 100644 (file)
@@ -1206,6 +1206,7 @@ static DEFINE_PER_CPU(bool, trc_ipi_to_cpu);
 static unsigned long n_heavy_reader_attempts;
 static unsigned long n_heavy_reader_updates;
 static unsigned long n_heavy_reader_ofl_updates;
+static unsigned long n_trc_holdouts;
 
 void call_rcu_tasks_trace(struct rcu_head *rhp, rcu_callback_t func);
 DEFINE_RCU_TASKS(rcu_tasks_trace, rcu_tasks_wait_gp, call_rcu_tasks_trace,
@@ -1299,6 +1300,7 @@ static void trc_add_holdout(struct task_struct *t, struct list_head *bhp)
        if (list_empty(&t->trc_holdout_list)) {
                get_task_struct(t);
                list_add(&t->trc_holdout_list, bhp);
+               n_trc_holdouts++;
        }
 }
 
@@ -1308,6 +1310,7 @@ static void trc_del_holdout(struct task_struct *t)
        if (!list_empty(&t->trc_holdout_list)) {
                list_del_init(&t->trc_holdout_list);
                put_task_struct(t);
+               n_trc_holdouts--;
        }
 }
 
@@ -1760,7 +1763,8 @@ void show_rcu_tasks_trace_gp_kthread(void)
 {
        char buf[64];
 
-       sprintf(buf, "h:%lu/%lu/%lu",
+       sprintf(buf, "N%lu h:%lu/%lu/%lu",
+               data_race(n_trc_holdouts),
                data_race(n_heavy_reader_ofl_updates),
                data_race(n_heavy_reader_updates),
                data_race(n_heavy_reader_attempts));