tracing: Add rcu annotation around file->filter accesses

Running sparse on trace_events_filter.c triggered several warnings about
file->filter being accessed directly even though it's annotated with __rcu.

Add rcu_dereference() around it and shuffle the logic slightly so that
it's always referenced via accessor functions.

Cc: Masami Hiramatsu <mhiramat@kernel.org>
Cc: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Link: https://lore.kernel.org/20250607102821.6c7effbf@gandalf.local.home
Signed-off-by: Steven Rostedt (Google) <rostedt@goodmis.org>
pull/1212/merge
Steven Rostedt 2025-06-07 10:28:21 -04:00 committed by Steven Rostedt (Google)
parent de6fdc076d
commit 549e914c96
1 changed files with 6 additions and 4 deletions

View File

@ -1250,7 +1250,9 @@ static void append_filter_err(struct trace_array *tr,
static inline struct event_filter *event_filter(struct trace_event_file *file) static inline struct event_filter *event_filter(struct trace_event_file *file)
{ {
return file->filter; return rcu_dereference_protected(file->filter,
lockdep_is_held(&event_mutex));
} }
/* caller must hold event_mutex */ /* caller must hold event_mutex */
@ -1320,7 +1322,7 @@ void free_event_filter(struct event_filter *filter)
static inline void __remove_filter(struct trace_event_file *file) static inline void __remove_filter(struct trace_event_file *file)
{ {
filter_disable(file); filter_disable(file);
remove_filter_string(file->filter); remove_filter_string(event_filter(file));
} }
static void filter_free_subsystem_preds(struct trace_subsystem_dir *dir, static void filter_free_subsystem_preds(struct trace_subsystem_dir *dir,
@ -1405,7 +1407,7 @@ static void try_delay_free_filter(struct event_filter *filter)
static inline void __free_subsystem_filter(struct trace_event_file *file) static inline void __free_subsystem_filter(struct trace_event_file *file)
{ {
__free_filter(file->filter); __free_filter(event_filter(file));
file->filter = NULL; file->filter = NULL;
} }
@ -1465,7 +1467,7 @@ static void filter_free_subsystem_filters(struct trace_subsystem_dir *dir,
list_for_each_entry(file, &tr->events, list) { list_for_each_entry(file, &tr->events, list) {
if (file->system != dir || !file->filter) if (file->system != dir || !file->filter)
continue; continue;
__free_filter(file->filter); __free_subsystem_filter(file);
} }
__free_filter(filter); __free_filter(filter);
} }