Skip to content

Commit 4047150

Browse files
committed
rcu-tasks: Add rcu_dynticks_zero_in_eqs() effectiveness statistics
This commit adds counts of the number of calls and number of successful calls to rcu_dynticks_zero_in_eqs(), which are printed at the end of rcutorture runs and at stall time. This allows evaluation of the effectiveness of rcu_dynticks_zero_in_eqs(). Signed-off-by: Paul E. McKenney <[email protected]>
1 parent 9796e1a commit 4047150

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

kernel/rcu/tasks.h

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -725,6 +725,11 @@ DECLARE_WAIT_QUEUE_HEAD(trc_wait); // List of holdout tasks.
725725
// Record outstanding IPIs to each CPU. No point in sending two...
726726
static DEFINE_PER_CPU(bool, trc_ipi_to_cpu);
727727

728+
// The number of detections of task quiescent state relying on
729+
// heavyweight readers executing explicit memory barriers.
730+
unsigned long n_heavy_reader_attempts;
731+
unsigned long n_heavy_reader_updates;
732+
728733
void call_rcu_tasks_trace(struct rcu_head *rhp, rcu_callback_t func);
729734
DEFINE_RCU_TASKS(rcu_tasks_trace, rcu_tasks_wait_gp, call_rcu_tasks_trace,
730735
"RCU Tasks Trace");
@@ -830,9 +835,11 @@ static bool trc_inspect_reader(struct task_struct *t, void *arg)
830835
// If heavyweight readers are enabled on the remote task,
831836
// we can inspect its state despite its currently running.
832837
// However, we cannot safely change its state.
838+
n_heavy_reader_attempts++;
833839
if (!ofl && // Check for "running" idle tasks on offline CPUs.
834840
!rcu_dynticks_zero_in_eqs(cpu, &t->trc_reader_nesting))
835841
return false; // No quiescent state, do it the hard way.
842+
n_heavy_reader_updates++;
836843
in_qs = true;
837844
} else {
838845
in_qs = likely(!t->trc_reader_nesting);
@@ -1147,9 +1154,11 @@ core_initcall(rcu_spawn_tasks_trace_kthread);
11471154

11481155
static void show_rcu_tasks_trace_gp_kthread(void)
11491156
{
1150-
char buf[32];
1157+
char buf[64];
11511158

1152-
sprintf(buf, "N%d", atomic_read(&trc_n_readers_need_end));
1159+
sprintf(buf, "N%d h:%lu/%lu", atomic_read(&trc_n_readers_need_end),
1160+
data_race(n_heavy_reader_updates),
1161+
data_race(n_heavy_reader_attempts));
11531162
show_rcu_tasks_generic_gp_kthread(&rcu_tasks_trace, buf);
11541163
}
11551164

0 commit comments

Comments
 (0)