From: Steven Rostedt Date: Mon, 5 May 2025 21:21:07 +0000 (-0400) Subject: tracing: Just use this_cpu_read() to access ignore_pid X-Git-Tag: v6.16-rc1~121^2~21 X-Git-Url: https://git.kernel.dk/?a=commitdiff_plain;h=1577683a925f63862e81d27246a3a0bc1f6e39ad;p=linux-block.git 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 Cc: Mark Rutland Cc: Mathieu Desnoyers Cc: Andrew Morton Link: https://lore.kernel.org/20250505212235.038958766@goodmis.org Signed-off-by: Steven Rostedt (Google) --- diff --git a/kernel/trace/trace_events.c b/kernel/trace/trace_events.c index 069e92856bda..fe0ea14d809e 100644 --- a/kernel/trace/trace_events.c +++ b/kernel/trace/trace_events.c @@ -622,7 +622,6 @@ EXPORT_SYMBOL_GPL(trace_event_raw_init); bool trace_event_ignore_this_pid(struct trace_event_file *trace_file) { struct trace_array *tr = trace_file->tr; - struct trace_array_cpu *data; struct trace_pid_list *no_pid_list; struct trace_pid_list *pid_list; @@ -632,9 +631,11 @@ bool trace_event_ignore_this_pid(struct trace_event_file *trace_file) if (!pid_list && !no_pid_list) return false; - data = this_cpu_ptr(tr->array_buffer.data); - - return data->ignore_pid; + /* + * This is recorded at every sched_switch for this task. + * Thus, even if the task migrates the ignore value will be the same. + */ + return this_cpu_read(tr->array_buffer.data->ignore_pid) != 0; } EXPORT_SYMBOL_GPL(trace_event_ignore_this_pid);