perf mem: Disable 'mem-loads-aux' group before reporting
authorJin Yao <yao.jin@linux.intel.com>
Thu, 27 May 2021 00:16:09 +0000 (08:16 +0800)
committerArnaldo Carvalho de Melo <acme@redhat.com>
Tue, 1 Jun 2021 14:06:01 +0000 (11:06 -0300)
For some platforms, such as Alderlake, the 'mem-loads' event is required
to use together with 'mem-loads-aux' within a group and 'mem-loads-aux'
must be the group leader. Now we disable this group before reporting
because 'mem-loads-aux' is just an auxiliary event. It doesn't carry
any valid memory load result. If we show the 'mem-loads-aux' +
'mem-loads' as a group in report, it needs many of changes but they
are totally unnecessary.

Signed-off-by: Jin Yao <yao.jin@linux.intel.com>
Acked-by: Jiri Olsa <jolsa@redhat.com>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: Andi Kleen <ak@linux.intel.com>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: Kan Liang <kan.liang@intel.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Link: https://lore.kernel.org/r/20210527001610.10553-8-yao.jin@linux.intel.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
tools/perf/builtin-report.c
tools/perf/util/evlist.c
tools/perf/util/evlist.h

index 36f9ccf..bc5c393 100644 (file)
@@ -934,6 +934,8 @@ static int __cmd_report(struct report *rep)
                return ret;
        }
 
+       evlist__check_mem_load_aux(session->evlist);
+
        if (rep->stats_mode)
                return stats_print(rep);
 
index 6ea3e67..6ba9664 100644 (file)
@@ -2161,3 +2161,28 @@ int evlist__scnprintf_evsels(struct evlist *evlist, size_t size, char *bf)
 
        return printed;
 }
+
+void evlist__check_mem_load_aux(struct evlist *evlist)
+{
+       struct evsel *leader, *evsel, *pos;
+
+       /*
+        * For some platforms, the 'mem-loads' event is required to use
+        * together with 'mem-loads-aux' within a group and 'mem-loads-aux'
+        * must be the group leader. Now we disable this group before reporting
+        * because 'mem-loads-aux' is just an auxiliary event. It doesn't carry
+        * any valid memory load information.
+        */
+       evlist__for_each_entry(evlist, evsel) {
+               leader = evsel->leader;
+               if (leader == evsel)
+                       continue;
+
+               if (leader->name && strstr(leader->name, "mem-loads-aux")) {
+                       for_each_group_evsel(pos, leader) {
+                               pos->leader = pos;
+                               pos->core.nr_members = 0;
+                       }
+               }
+       }
+}
index a8b97b5..2073cfa 100644 (file)
@@ -367,4 +367,5 @@ int evlist__ctlfd_ack(struct evlist *evlist);
 struct evsel *evlist__find_evsel(struct evlist *evlist, int idx);
 
 int evlist__scnprintf_evsels(struct evlist *evlist, size_t size, char *bf);
+void evlist__check_mem_load_aux(struct evlist *evlist);
 #endif /* __PERF_EVLIST_H */