perf script: Move filtering before scripting
authorAdrian Hunter <adrian.hunter@intel.com>
Mon, 21 Jun 2021 15:05:05 +0000 (18:05 +0300)
committerArnaldo Carvalho de Melo <acme@redhat.com>
Tue, 22 Jun 2021 18:18:15 +0000 (15:18 -0300)
To make it possible to use filtering with scripts, move filtering before
scripting.

Signed-off-by: Adrian Hunter <adrian.hunter@intel.com>
Cc: Andi Kleen <ak@linux.intel.com>
Cc: Jiri Olsa <jolsa@redhat.com>
Cc: Kan Liang <kan.liang@linux.intel.com>
Cc: Leo Yan <leo.yan@linaro.org>
Cc: Mark Rutland <mark.rutland@arm.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Link: http://lore.kernel.org/lkml/20210621150514.32159-3-adrian.hunter@intel.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
tools/perf/builtin-script.c

index 08a2b5d..ff7b438 100644 (file)
@@ -1984,12 +1984,6 @@ static void process_event(struct perf_script *script,
        if (output[type].fields == 0)
                return;
 
-       if (!show_event(sample, evsel, thread, al))
-               return;
-
-       if (evswitch__discard(&script->evswitch, evsel))
-               return;
-
        ++es->samples;
 
        perf_sample__fprintf_start(script, sample, thread, evsel,
@@ -2203,6 +2197,12 @@ static int process_sample_event(struct perf_tool *tool,
        if (al.filtered)
                goto out_put;
 
+       if (!show_event(sample, evsel, al.thread, &al))
+               goto out_put;
+
+       if (evswitch__discard(&scr->evswitch, evsel))
+               goto out_put;
+
        if (scripting_ops) {
                struct addr_location *addr_al_ptr = NULL;
                struct addr_location addr_al;