Commit 491b13c4 authored by Ian Rogers's avatar Ian Rogers Committed by Arnaldo Carvalho de Melo

perf cpumap: Use perf_cpu_map__cpu(map, cpu) instead of accessing map->map[cpu] directly

So that we can validate the 'map' instance wrt refcount checking.

Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: Alexey Bayduraev <alexey.v.bayduraev@linux.intel.com>
Cc: Dmitriy Vyukov <dvyukov@google.com>
Cc: Ian Rogers <irogers@google.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Riccardo Mancini <rickyman7@gmail.com>
Cc: Stephane Eranian <eranian@google.com>
Cc: Stephen Brennan <stephen.s.brennan@oracle.com>
Link: https://lore.kernel.org/lkml/20230407230405.2931830-3-irogers@google.com
[ Extracted from a larger patch ]
Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
parent d57fd492
...@@ -582,26 +582,26 @@ size_t cpu_map__snprint(struct perf_cpu_map *map, char *buf, size_t size) ...@@ -582,26 +582,26 @@ size_t cpu_map__snprint(struct perf_cpu_map *map, char *buf, size_t size)
bool last = i == perf_cpu_map__nr(map); bool last = i == perf_cpu_map__nr(map);
if (!last) if (!last)
cpu = map->map[i]; cpu = perf_cpu_map__cpu(map, i);
if (start == -1) { if (start == -1) {
start = i; start = i;
if (last) { if (last) {
ret += snprintf(buf + ret, size - ret, ret += snprintf(buf + ret, size - ret,
"%s%d", COMMA, "%s%d", COMMA,
map->map[i].cpu); perf_cpu_map__cpu(map, i).cpu);
} }
} else if (((i - start) != (cpu.cpu - map->map[start].cpu)) || last) { } else if (((i - start) != (cpu.cpu - perf_cpu_map__cpu(map, start).cpu)) || last) {
int end = i - 1; int end = i - 1;
if (start == end) { if (start == end) {
ret += snprintf(buf + ret, size - ret, ret += snprintf(buf + ret, size - ret,
"%s%d", COMMA, "%s%d", COMMA,
map->map[start].cpu); perf_cpu_map__cpu(map, start).cpu);
} else { } else {
ret += snprintf(buf + ret, size - ret, ret += snprintf(buf + ret, size - ret,
"%s%d-%d", COMMA, "%s%d-%d", COMMA,
map->map[start].cpu, map->map[end].cpu); perf_cpu_map__cpu(map, start).cpu, perf_cpu_map__cpu(map, end).cpu);
} }
first = false; first = false;
start = i; start = i;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment