Skip to content

Commit

Permalink
Merge tag 'trace-3.17-2' of git://git.kernel.org/pub/scm/linux/kernel…
Browse files Browse the repository at this point in the history
…/git/rostedt/linux-trace

Pull tracing filter cleanups from Steven Rostedt:
 "Oleg Nesterov did several clean ups with the tracing filter code.  As
  he found some small bugs that went into 3.16, and these changes were
  based on that, I had to apply his changes to a separate branch than my
  main development branch.

  This was based on work that was already pulled into 3.16, and is a
  separate pull request to keep from having local merges in my pull
  request"

* tag 'trace-3.17-2' of git://git.kernel.org/pub/scm/linux/kernel/git/rostedt/linux-trace:
  tracing: Kill "filter_string" arg of replace_preds()
  tracing: Change apply_subsystem_event_filter() paths to check file->system == dir
  tracing: Kill ftrace_event_call->files
  tracing/uprobes: Kill the dead TRACE_EVENT_FL_USE_CALL_FILTER logic
  tracing: Kill call_filter_disable()
  tracing: Kill destroy_call_preds()
  tracing: Kill destroy_preds() and destroy_file_preds()
  • Loading branch information
Linus Torvalds committed Aug 4, 2014
2 parents b8c0aa4 + 6355d54 commit c9b88e9
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 64 deletions.
3 changes: 0 additions & 3 deletions include/linux/ftrace_event.h
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,6 @@ struct ftrace_event_call {
struct trace_event event;
const char *print_fmt;
struct event_filter *filter;
struct list_head *files;
void *mod;
void *data;
/*
Expand Down Expand Up @@ -404,8 +403,6 @@ enum event_trigger_type {
ETT_EVENT_ENABLE = (1 << 3),
};

extern void destroy_preds(struct ftrace_event_file *file);
extern void destroy_call_preds(struct ftrace_event_call *call);
extern int filter_match_preds(struct event_filter *filter, void *rec);

extern int filter_check_discard(struct ftrace_event_file *file, void *rec,
Expand Down
4 changes: 2 additions & 2 deletions kernel/trace/trace_events.c
Original file line number Diff line number Diff line change
Expand Up @@ -1621,7 +1621,6 @@ static void event_remove(struct ftrace_event_call *call)
if (file->event_call != call)
continue;
ftrace_event_enable_disable(file, 0);
destroy_preds(file);
/*
* The do_for_each_event_file() is
* a double loop. After finding the call for this
Expand Down Expand Up @@ -1748,7 +1747,8 @@ static void __trace_remove_event_call(struct ftrace_event_call *call)
{
event_remove(call);
trace_destroy_fields(call);
destroy_call_preds(call);
free_event_filter(call->filter);
call->filter = NULL;
}

static int probe_remove_event_call(struct ftrace_event_call *call)
Expand Down
73 changes: 16 additions & 57 deletions kernel/trace/trace_events_filter.c
Original file line number Diff line number Diff line change
Expand Up @@ -774,17 +774,12 @@ static void __free_preds(struct event_filter *filter)
filter->n_preds = 0;
}

static void call_filter_disable(struct ftrace_event_call *call)
{
call->flags &= ~TRACE_EVENT_FL_FILTERED;
}

static void filter_disable(struct ftrace_event_file *file)
{
struct ftrace_event_call *call = file->event_call;

if (call->flags & TRACE_EVENT_FL_USE_CALL_FILTER)
call_filter_disable(call);
call->flags &= ~TRACE_EVENT_FL_FILTERED;
else
file->flags &= ~FTRACE_EVENT_FL_FILTERED;
}
Expand All @@ -804,32 +799,6 @@ void free_event_filter(struct event_filter *filter)
__free_filter(filter);
}

void destroy_call_preds(struct ftrace_event_call *call)
{
__free_filter(call->filter);
call->filter = NULL;
}

static void destroy_file_preds(struct ftrace_event_file *file)
{
__free_filter(file->filter);
file->filter = NULL;
}

/*
* Called when destroying the ftrace_event_file.
* The file is being freed, so we do not need to worry about
* the file being currently used. This is for module code removing
* the tracepoints from within it.
*/
void destroy_preds(struct ftrace_event_file *file)
{
if (file->event_call->flags & TRACE_EVENT_FL_USE_CALL_FILTER)
destroy_call_preds(file->event_call);
else
destroy_file_preds(file);
}

static struct event_filter *__alloc_filter(void)
{
struct event_filter *filter;
Expand Down Expand Up @@ -873,17 +842,14 @@ static inline void __remove_filter(struct ftrace_event_file *file)
remove_filter_string(file->filter);
}

static void filter_free_subsystem_preds(struct event_subsystem *system,
static void filter_free_subsystem_preds(struct ftrace_subsystem_dir *dir,
struct trace_array *tr)
{
struct ftrace_event_file *file;
struct ftrace_event_call *call;

list_for_each_entry(file, &tr->events, list) {
call = file->event_call;
if (strcmp(call->class->system, system->name) != 0)
if (file->system != dir)
continue;

__remove_filter(file);
}
}
Expand All @@ -901,15 +867,13 @@ static inline void __free_subsystem_filter(struct ftrace_event_file *file)
}
}

