]> asedeno.scripts.mit.edu Git - linux.git/commitdiff
perf evlist: Introduce append_tp_filter() method
authorArnaldo Carvalho de Melo <acme@redhat.com>
Mon, 7 Oct 2019 19:52:17 +0000 (16:52 -0300)
committerArnaldo Carvalho de Melo <acme@redhat.com>
Wed, 9 Oct 2019 14:23:52 +0000 (11:23 -0300)
Will be used by 'perf trace' to support 'perf trace --filter', we need
to append to any pre-existing filter.

When parse_filter() gets invoked to process --filter, it'll set the
filter to that specified on the command line, later on, when we filter
out 'perf trace' own pid to avoid an event feedback loop, we need to
preserve the command line filter put in place by parse_filter().

Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Luis Cláudio Gonçalves <lclaudio@redhat.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Link: https://lkml.kernel.org/n/tip-h9rot08qmxlnfmte0holt68x@git.kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
tools/perf/util/evlist.c
tools/perf/util/evlist.h

index c1b46080426b5a43853f1f088c9acee7595a66f3..1650d242a1c8a5a111c8a55f08c14821c937d612 100644 (file)
@@ -1068,6 +1068,26 @@ int perf_evlist__set_tp_filter(struct evlist *evlist, const char *filter)
        return err;
 }
 
+int perf_evlist__append_tp_filter(struct evlist *evlist, const char *filter)
+{
+       struct evsel *evsel;
+       int err = 0;
+
+       if (filter == NULL)
+               return -1;
+
+       evlist__for_each_entry(evlist, evsel) {
+               if (evsel->core.attr.type != PERF_TYPE_TRACEPOINT)
+                       continue;
+
+               err = perf_evsel__append_tp_filter(evsel, filter);
+               if (err)
+                       break;
+       }
+
+       return err;
+}
+
 static char *asprintf__tp_filter_pids(size_t npids, pid_t *pids)
 {
        char *filter;
index 00eab943584765d3deafe7c9bf4913b4dbb83189..c58fd1908bfc66555a8dd16b0769501fc7182c29 100644 (file)
@@ -140,6 +140,8 @@ int perf_evlist__set_tp_filter(struct evlist *evlist, const char *filter);
 int perf_evlist__set_tp_filter_pid(struct evlist *evlist, pid_t pid);
 int perf_evlist__set_tp_filter_pids(struct evlist *evlist, size_t npids, pid_t *pids);
 
+int perf_evlist__append_tp_filter(struct evlist *evlist, const char *filter);
+
 struct evsel *
 perf_evlist__find_tracepoint_by_id(struct evlist *evlist, int id);