History

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

Steven Rostedt (Google) committed 3 years ago

Commit e18eb871 parent ef38c794 files · +12 −4Browse files

Showing the changes to kernel (4 of 4 files). Show all

Unified · Split

4 files
  1. kernel/trace/trace.c +10 −1
  2. kernel/trace/trace.h +1 −0
  3. kernel/trace/trace_events.c +1 −1
  4. kernel/trace/trace_events_synth.c +0 −2
kernel/trace/trace.c+10−1
@@ -2180,10 +2180,12 @@ void tracing_reset_online_cpus(struct array_buffer *buf) · 2179 unmodified lines
2180}2180}
2181 2181
2182/* Must have trace_types_lock held */2182/* Must have trace_types_lock held */
2183void tracing_reset_all_online_cpus(void)2183void tracing_reset_all_online_cpus_unlocked(void)
2184{2184{
2185 struct trace_array *tr;2185 struct trace_array *tr;
2186 2186
2187 lockdep_assert_held(&trace_types_lock);
2188
2187 list_for_each_entry(tr, &ftrace_trace_arrays, list) {2189 list_for_each_entry(tr, &ftrace_trace_arrays, list) {
2188 if (!tr->clear_trace)2190 if (!tr->clear_trace)
2189 continue;2191 continue;
@@ -2195,6 +2197,13 @@ void tracing_reset_all_online_cpus(void) · 5 unmodified lines
2195 }2197 }
2196}2198}
2197 2199
2200void tracing_reset_all_online_cpus(void)
2201{
2202 mutex_lock(&trace_types_lock);
2203 tracing_reset_all_online_cpus_unlocked();
2204 mutex_unlock(&trace_types_lock);
2205}
2206
2198/*2207/*
2199 * The tgid_map array maps from pid to tgid; i.e. the value stored at index i2208 * The tgid_map array maps from pid to tgid; i.e. the value stored at index i
2200 * is the tgid last observed corresponding to pid=i.2209 * is the tgid last observed corresponding to pid=i.
kernel/trace/trace.h+1−0
@@ -580,6 +580,7 @@ int tracing_is_enabled(void); · 579 unmodified lines
580void tracing_reset_online_cpus(struct array_buffer *buf);580void tracing_reset_online_cpus(struct array_buffer *buf);
581void tracing_reset_current(int cpu);581void tracing_reset_current(int cpu);
582void tracing_reset_all_online_cpus(void);582void tracing_reset_all_online_cpus(void);
583void tracing_reset_all_online_cpus_unlocked(void);
583int tracing_open_generic(struct inode *inode, struct file *filp);584int tracing_open_generic(struct inode *inode, struct file *filp);
584int tracing_open_generic_tr(struct inode *inode, struct file *filp);585int tracing_open_generic_tr(struct inode *inode, struct file *filp);
585bool tracing_is_disabled(void);586bool tracing_is_disabled(void);
kernel/trace/trace_events.c+1−1
@@ -2972,7 +2972,7 @@ static void trace_module_remove_events(struct module *mod) · 2971 unmodified lines
2972 * over from this module may be passed to the new module events and2972 * over from this module may be passed to the new module events and
2973 * unexpected results may occur.2973 * unexpected results may occur.
2974 */2974 */
2975 tracing_reset_all_online_cpus();2975 tracing_reset_all_online_cpus_unlocked();
2976}2976}
2977 2977
2978static int trace_module_notify(struct notifier_block *self,2978static int trace_module_notify(struct notifier_block *self,
kernel/trace/trace_events_synth.c+0−2
@@ -1425,7 +1425,6 @@ int synth_event_delete(const char *event_name) · 1424 unmodified lines
1425 mutex_unlock(&event_mutex);1425 mutex_unlock(&event_mutex);
1426 1426
1427 if (mod) {1427 if (mod) {
1428 mutex_lock(&trace_types_lock);
1429 /*1428 /*
1430 * It is safest to reset the ring buffer if the module1429 * It is safest to reset the ring buffer if the module
1431 * being unloaded registered any events that were1430 * being unloaded registered any events that were
@@ -1437,7 +1436,6 @@ int synth_event_delete(const char *event_name) · 5 unmodified lines
1437 * occur.1436 * occur.
1438 */1437 */
1439 tracing_reset_all_online_cpus();1438 tracing_reset_all_online_cpus();
1440 mutex_unlock(&trace_types_lock);
1441 }1439 }
1442 1440
1443 return ret;1441 return ret;

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t