Message ID | 20231207192338.400336-6-kan.liang@linux.intel.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | Clean up perf mem | expand |
On Thu, Dec 07, 2023 at 11:23:38AM -0800, kan.liang@linux.intel.com wrote: > From: Kan Liang <kan.liang@linux.intel.com> > > The aux_event can be retrieved from the perf_pmu now. Implement a > generic support. > > Reviewed-by: Ian Rogers <irogers@google.com> > Tested-by: Ravi Bangoria <ravi.bangoria@amd.com> > Signed-off-by: Kan Liang <kan.liang@linux.intel.com> > --- > tools/perf/arch/x86/util/mem-events.c | 23 ++++------------------- > tools/perf/util/mem-events.c | 14 ++++++++++++-- > 2 files changed, 16 insertions(+), 21 deletions(-) > > diff --git a/tools/perf/arch/x86/util/mem-events.c b/tools/perf/arch/x86/util/mem-events.c > index b776d849fc64..62df03e91c7e 100644 > --- a/tools/perf/arch/x86/util/mem-events.c > +++ b/tools/perf/arch/x86/util/mem-events.c > @@ -1,11 +1,9 @@ > // SPDX-License-Identifier: GPL-2.0 > -#include "util/pmu.h" > -#include "util/pmus.h" > -#include "util/env.h" > -#include "map_symbol.h" > -#include "mem-events.h" > #include "linux/string.h" > -#include "env.h" > +#include "util/map_symbol.h" > +#include "util/mem-events.h" > +#include "mem-events.h" > + > > #define MEM_LOADS_AUX 0x8203 > > @@ -28,16 +26,3 @@ struct perf_mem_event perf_mem_events_amd[PERF_MEM_EVENTS__MAX] = { > E(NULL, NULL, NULL, false, 0), > E("mem-ldst", "%s//", NULL, false, 0), > }; > - > -bool is_mem_loads_aux_event(struct evsel *leader) > -{ > - struct perf_pmu *pmu = perf_pmus__find("cpu"); > - > - if (!pmu) > - pmu = perf_pmus__find("cpu_core"); > - > - if (pmu && !perf_pmu__have_event(pmu, "mem-loads-aux")) > - return false; > - > - return leader->core.attr.config == MEM_LOADS_AUX; > -} > diff --git a/tools/perf/util/mem-events.c b/tools/perf/util/mem-events.c > index 0d174f161034..d418320e52e3 100644 > --- a/tools/perf/util/mem-events.c > +++ b/tools/perf/util/mem-events.c > @@ -103,9 +103,19 @@ static const char *perf_pmu__mem_events_name(int i, struct perf_pmu *pmu) > return NULL; > } > > -__weak bool is_mem_loads_aux_event(struct evsel *leader __maybe_unused) > +bool is_mem_loads_aux_event(struct evsel *leader) > { > - return false; > + struct perf_pmu *pmu = leader->pmu; > + struct perf_mem_event *e; > + > + if (!pmu || !pmu->mem_events) > + return false; > + > + e = &pmu->mem_events[PERF_MEM_EVENTS__LOAD]; > + if (!e->aux_event) > + return false; > + > + return leader->core.attr.config == e->aux_event; > } I am wandering if we need to set the field 'aux_event' for Arm SPE. So a quesiton maybe is not relevant with this patch actually, we can see is_mem_loads_aux_event() is invoked in the file util/record.c: static struct evsel *evsel__read_sampler(struct evsel *evsel, struct evlist *evlist) { struct evsel *leader = evsel__leader(evsel); if (evsel__is_aux_event(leader) || arch_topdown_sample_read(leader) || is_mem_loads_aux_event(leader)) { ... } return leader; } Has evsel__is_aux_event() covered the memory load aux event? If it's, then is_mem_loads_aux_event() is not needed anymore. Thanks, Leo
On 2023-12-09 1:27 a.m., Leo Yan wrote: > On Thu, Dec 07, 2023 at 11:23:38AM -0800, kan.liang@linux.intel.com wrote: >> From: Kan Liang <kan.liang@linux.intel.com> >> >> The aux_event can be retrieved from the perf_pmu now. Implement a >> generic support. >> >> Reviewed-by: Ian Rogers <irogers@google.com> >> Tested-by: Ravi Bangoria <ravi.bangoria@amd.com> >> Signed-off-by: Kan Liang <kan.liang@linux.intel.com> >> --- >> tools/perf/arch/x86/util/mem-events.c | 23 ++++------------------- >> tools/perf/util/mem-events.c | 14 ++++++++++++-- >> 2 files changed, 16 insertions(+), 21 deletions(-) >> >> diff --git a/tools/perf/arch/x86/util/mem-events.c b/tools/perf/arch/x86/util/mem-events.c >> index b776d849fc64..62df03e91c7e 100644 >> --- a/tools/perf/arch/x86/util/mem-events.c >> +++ b/tools/perf/arch/x86/util/mem-events.c >> @@ -1,11 +1,9 @@ >> // SPDX-License-Identifier: GPL-2.0 >> -#include "util/pmu.h" >> -#include "util/pmus.h" >> -#include "util/env.h" >> -#include "map_symbol.h" >> -#include "mem-events.h" >> #include "linux/string.h" >> -#include "env.h" >> +#include "util/map_symbol.h" >> +#include "util/mem-events.h" >> +#include "mem-events.h" >> + >> >> #define MEM_LOADS_AUX 0x8203 >> >> @@ -28,16 +26,3 @@ struct perf_mem_event perf_mem_events_amd[PERF_MEM_EVENTS__MAX] = { >> E(NULL, NULL, NULL, false, 0), >> E("mem-ldst", "%s//", NULL, false, 0), >> }; >> - >> -bool is_mem_loads_aux_event(struct evsel *leader) >> -{ >> - struct perf_pmu *pmu = perf_pmus__find("cpu"); >> - >> - if (!pmu) >> - pmu = perf_pmus__find("cpu_core"); >> - >> - if (pmu && !perf_pmu__have_event(pmu, "mem-loads-aux")) >> - return false; >> - >> - return leader->core.attr.config == MEM_LOADS_AUX; >> -} >> diff --git a/tools/perf/util/mem-events.c b/tools/perf/util/mem-events.c >> index 0d174f161034..d418320e52e3 100644 >> --- a/tools/perf/util/mem-events.c >> +++ b/tools/perf/util/mem-events.c >> @@ -103,9 +103,19 @@ static const char *perf_pmu__mem_events_name(int i, struct perf_pmu *pmu) >> return NULL; >> } >> >> -__weak bool is_mem_loads_aux_event(struct evsel *leader __maybe_unused) >> +bool is_mem_loads_aux_event(struct evsel *leader) >> { >> - return false; >> + struct perf_pmu *pmu = leader->pmu; >> + struct perf_mem_event *e; >> + >> + if (!pmu || !pmu->mem_events) >> + return false; >> + >> + e = &pmu->mem_events[PERF_MEM_EVENTS__LOAD]; >> + if (!e->aux_event) >> + return false; >> + >> + return leader->core.attr.config == e->aux_event; >> } > > I am wandering if we need to set the field 'aux_event' for Arm SPE. > > So a quesiton maybe is not relevant with this patch actually, we can > see is_mem_loads_aux_event() is invoked in the file util/record.c: > > static struct evsel *evsel__read_sampler(struct evsel *evsel, struct evlist *evlist) > { > struct evsel *leader = evsel__leader(evsel); > > if (evsel__is_aux_event(leader) || arch_topdown_sample_read(leader) || > is_mem_loads_aux_event(leader)) { > ... > } > > return leader; > } > > Has evsel__is_aux_event() covered the memory load aux event? If it's, > then is_mem_loads_aux_event() is not needed anymore. They are two different things. The evsel__is_aux_event() should means an event requires AUX area, like intel_pt. While the aux event for the mem_loads event is an extra event which has to be scheduled together with the mem_loads event when sampling. It's only available for some Intel platforms, e.g., SPR. Thanks, Kan > > Thanks, > Leo
diff --git a/tools/perf/arch/x86/util/mem-events.c b/tools/perf/arch/x86/util/mem-events.c index b776d849fc64..62df03e91c7e 100644 --- a/tools/perf/arch/x86/util/mem-events.c +++ b/tools/perf/arch/x86/util/mem-events.c @@ -1,11 +1,9 @@ // SPDX-License-Identifier: GPL-2.0 -#include "util/pmu.h" -#include "util/pmus.h" -#include "util/env.h" -#include "map_symbol.h" -#include "mem-events.h" #include "linux/string.h" -#include "env.h" +#include "util/map_symbol.h" +#include "util/mem-events.h" +#include "mem-events.h" + #define MEM_LOADS_AUX 0x8203 @@ -28,16 +26,3 @@ struct perf_mem_event perf_mem_events_amd[PERF_MEM_EVENTS__MAX] = { E(NULL, NULL, NULL, false, 0), E("mem-ldst", "%s//", NULL, false, 0), }; - -bool is_mem_loads_aux_event(struct evsel *leader) -{ - struct perf_pmu *pmu = perf_pmus__find("cpu"); - - if (!pmu) - pmu = perf_pmus__find("cpu_core"); - - if (pmu && !perf_pmu__have_event(pmu, "mem-loads-aux")) - return false; - - return leader->core.attr.config == MEM_LOADS_AUX; -} diff --git a/tools/perf/util/mem-events.c b/tools/perf/util/mem-events.c index 0d174f161034..d418320e52e3 100644 --- a/tools/perf/util/mem-events.c +++ b/tools/perf/util/mem-events.c @@ -103,9 +103,19 @@ static const char *perf_pmu__mem_events_name(int i, struct perf_pmu *pmu) return NULL; } -__weak bool is_mem_loads_aux_event(struct evsel *leader __maybe_unused) +bool is_mem_loads_aux_event(struct evsel *leader) { - return false; + struct perf_pmu *pmu = leader->pmu; + struct perf_mem_event *e; + + if (!pmu || !pmu->mem_events) + return false; + + e = &pmu->mem_events[PERF_MEM_EVENTS__LOAD]; + if (!e->aux_event) + return false; + + return leader->core.attr.config == e->aux_event; } int perf_pmu__mem_events_parse(struct perf_pmu *pmu, const char *str)