perf mem amd: Fix perf_pmus__num_mem_pmus()
authorRavi Bangoria <ravi.bangoria@amd.com>
Thu, 15 Jun 2023 05:16:59 +0000 (10:46 +0530)
committerArnaldo Carvalho de Melo <acme@redhat.com>
Fri, 16 Jun 2023 13:50:53 +0000 (10:50 -0300)
perf mem/c2c on AMD internally uses IBS OP PMU, not the core PMU. Also,
AMD platforms does not have heterogeneous PMUs.

Reviewed-by: Ian Rogers <irogers@google.com>
Signed-off-by: Ravi Bangoria <ravi.bangoria@amd.com>
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: Ali Saidi <alisaidi@amazon.com>
Cc: Ananth Narayan <ananth.narayan@amd.com>
Cc: James Clark <james.clark@arm.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Kan Liang <kan.liang@linux.intel.com>
Cc: Leo Yan <leo.yan@linaro.org>
Cc: Madhavan Srinivasan <maddy@linux.ibm.com>
Cc: Mark Rutland <mark.rutland@arm.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Sandipan Das <sandipan.das@amd.com>
Cc: Santosh Shukla <santosh.shukla@amd.com>
Cc: Thomas Richter <tmricht@linux.ibm.com>
Link: https://lore.kernel.org/r/20230615051700.1833-3-ravi.bangoria@amd.com
[ Added the improved comment for perf_pmus__num_mem_pmus() as b4 didn't from the per-patch (not series) newer version ]
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
tools/perf/arch/x86/util/pmu.c
tools/perf/util/pmus.c

index 3c0de33..65d8cdf 100644 (file)
@@ -14,6 +14,8 @@
 #include "../../../util/intel-bts.h"
 #include "../../../util/pmu.h"
 #include "../../../util/fncache.h"
+#include "../../../util/pmus.h"
+#include "env.h"
 
 struct pmu_alias {
        char *name;
@@ -168,3 +170,13 @@ char *pmu_find_alias_name(const char *name)
 
        return __pmu_find_alias_name(name);
 }
+
+int perf_pmus__num_mem_pmus(void)
+{
+       /* AMD uses IBS OP pmu and not a core PMU for perf mem/c2c */
+       if (x86__is_amd_cpu())
+               return 1;
+
+       /* Intel uses core pmus for perf mem/c2c */
+       return perf_pmus__num_core_pmus();
+}
index 8c50ab8..a2032c1 100644 (file)
@@ -242,7 +242,7 @@ const struct perf_pmu *perf_pmus__pmu_for_pmu_filter(const char *str)
        return NULL;
 }
 
-int perf_pmus__num_mem_pmus(void)
+int __weak perf_pmus__num_mem_pmus(void)
 {
        /* All core PMUs are for mem events. */
        return perf_pmus__num_core_pmus();