summaryrefslogtreecommitdiff
path: root/tools/perf/util/mmap.c
diff options
context:
space:
mode:
authorIan Rogers <irogers@google.com>2025-03-18 20:19:14 +0300
committerNamhyung Kim <namhyung@kernel.org>2025-03-20 02:56:33 +0300
commit58b8b5d142a8bd5cee3f5181b9d9088051a53a04 (patch)
treef5c603fe2071560d3f2ffddbb0489783b0e1b380 /tools/perf/util/mmap.c
parentebf0b332732dcc64239119e554faa946562b0b93 (diff)
downloadlinux-58b8b5d142a8bd5cee3f5181b9d9088051a53a04.tar.xz
perf cpumap: Increment reference count for online cpumap
Thomas Richter <tmricht@linux.ibm.com> reported a double put on the cpumap for the placeholder core PMU: https://lore.kernel.org/lkml/20250318095132.1502654-3-tmricht@linux.ibm.com/ Requiring the caller to get the cpumap is not how these things are usually done, switch cpu_map__online to do the get and then fix up any use cases where a put is needed. Signed-off-by: Ian Rogers <irogers@google.com> Tested-by: Thomas Richter <tmricht@linux.ibm.com> Link: https://lore.kernel.org/r/20250318171914.145616-1-irogers@google.com Signed-off-by: Namhyung Kim <namhyung@kernel.org>
Diffstat (limited to 'tools/perf/util/mmap.c')
-rw-r--r--tools/perf/util/mmap.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/tools/perf/util/mmap.c b/tools/perf/util/mmap.c
index a7ef4d8d57d8..a34726219af3 100644
--- a/tools/perf/util/mmap.c
+++ b/tools/perf/util/mmap.c
@@ -244,9 +244,8 @@ static void build_node_mask(int node, struct mmap_cpu_mask *mask)
{
int idx, nr_cpus;
struct perf_cpu cpu;
- const struct perf_cpu_map *cpu_map = NULL;
+ struct perf_cpu_map *cpu_map = cpu_map__online();
- cpu_map = cpu_map__online();
if (!cpu_map)
return;
@@ -256,6 +255,7 @@ static void build_node_mask(int node, struct mmap_cpu_mask *mask)
if (cpu__get_node(cpu) == node)
__set_bit(cpu.cpu, mask->bits);
}
+ perf_cpu_map__put(cpu_map);
}
static int perf_mmap__setup_affinity_mask(struct mmap *map, struct mmap_params *mp)