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 <[email protected]> Reviewed-by: James Clark <[email protected]> Cc: Suzuki K Poulose <[email protected]> Cc: Will Deacon <[email protected]> Cc: Mike Leach <[email protected]> Cc: Kajol Jain <[email protected]> Cc: John Garry <[email protected]> Cc: [email protected] Cc: [email protected] Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Namhyung Kim <[email protected]>
1 parent e6b4da6 commit 14b0fff

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

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)