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: Add tracing_reset_all_online_cpus_unlocked() function

Currently the tracing_reset_all_online_cpus() requires the
trace_types_lock held. But only one caller of this function actually has
that lock held before calling it, and the other just takes the lock so
that it can call it. More users of this function is needed where the lock
is not held.

Add a tracing_reset_all_online_cpus_unlocked() function for the one use
case that calls it without being held, and also add a lockdep_assert to
make sure it is held when called.

Then have tracing_reset_all_online_cpus() take the lock internally, such
that callers do not need to worry about taking it.

Link: https://lkml.kernel.org/r/20221123192741.658273220@goodmis.org

Cc: Masami Hiramatsu <mhiramat@kernel.org>
Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: Zheng Yejian <zhengyejian1@huawei.com>
Signed-off-by: Steven Rostedt (Google) <rostedt@goodmis.org>

+12 -4
+10 -1
kernel/trace/trace.c
··· 2180 2180 } 2181 2181 2182 2182 /* Must have trace_types_lock held */ 2183 - void tracing_reset_all_online_cpus(void) 2183 + void tracing_reset_all_online_cpus_unlocked(void) 2184 2184 { 2185 2185 struct trace_array *tr; 2186 + 2187 + lockdep_assert_held(&trace_types_lock); 2186 2188 2187 2189 list_for_each_entry(tr, &ftrace_trace_arrays, list) { 2188 2190 if (!tr->clear_trace) ··· 2195 2193 tracing_reset_online_cpus(&tr->max_buffer); 2196 2194 #endif 2197 2195 } 2196 + } 2197 + 2198 + void tracing_reset_all_online_cpus(void) 2199 + { 2200 + mutex_lock(&trace_types_lock); 2201 + tracing_reset_all_online_cpus_unlocked(); 2202 + mutex_unlock(&trace_types_lock); 2198 2203 } 2199 2204 2200 2205 /*
+1
kernel/trace/trace.h
··· 580 580 void tracing_reset_online_cpus(struct array_buffer *buf); 581 581 void tracing_reset_current(int cpu); 582 582 void tracing_reset_all_online_cpus(void); 583 + void tracing_reset_all_online_cpus_unlocked(void); 583 584 int tracing_open_generic(struct inode *inode, struct file *filp); 584 585 int tracing_open_generic_tr(struct inode *inode, struct file *filp); 585 586 bool tracing_is_disabled(void);
+1 -1
kernel/trace/trace_events.c
··· 2972 2972 * over from this module may be passed to the new module events and 2973 2973 * unexpected results may occur. 2974 2974 */ 2975 - tracing_reset_all_online_cpus(); 2975 + tracing_reset_all_online_cpus_unlocked(); 2976 2976 } 2977 2977 2978 2978 static int trace_module_notify(struct notifier_block *self,
-2
kernel/trace/trace_events_synth.c
··· 1425 1425 mutex_unlock(&event_mutex); 1426 1426 1427 1427 if (mod) { 1428 - mutex_lock(&trace_types_lock); 1429 1428 /* 1430 1429 * It is safest to reset the ring buffer if the module 1431 1430 * being unloaded registered any events that were ··· 1436 1437 * occur. 1437 1438 */ 1438 1439 tracing_reset_all_online_cpus(); 1439 - mutex_unlock(&trace_types_lock); 1440 1440 } 1441 1441 1442 1442 return ret;