提交 3673b8e4 编写于 作者: S Steven Rostedt (Red Hat) 提交者: Steven Rostedt

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.auAcked-by: NRusty Russell <rusty@rustcorp.com.au>
Reviewed-by: NMasami Hiramatsu <masami.hiramatsu.pt@hitachi.com>
Tested-by: NMasami Hiramatsu <masami.hiramatsu.pt@hitachi.com>
Signed-off-by: NSteven Rostedt <rostedt@goodmis.org>
上级 0c564a53
...@@ -338,6 +338,8 @@ struct module { ...@@ -338,6 +338,8 @@ struct module {
#ifdef CONFIG_EVENT_TRACING #ifdef CONFIG_EVENT_TRACING
struct ftrace_event_call **trace_events; struct ftrace_event_call **trace_events;
unsigned int num_trace_events; unsigned int num_trace_events;
struct trace_enum_map **trace_enums;
unsigned int num_trace_enums;
#endif #endif
#ifdef CONFIG_FTRACE_MCOUNT_RECORD #ifdef CONFIG_FTRACE_MCOUNT_RECORD
unsigned int num_ftrace_callsites; unsigned int num_ftrace_callsites;
......
...@@ -2753,6 +2753,9 @@ static int find_module_sections(struct module *mod, struct load_info *info) ...@@ -2753,6 +2753,9 @@ static int find_module_sections(struct module *mod, struct load_info *info)
mod->trace_events = section_objs(info, "_ftrace_events", mod->trace_events = section_objs(info, "_ftrace_events",
sizeof(*mod->trace_events), sizeof(*mod->trace_events),
&mod->num_trace_events); &mod->num_trace_events);
mod->trace_enums = section_objs(info, "_ftrace_enum_map",
sizeof(*mod->trace_enums),
&mod->num_trace_enums);
#endif #endif
#ifdef CONFIG_TRACING #ifdef CONFIG_TRACING
mod->trace_bprintk_fmt_start = section_objs(info, "__trace_printk_fmt", mod->trace_bprintk_fmt_start = section_objs(info, "__trace_printk_fmt",
......
...@@ -3908,11 +3908,9 @@ static const struct file_operations tracing_saved_cmdlines_size_fops = { ...@@ -3908,11 +3908,9 @@ static const struct file_operations tracing_saved_cmdlines_size_fops = {
.write = tracing_saved_cmdlines_size_write, .write = tracing_saved_cmdlines_size_write,
}; };
static void static void trace_insert_enum_map(struct trace_enum_map **start, int len)
trace_insert_enum_map(struct trace_enum_map **start, struct trace_enum_map **stop)
{ {
struct trace_enum_map **map; struct trace_enum_map **map;
int len = stop - start;
if (len <= 0) if (len <= 0)
return; return;
...@@ -6561,9 +6559,48 @@ extern struct trace_enum_map *__stop_ftrace_enum_maps[]; ...@@ -6561,9 +6559,48 @@ extern struct trace_enum_map *__stop_ftrace_enum_maps[];
static void __init trace_enum_init(void) 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) static __init int tracer_init_debugfs(void)
{ {
struct dentry *d_tracer; struct dentry *d_tracer;
...@@ -6590,6 +6627,10 @@ static __init int tracer_init_debugfs(void) ...@@ -6590,6 +6627,10 @@ static __init int tracer_init_debugfs(void)
trace_enum_init(); trace_enum_init();
#ifdef CONFIG_MODULES
register_module_notifier(&trace_module_nb);
#endif
#ifdef CONFIG_DYNAMIC_FTRACE #ifdef CONFIG_DYNAMIC_FTRACE
trace_create_file("dyn_ftrace_total_info", 0444, d_tracer, trace_create_file("dyn_ftrace_total_info", 0444, d_tracer,
&ftrace_update_tot_cnt, &tracing_dyn_info_fops); &ftrace_update_tot_cnt, &tracing_dyn_info_fops);
......
...@@ -2034,7 +2034,7 @@ static int trace_module_notify(struct notifier_block *self, ...@@ -2034,7 +2034,7 @@ static int trace_module_notify(struct notifier_block *self,
static struct notifier_block trace_module_nb = { static struct notifier_block trace_module_nb = {
.notifier_call = trace_module_notify, .notifier_call = trace_module_notify,
.priority = 0, .priority = 1, /* higher than trace.c module notify */
}; };
#endif /* CONFIG_MODULES */ #endif /* CONFIG_MODULES */
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册