]> www.infradead.org Git - users/jedix/linux-maple.git/commit
perf pmu: Dynamically allocate tool PMU
authorJames Clark <james.clark@linaro.org>
Wed, 26 Feb 2025 10:41:00 +0000 (10:41 +0000)
committerNamhyung Kim <namhyung@kernel.org>
Thu, 27 Feb 2025 00:23:47 +0000 (16:23 -0800)
commit72c6f57a4193f2eadceb52261315438719c4c1ad
treeff299b8458532eec408b512567cc3fa17a1dab73
parent556b58c19154a7060b72ab62c0cd0911ccdbf1ba
perf pmu: Dynamically allocate tool PMU

perf_pmus__destroy() treats all PMUs as allocated and free's them so we
can't have any static PMUs that are added to the PMU lists. Fix it by
allocating the tool PMU in the same way as the others. Current users of
the tool PMU already use find_pmu() and not perf_pmus__tool_pmu(), so
rename the function to add 'new' to avoid it being misused in the
future.

perf_pmus__fake_pmu() can remain as static as it's not added to the
PMU lists.

Fixes the following error:

  $ perf bench internals pmu-scan

  # Running 'internals/pmu-scan' benchmark:
  Computing performance of sysfs PMU event scan for 100 times
  munmap_chunk(): invalid pointer
  Aborted (core dumped)

Fixes: 240505b2d0ad ("perf tool_pmu: Factor tool events into their own PMU")
Reviewed-by: Ian Rogers <irogers@google.com>
Signed-off-by: James Clark <james.clark@linaro.org>
Link: https://lore.kernel.org/r/20250226104111.564443-2-james.clark@linaro.org
Signed-off-by: Namhyung Kim <namhyung@kernel.org>
tools/perf/util/pmus.c
tools/perf/util/tool_pmu.c
tools/perf/util/tool_pmu.h