diff options
| author | Ian Rogers <irogers@google.com> | 2025-12-03 13:47:02 -0800 |
|---|---|---|
| committer | Namhyung Kim <namhyung@kernel.org> | 2025-12-04 00:36:14 -0800 |
| commit | e2de90bdc9f55a2a98fe6ee014c070d5c1d7cfb7 (patch) | |
| tree | 41b7d5bafb85ab8d17c89b3b0dfc092d472a4acb | |
| parent | a0a4173631bfcfd3520192c0a61cf911d6a52c3a (diff) | |
perf cpumap: Add "any" CPU handling to cpu_map__snprint_mask
If the perf_cpu_map is empty or is just the any CPU value, then early
return. Don't process the "any" CPU when creating the bitmap.
Tested-by: Ingo Molnar <mingo@kernel.org>
Signed-off-by: Ian Rogers <irogers@google.com>
Tested-by: Thomas Richter <tmricht@linux.ibm.com>
Signed-off-by: Namhyung Kim <namhyung@kernel.org>
| -rw-r--r-- | tools/perf/util/cpumap.c | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/tools/perf/util/cpumap.c b/tools/perf/util/cpumap.c index 89570397a4b3..a80845038a5e 100644 --- a/tools/perf/util/cpumap.c +++ b/tools/perf/util/cpumap.c @@ -684,16 +684,21 @@ size_t cpu_map__snprint_mask(struct perf_cpu_map *map, char *buf, size_t size) unsigned char *bitmap; struct perf_cpu c, last_cpu = perf_cpu_map__max(map); - if (buf == NULL) + if (buf == NULL || size == 0) return 0; + if (last_cpu.cpu < 0) { + buf[0] = '\0'; + return 0; + } + bitmap = zalloc(last_cpu.cpu / 8 + 1); if (bitmap == NULL) { buf[0] = '\0'; return 0; } - perf_cpu_map__for_each_cpu(c, idx, map) + perf_cpu_map__for_each_cpu_skip_any(c, idx, map) bitmap[c.cpu / 8] |= 1 << (c.cpu % 8); for (int cpu = last_cpu.cpu / 4 * 4; cpu >= 0; cpu -= 4) { |
