Skip to content

perf cpumap: Correct for perf_cpu_map__merge()

Leo Yan linux-perf-users lkml 1 version In review

Get series with b4
b4 am [email protected]

Versions newest first

  1. v1 Latest5 patches 7 repliesIn review

Patches in v1 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/5libperf cpumap: Correct reference count for perf_cpu_map__merge()tools/lib/perf/cpumap.c+3 -85 replies
2/5perf: Release old CPU maps after mergingtools/lib/perf/evlist.c tools/perf/util/mem-events.c+7 -10 replies
3/5perf cpumap: Update CPU map merging testtools/perf/tests/cpumap.c+1 -00 replies
4/5perf cpumap: Add more tests for CPU map mergingtools/perf/tests/cpumap.c+29 -50 replies
5/5perf cpumap: Add checking for reference countertools/perf/tests/cpumap.c+20 -00 replies

Reviews trailers per patch

No Reviewed-by, Acked-by or Tested-by trailers for v1 yet.

Read the v1 thread

Cover letter [PATCH v1 0/5] perf cpumap: Correct for perf_cpu_map__merge()

perf_cpu_map__merge() has two arguments, 'orig' and 'other', as described in its original comment:

"orig either gets freed and replaced with a new map, or reused with no reference count change (similar to "realloc") other has its reference count increased."

This causes confusion due to the different reference counting on the CPU map objects, which complicates its usage and makes maintenance difficult. We also discussed this in the email [1].

This patch series makes that a new CPU map is allocated for the merging result, or the reference count is increased if an existing CPU map is reused. This means that once perf_cpu_map__merge() is invoked, the caller gains ownership of the resulting map and must release it with perf_cpu_map__put().

The perf test has been updated accordingly. Tested result is:

  # ./perf test 41
   41: CPU map                            :
   41.1: Synthesize cpu map               : Ok
   41.2: Print cpu map                    : Ok
   41.3: Merge cpu map                    : Ok
   41.4: Intersect cpu map                : Ok
   41.5: Equal cpu map                    : Ok

[1] https://lore.kernel.org/linux-perf-users/[email protected]/

Leo Yan (5):
libperf cpumap: Correct reference count for perf_cpu_map__merge()
perf: Release old CPU maps after merging
perf cpumap: Update CPU map merging test
perf cpumap: Add more tests for CPU map merging
perf cpumap: Add checking for reference counter

 tools/lib/perf/cpumap.c      | 11 ++------
 tools/lib/perf/evlist.c      |  4 +++
 tools/perf/tests/cpumap.c    | 55 ++++++++++++++++++++++++++++++++----
 tools/perf/util/mem-events.c |  4 ++-
 4 files changed, 60 insertions(+), 14 deletions(-)
Signature · 1 line
2.34.1