aboutsummaryrefslogtreecommitdiffstats
path: root/kernel
diff options
context:
space:
mode:
authorSteven Rostedt (Red Hat) <rostedt@goodmis.org>2015-03-25 15:44:21 -0400
committerSteven Rostedt <rostedt@goodmis.org>2015-04-08 09:39:57 -0400
commit3673b8e4ce7237160fa31ee8d7e94a4d5a9976a1 (patch)
treedbbc779ed3883db285d243d85452a7e603120d85 /kernel
parent0c564a538aa934ad15b2145aaf8b64f3feb0be63 (diff)
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')
-rw-r--r--kernel/module.c3
-rw-r--r--kernel/trace/trace.c49
-rw-r--r--kernel/trace/trace_events.c2
3 files changed, 49 insertions, 5 deletions
diff --git a/kernel/module.c b/kernel/module.c
index b3d634ed06c9..d8f8ab271c2b 100644
--- a/kernel/module.c
+++ b/kernel/module.c
@@ -2753,6 +2753,9 @@ static int find_module_sections(struct module *mod, struct load_info *info)
2753 mod->trace_events = section_objs(info, "_ftrace_events", 2753 mod->trace_events = section_objs(info, "_ftrace_events",
2754 sizeof(*mod->trace_events), 2754 sizeof(*mod->trace_events),
2755 &mod->num_trace_events); 2755 &mod->num_trace_events);
2756 mod->trace_enums = section_objs(info, "_ftrace_enum_map",
2757 sizeof(*mod->trace_enums),
2758 &mod->num_trace_enums);
2756#endif 2759#endif
2757#ifdef CONFIG_TRACING 2760#ifdef CONFIG_TRACING
2758 mod->trace_bprintk_fmt_start = section_objs(info, "__trace_printk_fmt", 2761 mod->trace_bprintk_fmt_start = section_objs(info, "__trace_printk_fmt",
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 = {
3908 .write = tracing_saved_cmdlines_size_write, 3908 .write = tracing_saved_cmdlines_size_write,
3909}; 3909};
3910 3910
3911static void 3911static void trace_insert_enum_map(struct trace_enum_map **start, int len)
3912trace_insert_enum_map(struct trace_enum_map **start, struct trace_enum_map **stop)
3913{ 3912{
3914 struct trace_enum_map **map; 3913 struct trace_enum_map **map;
3915 int len = stop - start;
3916 3914
3917 if (len <= 0) 3915 if (len <= 0)
3918 return; 3916 return;
@@ -6561,9 +6559,48 @@ extern struct trace_enum_map *__stop_ftrace_enum_maps[];
6561 6559
6562static void __init trace_enum_init(void) 6560static void __init trace_enum_init(void)
6563{ 6561{
6564 trace_insert_enum_map(__start_ftrace_enum_maps, __stop_ftrace_enum_maps); 6562 int len;
6563
6564 len = __stop_ftrace_enum_maps - __start_ftrace_enum_maps;
6565 trace_insert_enum_map(__start_ftrace_enum_maps, len);
6566}
6567
6568#ifdef CONFIG_MODULES
6569static void trace_module_add_enums(struct module *mod)
6570{
6571 if (!mod->num_trace_enums)
6572 return;
6573
6574 /*
6575 * Modules with bad taint do not have events created, do
6576 * not bother with enums either.
6577 */
6578 if (trace_module_has_bad_taint(mod))
6579 return;
6580
6581 trace_insert_enum_map(mod->trace_enums, mod->num_trace_enums);
6582}
6583
6584static int trace_module_notify(struct notifier_block *self,
6585 unsigned long val, void *data)
6586{
6587 struct module *mod = data;
6588
6589 switch (val) {
6590 case MODULE_STATE_COMING:
6591 trace_module_add_enums(mod);
6592 break;
6593 }
6594
6595 return 0;
6565} 6596}
6566 6597
6598static struct notifier_block trace_module_nb = {
6599 .notifier_call = trace_module_notify,
6600 .priority = 0,
6601};
6602#endif
6603
6567static __init int tracer_init_debugfs(void) 6604static __init int tracer_init_debugfs(void)
6568{ 6605{
6569 struct dentry *d_tracer; 6606 struct dentry *d_tracer;
@@ -6590,6 +6627,10 @@ static __init int tracer_init_debugfs(void)
6590 6627
6591 trace_enum_init(); 6628 trace_enum_init();
6592 6629
6630#ifdef CONFIG_MODULES
6631 register_module_notifier(&trace_module_nb);
6632#endif
6633
6593#ifdef CONFIG_DYNAMIC_FTRACE 6634#ifdef CONFIG_DYNAMIC_FTRACE
6594 trace_create_file("dyn_ftrace_total_info", 0444, d_tracer, 6635 trace_create_file("dyn_ftrace_total_info", 0444, d_tracer,
6595 &ftrace_update_tot_cnt, &tracing_dyn_info_fops); 6636 &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,
2034 2034
2035static struct notifier_block trace_module_nb = { 2035static struct notifier_block trace_module_nb = {
2036 .notifier_call = trace_module_notify, 2036 .notifier_call = trace_module_notify,
2037 .priority = 0, 2037 .priority = 1, /* higher than trace.c module notify */
2038}; 2038};
2039#endif /* CONFIG_MODULES */ 2039#endif /* CONFIG_MODULES */
2040 2040