Message ID | 20230517145803.559429-19-irogers@google.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | PMU refactoring and improvements | expand |
On 2023-05-17 10:57 a.m., Ian Rogers wrote: > Find the PMU and then the event off of it. > > Signed-off-by: Ian Rogers <irogers@google.com> Reviewed-by: Kan Liang <kan.liang@linux.intel.com> Thanks, Kan > --- > tools/perf/arch/x86/util/mem-events.c | 14 +++++++------- > 1 file changed, 7 insertions(+), 7 deletions(-) > > diff --git a/tools/perf/arch/x86/util/mem-events.c b/tools/perf/arch/x86/util/mem-events.c > index f683ac702247..02d65e446f46 100644 > --- a/tools/perf/arch/x86/util/mem-events.c > +++ b/tools/perf/arch/x86/util/mem-events.c > @@ -55,13 +55,13 @@ struct perf_mem_event *perf_mem_events__ptr(int i) > > bool is_mem_loads_aux_event(struct evsel *leader) > { > - if (perf_pmu__find("cpu")) { > - if (!pmu_have_event("cpu", "mem-loads-aux")) > - return false; > - } else if (perf_pmu__find("cpu_core")) { > - if (!pmu_have_event("cpu_core", "mem-loads-aux")) > - return false; > - } > + struct perf_pmu *pmu = perf_pmu__find("cpu"); > + > + if (!pmu) > + pmu = perf_pmu__find("cpu_core"); > + > + if (pmu && !pmu_have_event(pmu->name, "mem-loads-aux")) > + return false; > > return leader->core.attr.config == MEM_LOADS_AUX; > }
diff --git a/tools/perf/arch/x86/util/mem-events.c b/tools/perf/arch/x86/util/mem-events.c index f683ac702247..02d65e446f46 100644 --- a/tools/perf/arch/x86/util/mem-events.c +++ b/tools/perf/arch/x86/util/mem-events.c @@ -55,13 +55,13 @@ struct perf_mem_event *perf_mem_events__ptr(int i) bool is_mem_loads_aux_event(struct evsel *leader) { - if (perf_pmu__find("cpu")) { - if (!pmu_have_event("cpu", "mem-loads-aux")) - return false; - } else if (perf_pmu__find("cpu_core")) { - if (!pmu_have_event("cpu_core", "mem-loads-aux")) - return false; - } + struct perf_pmu *pmu = perf_pmu__find("cpu"); + + if (!pmu) + pmu = perf_pmu__find("cpu_core"); + + if (pmu && !pmu_have_event(pmu->name, "mem-loads-aux")) + return false; return leader->core.attr.config == MEM_LOADS_AUX; }
Find the PMU and then the event off of it. Signed-off-by: Ian Rogers <irogers@google.com> --- tools/perf/arch/x86/util/mem-events.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-)