Skip to content

Commit 81b4a7b

Browse files
committed
rcu-tasks: Disable CPU hotplug across RCU tasks trace scans
This commit disables CPU hotplug across RCU tasks trace scans, which is a first step towards correctly recognizing idle tasks "running" on offline CPUs. Signed-off-by: Paul E. McKenney <[email protected]>
1 parent b38f57c commit 81b4a7b

File tree

1 file changed

+14
-4
lines changed

1 file changed

+14
-4
lines changed

kernel/rcu/tasks.h

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -910,16 +910,16 @@ static void rcu_tasks_trace_pregp_step(void)
910910
{
911911
int cpu;
912912

913-
// Wait for CPU-hotplug paths to complete.
914-
cpus_read_lock();
915-
cpus_read_unlock();
916-
917913
// Allow for fast-acting IPIs.
918914
atomic_set(&trc_n_readers_need_end, 1);
919915

920916
// There shouldn't be any old IPIs, but...
921917
for_each_possible_cpu(cpu)
922918
WARN_ON_ONCE(per_cpu(trc_ipi_to_cpu, cpu));
919+
920+
// Disable CPU hotplug across the tasklist scan.
921+
// This also waits for all readers in CPU-hotplug code paths.
922+
cpus_read_lock();
923923
}
924924

925925
/* Do first-round processing for the specified task. */
@@ -935,6 +935,9 @@ static void rcu_tasks_trace_pertask(struct task_struct *t,
935935
/* Do intermediate processing between task and holdout scans. */
936936
static void rcu_tasks_trace_postscan(void)
937937
{
938+
// Re-enable CPU hotplug now that the tasklist scan has completed.
939+
cpus_read_unlock();
940+
938941
// Wait for late-stage exiting tasks to finish exiting.
939942
// These might have passed the call to exit_tasks_rcu_finish().
940943
synchronize_rcu();
@@ -979,6 +982,9 @@ static void check_all_holdout_tasks_trace(struct list_head *hop,
979982
{
980983
struct task_struct *g, *t;
981984

985+
// Disable CPU hotplug across the holdout list scan.
986+
cpus_read_lock();
987+
982988
list_for_each_entry_safe(t, g, hop, trc_holdout_list) {
983989
// If safe and needed, try to check the current task.
984990
if (READ_ONCE(t->trc_ipi_to_cpu) == -1 &&
@@ -991,6 +997,10 @@ static void check_all_holdout_tasks_trace(struct list_head *hop,
991997
else if (needreport)
992998
show_stalled_task_trace(t, firstreport);
993999
}
1000+
1001+
// Re-enable CPU hotplug now that the holdout list scan has completed.
1002+
cpus_read_unlock();
1003+
9941004
if (needreport) {
9951005
if (firstreport)
9961006
pr_err("INFO: rcu_tasks_trace detected stalls? (Late IPI?)\n");

0 commit comments

Comments
 (0)