perf evlist: Disable 'immediate' events last
authorAdrian Hunter <adrian.hunter@intel.com>
Tue, 12 May 2020 12:19:17 +0000 (15:19 +0300)
committerArnaldo Carvalho de Melo <acme@redhat.com>
Thu, 28 May 2020 13:03:28 +0000 (10:03 -0300)
Events marked as 'immediate' are started before other events to ensure
that there is context at the start of the main tracing events. The same
is true at the end of tracing, so disable 'immediate' events after other
events.

Signed-off-by: Adrian Hunter <adrian.hunter@intel.com>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: Borislav Petkov <bp@alien8.de>
Cc: H. Peter Anvin <hpa@zytor.com>
Cc: Jiri Olsa <jolsa@redhat.com>
Cc: Leo Yan <leo.yan@linaro.org>
Cc: Mark Rutland <mark.rutland@arm.com>
Cc: Masami Hiramatsu <mhiramat@kernel.org>
Cc: Mathieu Poirier <mathieu.poirier@linaro.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Steven Rostedt (VMware) <rostedt@goodmis.org>
Cc: x86@kernel.org
Link: http://lore.kernel.org/lkml/20200512121922.8997-11-adrian.hunter@intel.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
tools/perf/util/evlist.c

index 2a9de64917009d4bc1de554ab277dc3552d01ae9..173b4f0e0e6e6158c77ea1dcf15e43ddcfae9a8f 100644 (file)
@@ -380,22 +380,33 @@ void evlist__disable(struct evlist *evlist)
 {
        struct evsel *pos;
        struct affinity affinity;
-       int cpu, i;
+       int cpu, i, imm = 0;
+       bool has_imm = false;
 
        if (affinity__setup(&affinity) < 0)
                return;
 
-       evlist__for_each_cpu(evlist, i, cpu) {
-               affinity__set(&affinity, cpu);
-
-               evlist__for_each_entry(evlist, pos) {
-                       if (evsel__cpu_iter_skip(pos, cpu))
-                               continue;
-                       if (pos->disabled || !evsel__is_group_leader(pos) || !pos->core.fd)
-                               continue;
-                       evsel__disable_cpu(pos, pos->cpu_iter - 1);
+       /* Disable 'immediate' events last */
+       for (imm = 0; imm <= 1; imm++) {
+               evlist__for_each_cpu(evlist, i, cpu) {
+                       affinity__set(&affinity, cpu);
+
+                       evlist__for_each_entry(evlist, pos) {
+                               if (evsel__cpu_iter_skip(pos, cpu))
+                                       continue;
+                               if (pos->disabled || !evsel__is_group_leader(pos) || !pos->core.fd)
+                                       continue;
+                               if (pos->immediate)
+                                       has_imm = true;
+                               if (pos->immediate != imm)
+                                       continue;
+                               evsel__disable_cpu(pos, pos->cpu_iter - 1);
+                       }
                }
+               if (!has_imm)
+                       break;
        }
+
        affinity__cleanup(&affinity);
        evlist__for_each_entry(evlist, pos) {
                if (!evsel__is_group_leader(pos) || !pos->core.fd)