static void filter_free_subsystem_filters(struct event_subsystem *system,
static void filter_free_subsystem_filters(struct ftrace_subsystem_dir *dir,
struct trace_array *tr)
{
struct ftrace_event_file *file;
struct ftrace_event_call *call;

list_for_each_entry(file, &tr->events, list) {
call = file->event_call;
if (strcmp(call->class->system, system->name) != 0)
if (file->system != dir)
continue;
__free_subsystem_filter(file);
}
Expand Down Expand Up @@ -1582,7 +1546,6 @@ static int fold_pred_tree(struct event_filter *filter,
static int replace_preds(struct ftrace_event_call *call,
struct event_filter *filter,
struct filter_parse_state *ps,
char *filter_string,
bool dry_run)
{
char *operand1 = NULL, *operand2 = NULL;
Expand Down Expand Up @@ -1755,29 +1718,27 @@ struct filter_list {
struct event_filter *filter;
};

static int replace_system_preds(struct event_subsystem *system,
static int replace_system_preds(struct ftrace_subsystem_dir *dir,
struct trace_array *tr,
struct filter_parse_state *ps,
char *filter_string)
{
struct ftrace_event_file *file;
struct ftrace_event_call *call;
struct filter_list *filter_item;
struct filter_list *tmp;
LIST_HEAD(filter_list);
bool fail = true;
int err;

list_for_each_entry(file, &tr->events, list) {
call = file->event_call;
if (strcmp(call->class->system, system->name) != 0)
if (file->system != dir)
continue;

/*
* Try to see if the filter can be applied
* (filter arg is ignored on dry_run)
*/
err = replace_preds(call, NULL, ps, filter_string, true);
err = replace_preds(file->event_call, NULL, ps, true);
if (err)
event_set_no_set_filter_flag(file);
else
Expand All @@ -1787,9 +1748,7 @@ static int replace_system_preds(struct event_subsystem *system,
list_for_each_entry(file, &tr->events, list) {
struct event_filter *filter;

call = file->event_call;

if (strcmp(call->class->system, system->name) != 0)
if (file->system != dir)
continue;

if (event_no_set_filter_flag(file))
Expand All @@ -1811,7 +1770,7 @@ static int replace_system_preds(struct event_subsystem *system,
if (err)
goto fail_mem;

err = replace_preds(call, filter, ps, filter_string, false);
err = replace_preds(file->event_call, filter, ps, false);
if (err) {
filter_disable(file);
parse_error(ps, FILT_ERR_BAD_SUBSYS_FILTER, 0);
Expand Down Expand Up @@ -1933,7 +1892,7 @@ static int create_filter(struct ftrace_event_call *call,

err = create_filter_start(filter_str, set_str, &ps, &filter);
if (!err) {
err = replace_preds(call, filter, ps, filter_str, false);
err = replace_preds(call, filter, ps, false);
if (err && set_str)
append_filter_err(ps, filter);
}
Expand All @@ -1959,7 +1918,7 @@ int create_event_filter(struct ftrace_event_call *call,
* Identical to create_filter() except that it creates a subsystem filter
* and always remembers @filter_str.
*/
static int create_system_filter(struct event_subsystem *system,
static int create_system_filter(struct ftrace_subsystem_dir *dir,
struct trace_array *tr,
char *filter_str, struct event_filter **filterp)
{
Expand All @@ -1969,7 +1928,7 @@ static int create_system_filter(struct event_subsystem *system,

err = create_filter_start(filter_str, true, &ps, &filter);
if (!err) {
err = replace_system_preds(system, tr, ps, filter_str);
err = replace_system_preds(dir, tr, ps, filter_str);
if (!err) {
/* System filters just show a default message */
kfree(filter->filter_string);
Expand Down Expand Up @@ -2053,18 +2012,18 @@ int apply_subsystem_event_filter(struct ftrace_subsystem_dir *dir,
}

if (!strcmp(strstrip(filter_string), "0")) {
filter_free_subsystem_preds(system, tr);
filter_free_subsystem_preds(dir, tr);
remove_filter_string(system->filter);
filter = system->filter;
system->filter = NULL;
/* Ensure all filters are no longer used */
synchronize_sched();
filter_free_subsystem_filters(system, tr);
filter_free_subsystem_filters(dir, tr);
__free_filter(filter);
goto out_unlock;
}

err = create_system_filter(system, tr, filter_string, &filter);
err = create_system_filter(dir, tr, filter_string, &filter);
if (filter) {
/*
* No event actually uses the system filter
Expand Down
3 changes: 1 addition & 2 deletions kernel/trace/trace_uprobe.c
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,6 @@ alloc_trace_uprobe(const char *group, const char *event, int nargs, bool is_ret)
if (is_ret)
tu->consumer.ret_handler = uretprobe_dispatcher;
init_trace_uprobe_filter(&tu->filter);
tu->tp.call.flags |= TRACE_EVENT_FL_USE_CALL_FILTER;
return tu;

error:
Expand Down Expand Up @@ -1292,7 +1291,7 @@ static int register_uprobe_event(struct trace_uprobe *tu)
kfree(call->print_fmt);
return -ENODEV;
}
call->flags = 0;

call->class->reg = trace_uprobe_register;
call->data = tu;
ret = trace_add_event_call(call);
Expand Down

0 comments on commit c9b88e9

Please sign in to comment.