Skip to content

Commit 49aa295

Browse files
Steven Rostedtrostedt
authored andcommitted
tracing: Add boiler plate for subsystem filter
The system filter can be used to set multiple event filters that exist within the system. But currently it displays the last filter written that does not necessarily correspond to the filters within the system. The system filter itself is not used to filter any events. The system filter is just a means to set filters of the events within it. Because this causes an ambiguous state when the system filter reads a filter string but the events within the system have different strings it is best to just show a boiler plate: ### global filter ### # Use this to set filters for multiple events. # Only events with the given fields will be affected. # If no events are modified, an error message will be displayed here. If an error occurs while writing to the system filter, the system filter will replace the boiler plate with the error message as it currently does. Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
1 parent ed0449a commit 49aa295

1 file changed

Lines changed: 19 additions & 7 deletions

File tree

‎kernel/trace/trace_events_filter.c‎

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,12 @@
2727
#include "trace.h"
2828
#include "trace_output.h"
2929

30+
#define DEFAULT_SYS_FILTER_MESSAGE \
31+
"### global filter ###\n" \
32+
"# Use this to set filters for multiple events.\n" \
33+
"# Only events with the given fields will be affected.\n" \
34+
"# If no events are modified, an error message will be displayed here"
35+
3036
enum filter_op_ids
3137
{
3238
OP_OR,
@@ -646,7 +652,7 @@ void print_subsystem_event_filter(struct event_subsystem *system,
646652
if (filter && filter->filter_string)
647653
trace_seq_printf(s, "%s\n", filter->filter_string);
648654
else
649-
trace_seq_printf(s, "none\n");
655+
trace_seq_printf(s, DEFAULT_SYS_FILTER_MESSAGE "\n");
650656
mutex_unlock(&event_mutex);
651657
}
652658

@@ -1838,7 +1844,10 @@ int apply_subsystem_event_filter(struct event_subsystem *system,
18381844
if (!filter)
18391845
goto out;
18401846

1841-
replace_filter_string(filter, filter_string);
1847+
/* System filters just show a default message */
1848+
kfree(filter->filter_string);
1849+
filter->filter_string = NULL;
1850+
18421851
/*
18431852
* No event actually uses the system filter
18441853
* we can free it without synchronize_sched().
@@ -1848,14 +1857,12 @@ int apply_subsystem_event_filter(struct event_subsystem *system,
18481857

18491858
parse_init(ps, filter_ops, filter_string);
18501859
err = filter_parse(ps);
1851-
if (err) {
1852-
append_filter_err(ps, system->filter);
1853-
goto out;
1854-
}
1860+
if (err)
1861+
goto err_filter;
18551862

18561863
err = replace_system_preds(system, ps, filter_string);
18571864
if (err)
1858-
append_filter_err(ps, system->filter);
1865+
goto err_filter;
18591866

18601867
out:
18611868
filter_opstack_clear(ps);
@@ -1865,6 +1872,11 @@ int apply_subsystem_event_filter(struct event_subsystem *system,
18651872
mutex_unlock(&event_mutex);
18661873

18671874
return err;
1875+
1876+
err_filter:
1877+
replace_filter_string(filter, filter_string);
1878+
append_filter_err(ps, system->filter);
1879+
goto out;
18681880
}
18691881

18701882
#ifdef CONFIG_PERF_EVENTS

0 commit comments

Comments
 (0)