Commit a59fd602 authored by Steven Rostedt's avatar Steven Rostedt Committed by Steven Rostedt

tracing/events: convert event call sites to use a link list

Impact: makes it possible to define events in modules

The events are created by reading down the section that they are linked
in by the macros. But this is not scalable to modules. This patch converts
the manipulations to use a global link list, and on boot up it adds
the items in the section to the list.

This change will allow modules to add their tracing events to the list as
well.

Note, this change alone does not permit modules to use the TRACE_EVENT macros,
but the change is needed for them to eventually do so.
Signed-off-by: default avatarSteven Rostedt <rostedt@goodmis.org>
parent f42c85e7
...@@ -83,6 +83,7 @@ void trace_current_buffer_discard_commit(struct ring_buffer_event *event); ...@@ -83,6 +83,7 @@ void trace_current_buffer_discard_commit(struct ring_buffer_event *event);
void tracing_record_cmdline(struct task_struct *tsk); void tracing_record_cmdline(struct task_struct *tsk);
struct ftrace_event_call { struct ftrace_event_call {
struct list_head list;
char *name; char *name;
char *system; char *system;
struct dentry *dir; struct dentry *dir;
......
...@@ -739,11 +739,6 @@ struct event_subsystem { ...@@ -739,11 +739,6 @@ struct event_subsystem {
struct filter_pred **preds; struct filter_pred **preds;
}; };
#define events_for_each(event) \
for (event = __start_ftrace_events; \
(unsigned long)event < (unsigned long)__stop_ftrace_events; \
event++)
struct filter_pred; struct filter_pred;
typedef int (*filter_pred_fn_t) (struct filter_pred *pred, void *event); typedef int (*filter_pred_fn_t) (struct filter_pred *pred, void *event);
...@@ -785,13 +780,7 @@ filter_check_discard(struct ftrace_event_call *call, void *rec, ...@@ -785,13 +780,7 @@ filter_check_discard(struct ftrace_event_call *call, void *rec,
return 0; return 0;
} }
extern struct ftrace_event_call __start_ftrace_events[]; extern struct list_head ftrace_events;
extern struct ftrace_event_call __stop_ftrace_events[];
#define for_each_event(event) \
for (event = __start_ftrace_events; \
(unsigned long)event < (unsigned long)__stop_ftrace_events; \
event++)
extern const char *__start___trace_bprintk_fmt[]; extern const char *__start___trace_bprintk_fmt[];
extern const char *__stop___trace_bprintk_fmt[]; extern const char *__stop___trace_bprintk_fmt[];
......
...@@ -11,7 +11,7 @@ int ftrace_profile_enable(int event_id) ...@@ -11,7 +11,7 @@ int ftrace_profile_enable(int event_id)
{ {
struct ftrace_event_call *event; struct ftrace_event_call *event;
for_each_event(event) { list_for_each_entry(event, &ftrace_events, list) {
if (event->id == event_id) if (event->id == event_id)
return event->profile_enable(event); return event->profile_enable(event);
} }
...@@ -23,7 +23,7 @@ void ftrace_profile_disable(int event_id) ...@@ -23,7 +23,7 @@ void ftrace_profile_disable(int event_id)
{ {
struct ftrace_event_call *event; struct ftrace_event_call *event;
for_each_event(event) { list_for_each_entry(event, &ftrace_events, list) {
if (event->id == event_id) if (event->id == event_id)
return event->profile_disable(event); return event->profile_disable(event);
} }
......
...@@ -19,6 +19,8 @@ ...@@ -19,6 +19,8 @@
static DEFINE_MUTEX(event_mutex); static DEFINE_MUTEX(event_mutex);
LIST_HEAD(ftrace_events);
int trace_define_field(struct ftrace_event_call *call, char *type, int trace_define_field(struct ftrace_event_call *call, char *type,
char *name, int offset, int size) char *name, int offset, int size)
{ {
...@@ -54,16 +56,14 @@ err: ...@@ -54,16 +56,14 @@ err:
static void ftrace_clear_events(void) static void ftrace_clear_events(void)
{ {
struct ftrace_event_call *call = (void *)__start_ftrace_events; struct ftrace_event_call *call;
while ((unsigned long)call < (unsigned long)__stop_ftrace_events) { list_for_each_entry(call, &ftrace_events, list) {
if (call->enabled) { if (call->enabled) {
call->enabled = 0; call->enabled = 0;
call->unregfunc(); call->unregfunc();
} }
call++;
} }
} }
...@@ -89,7 +89,7 @@ static void ftrace_event_enable_disable(struct ftrace_event_call *call, ...@@ -89,7 +89,7 @@ static void ftrace_event_enable_disable(struct ftrace_event_call *call,
static int ftrace_set_clr_event(char *buf, int set) static int ftrace_set_clr_event(char *buf, int set)
{ {
struct ftrace_event_call *call = __start_ftrace_events; struct ftrace_event_call *call;
char *event = NULL, *sub = NULL, *match; char *event = NULL, *sub = NULL, *match;
int ret = -EINVAL; int ret = -EINVAL;
...@@ -118,7 +118,7 @@ static int ftrace_set_clr_event(char *buf, int set) ...@@ -118,7 +118,7 @@ static int ftrace_set_clr_event(char *buf, int set)
} }
mutex_lock(&event_mutex); mutex_lock(&event_mutex);
for_each_event(call) { list_for_each_entry(call, &ftrace_events, list) {
if (!call->name || !call->regfunc) if (!call->name || !call->regfunc)
continue; continue;
...@@ -224,15 +224,17 @@ ftrace_event_write(struct file *file, const char __user *ubuf, ...@@ -224,15 +224,17 @@ ftrace_event_write(struct file *file, const char __user *ubuf,
static void * static void *
t_next(struct seq_file *m, void *v, loff_t *pos) t_next(struct seq_file *m, void *v, loff_t *pos)
{ {
struct ftrace_event_call *call = m->private; struct list_head *list = m->private;
struct ftrace_event_call *next = call; struct ftrace_event_call *call;
(*pos)++; (*pos)++;
for (;;) { for (;;) {
if ((unsigned long)call >= (unsigned long)__stop_ftrace_events) if (list == &ftrace_events)
return NULL; return NULL;
call = list_entry(list, struct ftrace_event_call, list);
/* /*
* The ftrace subsystem is for showing formats only. * The ftrace subsystem is for showing formats only.
* They can not be enabled or disabled via the event files. * They can not be enabled or disabled via the event files.
...@@ -240,11 +242,10 @@ t_next(struct seq_file *m, void *v, loff_t *pos) ...@@ -240,11 +242,10 @@ t_next(struct seq_file *m, void *v, loff_t *pos)
if (call->regfunc) if (call->regfunc)
break; break;
call++; list = list->next;
next = call;
} }
m->private = ++next; m->private = list->next;
return call; return call;
} }
...@@ -257,22 +258,23 @@ static void *t_start(struct seq_file *m, loff_t *pos) ...@@ -257,22 +258,23 @@ static void *t_start(struct seq_file *m, loff_t *pos)
static void * static void *
s_next(struct seq_file *m, void *v, loff_t *pos) s_next(struct seq_file *m, void *v, loff_t *pos)
{ {
struct ftrace_event_call *call = m->private; struct list_head *list = m->private;
struct ftrace_event_call *next; struct ftrace_event_call *call;
(*pos)++; (*pos)++;
retry: retry:
if ((unsigned long)call >= (unsigned long)__stop_ftrace_events) if (list == &ftrace_events)
return NULL; return NULL;
call = list_entry(list, struct ftrace_event_call, list);
if (!call->enabled) { if (!call->enabled) {
call++; list = list->next;
goto retry; goto retry;
} }
next = call; m->private = list->next;
m->private = ++next;
return call; return call;
} }
...@@ -312,7 +314,7 @@ ftrace_event_seq_open(struct inode *inode, struct file *file) ...@@ -312,7 +314,7 @@ ftrace_event_seq_open(struct inode *inode, struct file *file)
if (!ret) { if (!ret) {
struct seq_file *m = file->private_data; struct seq_file *m = file->private_data;
m->private = __start_ftrace_events; m->private = ftrace_events.next;
} }
return ret; return ret;
} }
...@@ -797,9 +799,17 @@ event_create_dir(struct ftrace_event_call *call, struct dentry *d_events) ...@@ -797,9 +799,17 @@ event_create_dir(struct ftrace_event_call *call, struct dentry *d_events)
return 0; return 0;
} }
extern struct ftrace_event_call __start_ftrace_events[];
extern struct ftrace_event_call __stop_ftrace_events[];
#define for_each_event(event) \
for (event = __start_ftrace_events; \
(unsigned long)event < (unsigned long)__stop_ftrace_events; \
event++)
static __init int event_trace_init(void) static __init int event_trace_init(void)
{ {
struct ftrace_event_call *call = __start_ftrace_events; struct ftrace_event_call *call;
struct dentry *d_tracer; struct dentry *d_tracer;
struct dentry *entry; struct dentry *entry;
struct dentry *d_events; struct dentry *d_events;
...@@ -830,6 +840,7 @@ static __init int event_trace_init(void) ...@@ -830,6 +840,7 @@ static __init int event_trace_init(void)
/* The linker may leave blanks */ /* The linker may leave blanks */
if (!call->name) if (!call->name)
continue; continue;
list_add(&call->list, &ftrace_events);
event_create_dir(call, d_events); event_create_dir(call, d_events);
} }
......
...@@ -223,7 +223,7 @@ oom: ...@@ -223,7 +223,7 @@ oom:
void filter_free_subsystem_preds(struct event_subsystem *system) void filter_free_subsystem_preds(struct event_subsystem *system)
{ {
struct ftrace_event_call *call = __start_ftrace_events; struct ftrace_event_call *call;
int i; int i;
if (system->n_preds) { if (system->n_preds) {
...@@ -234,7 +234,7 @@ void filter_free_subsystem_preds(struct event_subsystem *system) ...@@ -234,7 +234,7 @@ void filter_free_subsystem_preds(struct event_subsystem *system)
system->n_preds = 0; system->n_preds = 0;
} }
events_for_each(call) { list_for_each_entry(call, &ftrace_events, list) {
if (!call->define_fields) if (!call->define_fields)
continue; continue;
...@@ -320,7 +320,7 @@ int filter_add_pred(struct ftrace_event_call *call, struct filter_pred *pred) ...@@ -320,7 +320,7 @@ int filter_add_pred(struct ftrace_event_call *call, struct filter_pred *pred)
int filter_add_subsystem_pred(struct event_subsystem *system, int filter_add_subsystem_pred(struct event_subsystem *system,
struct filter_pred *pred) struct filter_pred *pred)
{ {
struct ftrace_event_call *call = __start_ftrace_events; struct ftrace_event_call *call;
if (system->n_preds && !pred->compound) if (system->n_preds && !pred->compound)
filter_free_subsystem_preds(system); filter_free_subsystem_preds(system);
...@@ -337,7 +337,7 @@ int filter_add_subsystem_pred(struct event_subsystem *system, ...@@ -337,7 +337,7 @@ int filter_add_subsystem_pred(struct event_subsystem *system,
system->preds[system->n_preds] = pred; system->preds[system->n_preds] = pred;
events_for_each(call) { list_for_each_entry(call, &ftrace_events, list) {
int err; int err;
if (!call->define_fields) if (!call->define_fields)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment