Skip to content

Commit 14b0fff

Browse files
Leo-Yannamhyung
authored andcommitted
perf mem: Warn if memory events are not supported on all CPUs
It is possible that memory events are not supported on all CPUs. Prints a warning by dumping the enabled CPU maps in this case. Signed-off-by: Leo Yan <leo.yan@arm.com> Reviewed-by: James Clark <james.clark@linaro.org> Cc: Suzuki K Poulose <suzuki.poulose@arm.com> Cc: Will Deacon <will@kernel.org> Cc: Mike Leach <mike.leach@linaro.org> Cc: Kajol Jain <kjain@linux.ibm.com> Cc: John Garry <john.g.garry@oracle.com> Cc: linux-arm-kernel@lists.infradead.org Cc: coresight@lists.linaro.org Link: https://lore.kernel.org/r/20240706152035.86983-3-leo.yan@arm.com Signed-off-by: Namhyung Kim <namhyung@kernel.org>
1 parent e6b4da6 commit 14b0fff

1 file changed

Lines changed: 14 additions & 0 deletions

File tree

tools/perf/util/mem-events.c

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
#include <unistd.h>
99
#include <api/fs/fs.h>
1010
#include <linux/kernel.h>
11+
#include "cpumap.h"
1112
#include "map_symbol.h"
1213
#include "mem-events.h"
1314
#include "mem-info.h"
@@ -242,6 +243,7 @@ int perf_mem_events__record_args(const char **rec_argv, int *argv_nr)
242243
int i = *argv_nr;
243244
const char *s;
244245
char *copy;
246+
struct perf_cpu_map *cpu_map = NULL;
245247

246248
while ((pmu = perf_pmus__scan_mem(pmu)) != NULL) {
247249
for (int j = 0; j < PERF_MEM_EVENTS__MAX; j++) {
@@ -266,7 +268,19 @@ int perf_mem_events__record_args(const char **rec_argv, int *argv_nr)
266268

267269
rec_argv[i++] = "-e";
268270
rec_argv[i++] = copy;
271+
272+
cpu_map = perf_cpu_map__merge(cpu_map, pmu->cpus);
273+
}
274+
}
275+
276+
if (cpu_map) {
277+
if (!perf_cpu_map__equal(cpu_map, cpu_map__online())) {
278+
char buf[200];
279+
280+
cpu_map__snprint(cpu_map, buf, sizeof(buf));
281+
pr_warning("Memory events are enabled on a subset of CPUs: %s\n", buf);
269282
}
283+
perf_cpu_map__put(cpu_map);
270284
}
271285

272286
*argv_nr = i;

0 commit comments

Comments
 (0)