Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

tracing: Just use this_cpu_read() to access ignore_pid

The ignore_pid boolean on the per CPU data descriptor is updated at
sched_switch when a new task is scheduled in. If the new task is to be
ignored, it is set to true, otherwise it is set to false. The current task
should always have the correct value as it is updated when the task is
scheduled in.

Instead of breaking up the read of this value, which requires preemption
to be disabled, just use this_cpu_read() which gives a snapshot of the
value. Since the value will always be correct for a given task (because
it's updated at sched switch) it doesn't need preemption disabled.

This will also allow trace events to be called with preemption enabled.

Cc: Masami Hiramatsu <mhiramat@kernel.org>
Cc: Mark Rutland <mark.rutland@arm.com>
Cc: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Cc: Andrew Morton <akpm@linux-foundation.org>
Link: https://lore.kernel.org/20250505212235.038958766@goodmis.org
Signed-off-by: Steven Rostedt (Google) <rostedt@goodmis.org>

+5 -4
+5 -4
kernel/trace/trace_events.c
··· 622 622 bool trace_event_ignore_this_pid(struct trace_event_file *trace_file) 623 623 { 624 624 struct trace_array *tr = trace_file->tr; 625 - struct trace_array_cpu *data; 626 625 struct trace_pid_list *no_pid_list; 627 626 struct trace_pid_list *pid_list; 628 627 ··· 631 632 if (!pid_list && !no_pid_list) 632 633 return false; 633 634 634 - data = this_cpu_ptr(tr->array_buffer.data); 635 - 636 - return data->ignore_pid; 635 + /* 636 + * This is recorded at every sched_switch for this task. 637 + * Thus, even if the task migrates the ignore value will be the same. 638 + */ 639 + return this_cpu_read(tr->array_buffer.data->ignore_pid) != 0; 637 640 } 638 641 EXPORT_SYMBOL_GPL(trace_event_ignore_this_pid); 639 642