perf evlist: Add evlist__{en/dis}able_non_dummy()
authorAdrian Hunter <adrian.hunter@intel.com>
Wed, 24 Aug 2022 07:28:13 +0000 (10:28 +0300)
committerArnaldo Carvalho de Melo <acme@redhat.com>
Tue, 4 Oct 2022 11:55:19 +0000 (08:55 -0300)
Dummy events are used to provide sideband information like MMAP events that
are always needed even when main events are disabled. Add functions that
take that into account.

Signed-off-by: Adrian Hunter <adrian.hunter@intel.com>
Acked-by: Ian Rogers <irogers@google.com>
Cc: Alexey Bayduraev <alexey.v.bayduraev@linux.intel.com>
Cc: Andi Kleen <ak@linux.intel.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Namhyung Kim <namhyung@kernel.org>
Link: https://lore.kernel.org/r/20220824072814.16422-5-adrian.hunter@intel.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
tools/perf/util/evlist.c
tools/perf/util/evlist.h

index 4c5e6e9..3cfe730 100644 (file)
@@ -480,7 +480,7 @@ static int evlist__is_enabled(struct evlist *evlist)
        return false;
 }
 
-static void __evlist__disable(struct evlist *evlist, char *evsel_name)
+static void __evlist__disable(struct evlist *evlist, char *evsel_name, bool excl_dummy)
 {
        struct evsel *pos;
        struct evlist_cpu_iterator evlist_cpu_itr;
@@ -502,6 +502,8 @@ static void __evlist__disable(struct evlist *evlist, char *evsel_name)
                                continue;
                        if (pos->disabled || !evsel__is_group_leader(pos) || !pos->core.fd)
                                continue;
+                       if (excl_dummy && evsel__is_dummy_event(pos))
+                               continue;
                        if (pos->immediate)
                                has_imm = true;
                        if (pos->immediate != imm)
@@ -518,6 +520,8 @@ static void __evlist__disable(struct evlist *evlist, char *evsel_name)
                        continue;
                if (!evsel__is_group_leader(pos) || !pos->core.fd)
                        continue;
+               if (excl_dummy && evsel__is_dummy_event(pos))
+                       continue;
                pos->disabled = true;
        }
 
@@ -533,15 +537,20 @@ static void __evlist__disable(struct evlist *evlist, char *evsel_name)
 
 void evlist__disable(struct evlist *evlist)
 {
-       __evlist__disable(evlist, NULL);
+       __evlist__disable(evlist, NULL, false);
+}
+
+void evlist__disable_non_dummy(struct evlist *evlist)
+{
+       __evlist__disable(evlist, NULL, true);
 }
 
 void evlist__disable_evsel(struct evlist *evlist, char *evsel_name)
 {
-       __evlist__disable(evlist, evsel_name);
+       __evlist__disable(evlist, evsel_name, false);
 }
 
-static void __evlist__enable(struct evlist *evlist, char *evsel_name)
+static void __evlist__enable(struct evlist *evlist, char *evsel_name, bool excl_dummy)
 {
        struct evsel *pos;
        struct evlist_cpu_iterator evlist_cpu_itr;
@@ -560,6 +569,8 @@ static void __evlist__enable(struct evlist *evlist, char *evsel_name)
                        continue;
                if (!evsel__is_group_leader(pos) || !pos->core.fd)
                        continue;
+               if (excl_dummy && evsel__is_dummy_event(pos))
+                       continue;
                evsel__enable_cpu(pos, evlist_cpu_itr.cpu_map_idx);
        }
        affinity__cleanup(affinity);
@@ -568,6 +579,8 @@ static void __evlist__enable(struct evlist *evlist, char *evsel_name)
                        continue;
                if (!evsel__is_group_leader(pos) || !pos->core.fd)
                        continue;
+               if (excl_dummy && evsel__is_dummy_event(pos))
+                       continue;
                pos->disabled = false;
        }
 
@@ -581,12 +594,17 @@ static void __evlist__enable(struct evlist *evlist, char *evsel_name)
 
 void evlist__enable(struct evlist *evlist)
 {
-       __evlist__enable(evlist, NULL);
+       __evlist__enable(evlist, NULL, false);
+}
+
+void evlist__enable_non_dummy(struct evlist *evlist)
+{
+       __evlist__enable(evlist, NULL, true);
 }
 
 void evlist__enable_evsel(struct evlist *evlist, char *evsel_name)
 {
-       __evlist__enable(evlist, evsel_name);
+       __evlist__enable(evlist, evsel_name, false);
 }
 
 void evlist__toggle_enable(struct evlist *evlist)
index 3a46458..3a84744 100644 (file)
@@ -205,6 +205,8 @@ void evlist__enable(struct evlist *evlist);
 void evlist__toggle_enable(struct evlist *evlist);
 void evlist__disable_evsel(struct evlist *evlist, char *evsel_name);
 void evlist__enable_evsel(struct evlist *evlist, char *evsel_name);
+void evlist__disable_non_dummy(struct evlist *evlist);
+void evlist__enable_non_dummy(struct evlist *evlist);
 
 void evlist__set_selected(struct evlist *evlist, struct evsel *evsel);