Skip to content

Commit 1233616

Browse files
captain5050acmel
authored andcommitted
perf evsel: Modify group pmu name for software events
If we have a group of {cycles,faults} then we need the faults software event to appear to be on the same PMU as cycles so that we don't split the group in parse_events__sort_events_and_fix_groups. This case is relatively easy as cycles is the leader and will have a PMU name. In the reverse case, {faults,cycles} we still need faults to appear to have the PMU name of cycles but the old behavior is just to return "cpu". For hybrid this fails as cycles will be on "cpu_core" or "cpu_atom", causing faults to be split into a different group. Change the behavior for software events so that the whole group is searched for the named PMU. Signed-off-by: Ian Rogers <irogers@google.com> Tested-by: Adrian Hunter <adrian.hunter@intel.com> Cc: Ahmad Yasin <ahmad.yasin@intel.com> Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com> Cc: Andi Kleen <ak@linux.intel.com> Cc: Athira Rajeev <atrajeev@linux.vnet.ibm.com> Cc: Caleb Biggers <caleb.biggers@intel.com> Cc: Edward Baker <edward.baker@intel.com> Cc: Florian Fischer <florian.fischer@muhq.space> Cc: Ingo Molnar <mingo@redhat.com> Cc: James Clark <james.clark@arm.com> Cc: Jiri Olsa <jolsa@kernel.org> Cc: John Garry <john.g.garry@oracle.com> Cc: Kajol Jain <kjain@linux.ibm.com> Cc: Kan Liang <kan.liang@linux.intel.com> Cc: Kang Minchul <tegongkang@gmail.com> Cc: Leo Yan <leo.yan@linaro.org> Cc: Mark Rutland <mark.rutland@arm.com> Cc: Namhyung Kim <namhyung@kernel.org> Cc: Perry Taylor <perry.taylor@intel.com> Cc: Peter Zijlstra <peterz@infradead.org> Cc: Ravi Bangoria <ravi.bangoria@amd.com> Cc: Rob Herring <robh@kernel.org> Cc: Samantha Alt <samantha.alt@intel.com> Cc: Stephane Eranian <eranian@google.com> Cc: Sumanth Korikkar <sumanthk@linux.ibm.com> Cc: Suzuki Poulouse <suzuki.poulose@arm.com> Cc: Thomas Richter <tmricht@linux.ibm.com> Cc: Tiezhu Yang <yangtiezhu@loongson.cn> Cc: Weilin Wang <weilin.wang@intel.com> Cc: Xing Zhengjun <zhengjun.xing@linux.intel.com> Cc: Yang Jihong <yangjihong1@huawei.com> Link: https://lore.kernel.org/r/20230502223851.2234828-20-irogers@google.com Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
1 parent 34e8289 commit 1233616

1 file changed

Lines changed: 9 additions & 6 deletions

File tree

tools/perf/util/evsel.c

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -829,23 +829,26 @@ bool evsel__name_is(struct evsel *evsel, const char *name)
829829

830830
const char *evsel__group_pmu_name(const struct evsel *evsel)
831831
{
832-
const struct evsel *leader;
832+
struct evsel *leader, *pos;
833833

834834
/* If the pmu_name is set use it. pmu_name isn't set for CPU and software events. */
835835
if (evsel->pmu_name)
836836
return evsel->pmu_name;
837837
/*
838838
* Software events may be in a group with other uncore PMU events. Use
839-
* the pmu_name of the group leader to avoid breaking the software event
840-
* out of the group.
839+
* the pmu_name of the first non-software event to avoid breaking the
840+
* software event out of the group.
841841
*
842842
* Aux event leaders, like intel_pt, expect a group with events from
843843
* other PMUs, so substitute the AUX event's PMU in this case.
844844
*/
845845
leader = evsel__leader(evsel);
846-
if ((evsel->core.attr.type == PERF_TYPE_SOFTWARE || evsel__is_aux_event(leader)) &&
847-
leader->pmu_name) {
848-
return leader->pmu_name;
846+
if (evsel->core.attr.type == PERF_TYPE_SOFTWARE || evsel__is_aux_event(leader)) {
847+
/* Starting with the leader, find the first event with a named PMU. */
848+
for_each_group_evsel(pos, leader) {
849+
if (pos->pmu_name)
850+
return pos->pmu_name;
851+
}
849852
}
850853

851854
return "cpu";

0 commit comments

Comments
 (0)