Skip to content

Commit

Permalink
tracing: Add trace_array parameter to create_event_filter()
Browse files Browse the repository at this point in the history
Pass in the trace_array that represents the instance the filter being
changed is in to create_event_filter(). This will allow for error messages
that happen when writing to the filter can be displayed in the proper
instance "error_log" file.

Note, for calls to create_filter() (that was also modified to support
create_event_filter()), that changes filters that do not exist in a instance
(for perf for example), NULL may be passed in, which means that there will
not be any message to log for that filter.

Reviewed-by: Masami Hiramatsu <[email protected]>
Reviewed-by: Tom Zanussi <[email protected]>
Tested-by: Tom Zanussi <[email protected]>
Signed-off-by: Steven Rostedt (VMware) <[email protected]>
  • Loading branch information
rostedt committed Apr 8, 2019
1 parent ab105a4 commit 1e144d7
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 13 deletions.
3 changes: 2 additions & 1 deletion kernel/trace/trace.h
Original file line number Diff line number Diff line change
Expand Up @@ -1553,7 +1553,8 @@ extern int apply_subsystem_event_filter(struct trace_subsystem_dir *dir,
extern void print_subsystem_event_filter(struct event_subsystem *system,
struct trace_seq *s);
extern int filter_assign_type(const char *type);
extern int create_event_filter(struct trace_event_call *call,
extern int create_event_filter(struct trace_array *tr,
struct trace_event_call *call,
char *filter_str, bool set_str,
struct event_filter **filterp);
extern void free_event_filter(struct event_filter *filter);
Expand Down
25 changes: 14 additions & 11 deletions kernel/trace/trace_events_filter.c
Original file line number Diff line number Diff line change
Expand Up @@ -920,7 +920,8 @@ static void remove_filter_string(struct event_filter *filter)
filter->filter_string = NULL;
}

static void append_filter_err(struct filter_parse_error *pe,
static void append_filter_err(struct trace_array *tr,
struct filter_parse_error *pe,
struct event_filter *filter)
{
struct trace_seq *s;
Expand Down Expand Up @@ -1607,7 +1608,7 @@ static int process_system_preds(struct trace_subsystem_dir *dir,
if (err) {
filter_disable(file);
parse_error(pe, FILT_ERR_BAD_SUBSYS_FILTER, 0);
append_filter_err(pe, filter);
append_filter_err(tr, pe, filter);
} else
event_set_filtered_flag(file);

Expand Down Expand Up @@ -1719,7 +1720,8 @@ static void create_filter_finish(struct filter_parse_error *pe)
* information if @set_str is %true and the caller is responsible for
* freeing it.
*/
static int create_filter(struct trace_event_call *call,
static int create_filter(struct trace_array *tr,
struct trace_event_call *call,
char *filter_string, bool set_str,
struct event_filter **filterp)
{
Expand All @@ -1736,17 +1738,18 @@ static int create_filter(struct trace_event_call *call,

err = process_preds(call, filter_string, *filterp, pe);
if (err && set_str)
append_filter_err(pe, *filterp);
append_filter_err(tr, pe, *filterp);
create_filter_finish(pe);

return err;
}

int create_event_filter(struct trace_event_call *call,
int create_event_filter(struct trace_array *tr,
struct trace_event_call *call,
char *filter_str, bool set_str,
struct event_filter **filterp)
{
return create_filter(call, filter_str, set_str, filterp);
return create_filter(tr, call, filter_str, set_str, filterp);
}

/**
Expand All @@ -1773,7 +1776,7 @@ static int create_system_filter(struct trace_subsystem_dir *dir,
kfree((*filterp)->filter_string);
(*filterp)->filter_string = NULL;
} else {
append_filter_err(pe, *filterp);
append_filter_err(tr, pe, *filterp);
}
}
create_filter_finish(pe);
Expand Down Expand Up @@ -1804,7 +1807,7 @@ int apply_event_filter(struct trace_event_file *file, char *filter_string)
return 0;
}

err = create_filter(call, filter_string, true, &filter);
err = create_filter(file->tr, call, filter_string, true, &filter);

/*
* Always swap the call filter with the new filter
Expand Down Expand Up @@ -2060,7 +2063,7 @@ int ftrace_profile_set_filter(struct perf_event *event, int event_id,
if (event->filter)
goto out_unlock;

err = create_filter(call, filter_str, false, &filter);
err = create_filter(NULL, call, filter_str, false, &filter);
if (err)
goto free_filter;

Expand Down Expand Up @@ -2209,8 +2212,8 @@ static __init int ftrace_test_event_filter(void)
struct test_filter_data_t *d = &test_filter_data[i];
int err;

err = create_filter(&event_ftrace_test_filter, d->filter,
false, &filter);
err = create_filter(NULL, &event_ftrace_test_filter,
d->filter, false, &filter);
if (err) {
printk(KERN_INFO
"Failed to get filter for '%s', err %d\n",
Expand Down
3 changes: 2 additions & 1 deletion kernel/trace/trace_events_trigger.c
Original file line number Diff line number Diff line change
Expand Up @@ -731,7 +731,8 @@ int set_trigger_filter(char *filter_str,
goto out;

/* The filter is for the 'trigger' event, not the triggered event */
ret = create_event_filter(file->event_call, filter_str, false, &filter);
ret = create_event_filter(file->tr, file->event_call,
filter_str, false, &filter);
/*
* If create_event_filter() fails, filter still needs to be freed.
* Which the calling code will do with data->filter.
Expand Down

0 comments on commit 1e144d7

Please sign in to comment.