Skip to content

Commit 1577683

Browse files
committed
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>
1 parent c638ebd commit 1577683

1 file changed

Lines changed: 5 additions & 4 deletions

File tree

kernel/trace/trace_events.c

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -622,7 +622,6 @@ EXPORT_SYMBOL_GPL(trace_event_raw_init);
622622
bool trace_event_ignore_this_pid(struct trace_event_file *trace_file)
623623
{
624624
struct trace_array *tr = trace_file->tr;
625-
struct trace_array_cpu *data;
626625
struct trace_pid_list *no_pid_list;
627626
struct trace_pid_list *pid_list;
628627

@@ -632,9 +631,11 @@ bool trace_event_ignore_this_pid(struct trace_event_file *trace_file)
632631
if (!pid_list && !no_pid_list)
633632
return false;
634633

635-
data = this_cpu_ptr(tr->array_buffer.data);
636-
637-
return data->ignore_pid;
634+
/*
635+
* This is recorded at every sched_switch for this task.
636+
* Thus, even if the task migrates the ignore value will be the same.
637+
*/
638+
return this_cpu_read(tr->array_buffer.data->ignore_pid) != 0;
638639
}
639640
EXPORT_SYMBOL_GPL(trace_event_ignore_this_pid);
640641

0 commit comments

Comments
 (0)