diff options
author | Steven Rostedt <srostedt@redhat.com> | 2010-06-08 11:22:06 -0400 |
---|---|---|
committer | Steven Rostedt <rostedt@goodmis.org> | 2010-06-28 21:13:14 -0400 |
commit | a1d0ce8213e9ddf4046ef5ba95c55762d075f541 (patch) | |
tree | c72fb18588de555c8fa0c61452ae14ffe37dbf8a /kernel/trace/trace_events.c | |
parent | d62f85d1e22e537192ce494c89540e1ac0d8bfc7 (diff) |
tracing: Use class->reg() for all registering of events
Because kprobes and syscalls need special processing to register
events, the class->reg() method was created to handle the differences.
But instead of creating a default ->reg for perf and ftrace events,
the code was scattered with:
if (class->reg)
class->reg();
else
default_reg();
This is messy and can also lead to bugs.
This patch cleans up this code and creates a default reg() entry for
the events allowing for the code to directly call the class->reg()
without the condition.
Reported-by: Peter Zijlstra <peterz@infradead.org>
Acked-by: Peter Zijlstra <peterz@infradead.org>
Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
Diffstat (limited to 'kernel/trace/trace_events.c')
-rw-r--r-- | kernel/trace/trace_events.c | 55 |
1 files changed, 36 insertions, 19 deletions
diff --git a/kernel/trace/trace_events.c b/kernel/trace/trace_events.c index 69bee4cc0e10..e8e6043f4d29 100644 --- a/kernel/trace/trace_events.c +++ b/kernel/trace/trace_events.c | |||
@@ -141,6 +141,35 @@ int trace_event_raw_init(struct ftrace_event_call *call) | |||
141 | } | 141 | } |
142 | EXPORT_SYMBOL_GPL(trace_event_raw_init); | 142 | EXPORT_SYMBOL_GPL(trace_event_raw_init); |
143 | 143 | ||
144 | int ftrace_event_reg(struct ftrace_event_call *call, enum trace_reg type) | ||
145 | { | ||
146 | switch (type) { | ||
147 | case TRACE_REG_REGISTER: | ||
148 | return tracepoint_probe_register(call->name, | ||
149 | call->class->probe, | ||
150 | call); | ||
151 | case TRACE_REG_UNREGISTER: | ||
152 | tracepoint_probe_unregister(call->name, | ||
153 | call->class->probe, | ||
154 | call); | ||
155 | return 0; | ||
156 | |||
157 | #ifdef CONFIG_PERF_EVENTS | ||
158 | case TRACE_REG_PERF_REGISTER: | ||
159 | return tracepoint_probe_register(call->name, | ||
160 | call->class->perf_probe, | ||
161 | call); | ||
162 | case TRACE_REG_PERF_UNREGISTER: | ||
163 | tracepoint_probe_unregister(call->name, | ||
164 | call->class->perf_probe, | ||
165 | call); | ||
166 | return 0; | ||
167 | #endif | ||
168 | } | ||
169 | return 0; | ||
170 | } | ||
171 | EXPORT_SYMBOL_GPL(ftrace_event_reg); | ||
172 | |||
144 | static int ftrace_event_enable_disable(struct ftrace_event_call *call, | 173 | static int ftrace_event_enable_disable(struct ftrace_event_call *call, |
145 | int enable) | 174 | int enable) |
146 | { | 175 | { |
@@ -151,23 +180,13 @@ static int ftrace_event_enable_disable(struct ftrace_event_call *call, | |||
151 | if (call->flags & TRACE_EVENT_FL_ENABLED) { | 180 | if (call->flags & TRACE_EVENT_FL_ENABLED) { |
152 | call->flags &= ~TRACE_EVENT_FL_ENABLED; | 181 | call->flags &= ~TRACE_EVENT_FL_ENABLED; |
153 | tracing_stop_cmdline_record(); | 182 | tracing_stop_cmdline_record(); |
154 | if (call->class->reg) | 183 | call->class->reg(call, TRACE_REG_UNREGISTER); |
155 | call->class->reg(call, TRACE_REG_UNREGISTER); | ||
156 | else | ||
157 | tracepoint_probe_unregister(call->name, | ||
158 | call->class->probe, | ||
159 | call); | ||
160 | } | 184 | } |
161 | break; | 185 | break; |
162 | case 1: | 186 | case 1: |
163 | if (!(call->flags & TRACE_EVENT_FL_ENABLED)) { | 187 | if (!(call->flags & TRACE_EVENT_FL_ENABLED)) { |
164 | tracing_start_cmdline_record(); | 188 | tracing_start_cmdline_record(); |
165 | if (call->class->reg) | 189 | ret = call->class->reg(call, TRACE_REG_REGISTER); |
166 | ret = call->class->reg(call, TRACE_REG_REGISTER); | ||
167 | else | ||
168 | ret = tracepoint_probe_register(call->name, | ||
169 | call->class->probe, | ||
170 | call); | ||
171 | if (ret) { | 190 | if (ret) { |
172 | tracing_stop_cmdline_record(); | 191 | tracing_stop_cmdline_record(); |
173 | pr_info("event trace: Could not enable event " | 192 | pr_info("event trace: Could not enable event " |
@@ -205,8 +224,7 @@ static int __ftrace_set_clr_event(const char *match, const char *sub, | |||
205 | mutex_lock(&event_mutex); | 224 | mutex_lock(&event_mutex); |
206 | list_for_each_entry(call, &ftrace_events, list) { | 225 | list_for_each_entry(call, &ftrace_events, list) { |
207 | 226 | ||
208 | if (!call->name || !call->class || | 227 | if (!call->name || !call->class || !call->class->reg) |
209 | (!call->class->probe && !call->class->reg)) | ||
210 | continue; | 228 | continue; |
211 | 229 | ||
212 | if (match && | 230 | if (match && |
@@ -332,7 +350,7 @@ t_next(struct seq_file *m, void *v, loff_t *pos) | |||
332 | * The ftrace subsystem is for showing formats only. | 350 | * The ftrace subsystem is for showing formats only. |
333 | * They can not be enabled or disabled via the event files. | 351 | * They can not be enabled or disabled via the event files. |
334 | */ | 352 | */ |
335 | if (call->class && (call->class->probe || call->class->reg)) | 353 | if (call->class && call->class->reg) |
336 | return call; | 354 | return call; |
337 | } | 355 | } |
338 | 356 | ||
@@ -485,8 +503,7 @@ system_enable_read(struct file *filp, char __user *ubuf, size_t cnt, | |||
485 | 503 | ||
486 | mutex_lock(&event_mutex); | 504 | mutex_lock(&event_mutex); |
487 | list_for_each_entry(call, &ftrace_events, list) { | 505 | list_for_each_entry(call, &ftrace_events, list) { |
488 | if (!call->name || !call->class || | 506 | if (!call->name || !call->class || !call->class->reg) |
489 | (!call->class->probe && !call->class->reg)) | ||
490 | continue; | 507 | continue; |
491 | 508 | ||
492 | if (system && strcmp(call->class->system, system) != 0) | 509 | if (system && strcmp(call->class->system, system) != 0) |
@@ -977,12 +994,12 @@ event_create_dir(struct ftrace_event_call *call, struct dentry *d_events, | |||
977 | return -1; | 994 | return -1; |
978 | } | 995 | } |
979 | 996 | ||
980 | if (call->class->probe || call->class->reg) | 997 | if (call->class->reg) |
981 | trace_create_file("enable", 0644, call->dir, call, | 998 | trace_create_file("enable", 0644, call->dir, call, |
982 | enable); | 999 | enable); |
983 | 1000 | ||
984 | #ifdef CONFIG_PERF_EVENTS | 1001 | #ifdef CONFIG_PERF_EVENTS |
985 | if (call->event.type && (call->class->perf_probe || call->class->reg)) | 1002 | if (call->event.type && call->class->reg) |
986 | trace_create_file("id", 0444, call->dir, call, | 1003 | trace_create_file("id", 0444, call->dir, call, |
987 | id); | 1004 | id); |
988 | #endif | 1005 | #endif |