Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 146094
b: refs/heads/master
c: 20c8928
h: refs/heads/master
v: v3
  • Loading branch information
Li Zefan authored and Ingo Molnar committed May 6, 2009
1 parent 662feb9 commit e360b0a
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 18 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 2df75e415709ad12862028916c772c1f377f6a7c
refs/heads/master: 20c8928abe70e204bd077ab6cfe23002d7788983
1 change: 1 addition & 0 deletions trunk/kernel/trace/trace.h
Original file line number Diff line number Diff line change
Expand Up @@ -825,6 +825,7 @@ static int filter_pred_##size(struct filter_pred *pred, void *event, \
return match; \
}

extern struct mutex event_mutex;
extern struct list_head ftrace_events;

extern const char *__start___trace_bprintk_fmt[];
Expand Down
19 changes: 14 additions & 5 deletions trunk/kernel/trace/trace_event_profile.c
Original file line number Diff line number Diff line change
Expand Up @@ -10,21 +10,30 @@
int ftrace_profile_enable(int event_id)
{
struct ftrace_event_call *event;
int ret = -EINVAL;

mutex_lock(&event_mutex);
list_for_each_entry(event, &ftrace_events, list) {
if (event->id == event_id)
return event->profile_enable(event);
if (event->id == event_id) {
ret = event->profile_enable(event);
break;
}
}
mutex_unlock(&event_mutex);

return -EINVAL;
return ret;
}

void ftrace_profile_disable(int event_id)
{
struct ftrace_event_call *event;

mutex_lock(&event_mutex);
list_for_each_entry(event, &ftrace_events, list) {
if (event->id == event_id)
return event->profile_disable(event);
if (event->id == event_id) {
event->profile_disable(event);
break;
}
}
mutex_unlock(&event_mutex);
}
20 changes: 11 additions & 9 deletions trunk/kernel/trace/trace_events.c
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@

#define TRACE_SYSTEM "TRACE_SYSTEM"

static DEFINE_MUTEX(event_mutex);
DEFINE_MUTEX(event_mutex);

LIST_HEAD(ftrace_events);

Expand Down Expand Up @@ -80,13 +80,15 @@ static void ftrace_clear_events(void)
{
struct ftrace_event_call *call;

mutex_lock(&event_mutex);
list_for_each_entry(call, &ftrace_events, list) {

if (call->enabled) {
call->enabled = 0;
call->unregfunc();
}
}
mutex_unlock(&event_mutex);
}

static void ftrace_event_enable_disable(struct ftrace_event_call *call,
Expand Down Expand Up @@ -274,6 +276,9 @@ t_next(struct seq_file *m, void *v, loff_t *pos)

static void *t_start(struct seq_file *m, loff_t *pos)
{
mutex_lock(&event_mutex);
if (*pos == 0)
m->private = ftrace_events.next;
return t_next(m, NULL, pos);
}

Expand Down Expand Up @@ -303,6 +308,9 @@ s_next(struct seq_file *m, void *v, loff_t *pos)

static void *s_start(struct seq_file *m, loff_t *pos)
{
mutex_lock(&event_mutex);
if (*pos == 0)
m->private = ftrace_events.next;
return s_next(m, NULL, pos);
}

Expand All @@ -319,26 +327,20 @@ static int t_show(struct seq_file *m, void *v)

static void t_stop(struct seq_file *m, void *p)
{
mutex_unlock(&event_mutex);
}

static int
ftrace_event_seq_open(struct inode *inode, struct file *file)
{
int ret;
const struct seq_operations *seq_ops;

if ((file->f_mode & FMODE_WRITE) &&
!(file->f_flags & O_APPEND))
ftrace_clear_events();

seq_ops = inode->i_private;
ret = seq_open(file, seq_ops);
if (!ret) {
struct seq_file *m = file->private_data;

m->private = ftrace_events.next;
}
return ret;
return seq_open(file, seq_ops);
}

static ssize_t
Expand Down
10 changes: 7 additions & 3 deletions trunk/kernel/trace/trace_events_filter.c
Original file line number Diff line number Diff line change
Expand Up @@ -408,6 +408,7 @@ static void filter_free_subsystem_preds(struct event_subsystem *system)
filter->n_preds = 0;
}

mutex_lock(&event_mutex);
list_for_each_entry(call, &ftrace_events, list) {
if (!call->define_fields)
continue;
Expand All @@ -417,6 +418,7 @@ static void filter_free_subsystem_preds(struct event_subsystem *system)
remove_filter_string(call->filter);
}
}
mutex_unlock(&event_mutex);
}

static int filter_add_pred_fn(struct filter_parse_state *ps,
Expand Down Expand Up @@ -567,6 +569,7 @@ static int filter_add_subsystem_pred(struct filter_parse_state *ps,
{
struct event_filter *filter = system->filter;
struct ftrace_event_call *call;
int err = 0;

if (!filter->preds) {
filter->preds = kzalloc(MAX_FILTER_PRED * sizeof(pred),
Expand All @@ -584,8 +587,8 @@ static int filter_add_subsystem_pred(struct filter_parse_state *ps,
filter->preds[filter->n_preds] = pred;
filter->n_preds++;

mutex_lock(&event_mutex);
list_for_each_entry(call, &ftrace_events, list) {
int err;

if (!call->define_fields)
continue;
Expand All @@ -597,12 +600,13 @@ static int filter_add_subsystem_pred(struct filter_parse_state *ps,
if (err) {
filter_free_subsystem_preds(system);
parse_error(ps, FILT_ERR_BAD_SUBSYS_FILTER, 0);
return err;
break;
}
replace_filter_string(call->filter, filter_string);
}
mutex_unlock(&event_mutex);

return 0;
return err;
}

static void parse_init(struct filter_parse_state *ps,
Expand Down

0 comments on commit e360b0a

Please sign in to comment.