diff mbox series

[5/6] perf mem: Clean up is_mem_loads_aux_event()

Message ID 20231206201324.184059-6-kan.liang@linux.intel.com (mailing list archive)
State New, archived
Headers show
Series Clean up perf mem | expand

Commit Message

Liang, Kan Dec. 6, 2023, 8:13 p.m. UTC
From: Kan Liang <kan.liang@linux.intel.com>

The aux_event can be retrieved from the perf_pmu now. Implement a
generic support.

Signed-off-by: Kan Liang <kan.liang@linux.intel.com>
---
 tools/perf/arch/x86/util/mem-events.c | 13 -------------
 tools/perf/util/mem-events.c          | 14 ++++++++++++--
 2 files changed, 12 insertions(+), 15 deletions(-)

Comments

Ian Rogers Dec. 6, 2023, 9:10 p.m. UTC | #1
On Wed, Dec 6, 2023 at 12:13 PM <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.
>
> Signed-off-by: Kan Liang <kan.liang@linux.intel.com>

Reviewed-by: Ian Rogers <irogers@google.com>

Thanks,
Ian

> ---
>  tools/perf/arch/x86/util/mem-events.c | 13 -------------
>  tools/perf/util/mem-events.c          | 14 ++++++++++++--
>  2 files changed, 12 insertions(+), 15 deletions(-)
>
> diff --git a/tools/perf/arch/x86/util/mem-events.c b/tools/perf/arch/x86/util/mem-events.c
> index b776d849fc64..71ffe16de751 100644
> --- a/tools/perf/arch/x86/util/mem-events.c
> +++ b/tools/perf/arch/x86/util/mem-events.c
> @@ -28,16 +28,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 9ea9e9a868c4..336d1109b3a5 100644
> --- a/tools/perf/util/mem-events.c
> +++ b/tools/perf/util/mem-events.c
> @@ -103,9 +103,19 @@ static const char *perf_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_mem_events__parse(struct perf_pmu *pmu, const char *str)
> --
> 2.35.1
>
diff mbox series

Patch

diff --git a/tools/perf/arch/x86/util/mem-events.c b/tools/perf/arch/x86/util/mem-events.c
index b776d849fc64..71ffe16de751 100644
--- a/tools/perf/arch/x86/util/mem-events.c
+++ b/tools/perf/arch/x86/util/mem-events.c
@@ -28,16 +28,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 9ea9e9a868c4..336d1109b3a5 100644
--- a/tools/perf/util/mem-events.c
+++ b/tools/perf/util/mem-events.c
@@ -103,9 +103,19 @@  static const char *perf_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_mem_events__parse(struct perf_pmu *pmu, const char *str)