Skip to content

Commit bd26bdd

Browse files
captain5050acmel
authored andcommitted
perf cpumap: Trim the cpu_aggr_map
cpu_aggr_map__new() removes duplicates, when this happens shrink the array. Reviewed-by: James Clark <[email protected]> Signed-off-by: Ian Rogers <[email protected]> Cc: Alexander Shishkin <[email protected]> Cc: Andi Kleen <[email protected]> Cc: Ingo Molnar <[email protected]> Cc: Jiri Olsa <[email protected]> Cc: John Garry <[email protected]> Cc: Kajol Jain <[email protected]> Cc: Kan Liang <[email protected]> Cc: Leo Yan <[email protected]> Cc: Mark Rutland <[email protected]> Cc: Mathieu Poirier <[email protected]> Cc: Mike Leach <[email protected]> Cc: Namhyung Kim <[email protected]> Cc: Paul Clarke <[email protected]> Cc: Peter Zijlstra <[email protected]> Cc: Riccardo Mancini <[email protected]> Cc: Stephane Eranian <[email protected]> Cc: Suzuki Poulouse <[email protected]> Cc: Vineet Singh <[email protected]> Cc: [email protected] Cc: [email protected] Cc: [email protected] Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Arnaldo Carvalho de Melo <[email protected]>
1 parent 92aad5c commit bd26bdd

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

tools/perf/util/cpumap.c

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,15 @@ struct cpu_aggr_map *cpu_aggr_map__new(const struct perf_cpu_map *cpus,
185185
c->nr++;
186186
}
187187
}
188-
188+
/* Trim. */
189+
if (c->nr != cpus->nr) {
190+
struct cpu_aggr_map *trimmed_c =
191+
realloc(c,
192+
sizeof(struct cpu_aggr_map) + sizeof(struct aggr_cpu_id) * c->nr);
193+
194+
if (trimmed_c)
195+
c = trimmed_c;
196+
}
189197
/* ensure we process id in increasing order */
190198
qsort(c->map, c->nr, sizeof(struct aggr_cpu_id), aggr_cpu_id__cmp);
191199

0 commit comments

Comments
 (0)