diff options
author | Steven Rostedt (VMware) <rostedt@goodmis.org> | 2018-02-22 23:26:11 -0500 |
---|---|---|
committer | Steven Rostedt (VMware) <rostedt@goodmis.org> | 2018-03-10 16:06:07 -0500 |
commit | 404a3add43c9c42fe48b61341badfcb9cca165cc (patch) | |
tree | 60e153bd6280148adfb394b2deaac9ddb4ab3a03 /kernel | |
parent | c7399708b3cd9004205923c3d139dcc7d067a8a4 (diff) | |
download | linux-404a3add43c9c42fe48b61341badfcb9cca165cc.tar.gz linux-404a3add43c9c42fe48b61341badfcb9cca165cc.tar.bz2 linux-404a3add43c9c42fe48b61341badfcb9cca165cc.zip |
tracing: Only add filter list when needed
replace_system_preds() creates a filter list to free even when it doesn't
really need to have it. Only save filters that require synchronize_sched()
in the filter list to free. This will allow the code to be updated a bit
easier in the future.
Signed-off-by: Steven Rostedt (VMware) <rostedt@goodmis.org>
Diffstat (limited to 'kernel')
-rw-r--r-- | kernel/trace/trace_events_filter.c | 27 |
1 files changed, 14 insertions, 13 deletions
diff --git a/kernel/trace/trace_events_filter.c b/kernel/trace/trace_events_filter.c index 3d60bbeb2ef1..2401b7c727a3 100644 --- a/kernel/trace/trace_events_filter.c +++ b/kernel/trace/trace_events_filter.c @@ -1769,6 +1769,7 @@ static int replace_system_preds(struct trace_subsystem_dir *dir, { struct trace_event_file *file; struct filter_list *filter_item; + struct event_filter *filter = NULL; struct filter_list *tmp; LIST_HEAD(filter_list); bool fail = true; @@ -1790,7 +1791,6 @@ static int replace_system_preds(struct trace_subsystem_dir *dir, } list_for_each_entry(file, &tr->events, list) { - struct event_filter *filter; if (file->system != dir) continue; @@ -1798,16 +1798,9 @@ static int replace_system_preds(struct trace_subsystem_dir *dir, if (event_no_set_filter_flag(file)) continue; - filter_item = kzalloc(sizeof(*filter_item), GFP_KERNEL); - if (!filter_item) - goto fail_mem; - - list_add_tail(&filter_item->list, &filter_list); - - filter_item->filter = kzalloc(sizeof(*filter), GFP_KERNEL); - if (!filter_item->filter) + filter = kzalloc(sizeof(*filter), GFP_KERNEL); + if (!filter) goto fail_mem; - filter = filter_item->filter; /* Can only fail on no memory */ err = replace_filter_string(filter, filter_string); @@ -1821,13 +1814,20 @@ static int replace_system_preds(struct trace_subsystem_dir *dir, append_filter_err(ps, filter); } else event_set_filtered_flag(file); + + + filter_item = kzalloc(sizeof(*filter_item), GFP_KERNEL); + if (!filter_item) + goto fail_mem; + + list_add_tail(&filter_item->list, &filter_list); /* * Regardless of if this returned an error, we still * replace the filter for the call. */ - filter = event_filter(file); - event_set_filter(file, filter_item->filter); - filter_item->filter = filter; + filter_item->filter = event_filter(file); + event_set_filter(file, filter); + filter = NULL; fail = false; } @@ -1856,6 +1856,7 @@ static int replace_system_preds(struct trace_subsystem_dir *dir, parse_error(ps, FILT_ERR_BAD_SUBSYS_FILTER, 0); return -EINVAL; fail_mem: + kfree(filter); /* If any call succeeded, we still need to sync */ if (!fail) synchronize_sched(); |