diff options
author | Steven Rostedt (Red Hat) <rostedt@goodmis.org> | 2015-03-25 20:44:21 +0100 |
---|---|---|
committer | Steven Rostedt <rostedt@goodmis.org> | 2015-04-08 15:39:57 +0200 |
commit | 3673b8e4ce7237160fa31ee8d7e94a4d5a9976a1 (patch) | |
tree | dbbc779ed3883db285d243d85452a7e603120d85 /kernel/trace | |
parent | tracing: Add TRACE_DEFINE_ENUM() macro to map enums to their values (diff) | |
download | linux-3673b8e4ce7237160fa31ee8d7e94a4d5a9976a1.tar.xz linux-3673b8e4ce7237160fa31ee8d7e94a4d5a9976a1.zip |
tracing: Allow for modules to convert their enums to values
Update the infrastructure such that modules that declare TRACE_DEFINE_ENUM()
will have those enums converted into their values in the tracepoint
print fmt strings.
Link: http://lkml.kernel.org/r/87vbhjp74q.fsf@rustcorp.com.au
Acked-by: Rusty Russell <rusty@rustcorp.com.au>
Reviewed-by: Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com>
Tested-by: Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com>
Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
Diffstat (limited to 'kernel/trace')
-rw-r--r-- | kernel/trace/trace.c | 49 | ||||
-rw-r--r-- | kernel/trace/trace_events.c | 2 |
2 files changed, 46 insertions, 5 deletions
diff --git a/kernel/trace/trace.c b/kernel/trace/trace.c index ebf49649534c..28e6654e640d 100644 --- a/kernel/trace/trace.c +++ b/kernel/trace/trace.c @@ -3908,11 +3908,9 @@ static const struct file_operations tracing_saved_cmdlines_size_fops = { .write = tracing_saved_cmdlines_size_write, }; -static void -trace_insert_enum_map(struct trace_enum_map **start, struct trace_enum_map **stop) +static void trace_insert_enum_map(struct trace_enum_map **start, int len) { struct trace_enum_map **map; - int len = stop - start; if (len <= 0) return; @@ -6561,9 +6559,48 @@ extern struct trace_enum_map *__stop_ftrace_enum_maps[]; static void __init trace_enum_init(void) { - trace_insert_enum_map(__start_ftrace_enum_maps, __stop_ftrace_enum_maps); + int len; + + len = __stop_ftrace_enum_maps - __start_ftrace_enum_maps; + trace_insert_enum_map(__start_ftrace_enum_maps, len); +} + +#ifdef CONFIG_MODULES +static void trace_module_add_enums(struct module *mod) +{ + if (!mod->num_trace_enums) + return; + + /* + * Modules with bad taint do not have events created, do + * not bother with enums either. + */ + if (trace_module_has_bad_taint(mod)) + return; + + trace_insert_enum_map(mod->trace_enums, mod->num_trace_enums); +} + +static int trace_module_notify(struct notifier_block *self, + unsigned long val, void *data) +{ + struct module *mod = data; + + switch (val) { + case MODULE_STATE_COMING: + trace_module_add_enums(mod); + break; + } + + return 0; } +static struct notifier_block trace_module_nb = { + .notifier_call = trace_module_notify, + .priority = 0, +}; +#endif + static __init int tracer_init_debugfs(void) { struct dentry *d_tracer; @@ -6590,6 +6627,10 @@ static __init int tracer_init_debugfs(void) trace_enum_init(); +#ifdef CONFIG_MODULES + register_module_notifier(&trace_module_nb); +#endif + #ifdef CONFIG_DYNAMIC_FTRACE trace_create_file("dyn_ftrace_total_info", 0444, d_tracer, &ftrace_update_tot_cnt, &tracing_dyn_info_fops); diff --git a/kernel/trace/trace_events.c b/kernel/trace/trace_events.c index fc58c50fbf01..a576bbe75577 100644 --- a/kernel/trace/trace_events.c +++ b/kernel/trace/trace_events.c @@ -2034,7 +2034,7 @@ static int trace_module_notify(struct notifier_block *self, static struct notifier_block trace_module_nb = { .notifier_call = trace_module_notify, - .priority = 0, + .priority = 1, /* higher than trace.c module notify */ }; #endif /* CONFIG_MODULES */ |