[PATCH v2 0/3] perf cpumap: Refactor perf_cpu_map__merge()

Leo Yan posted 3 patches 2 weeks, 2 days ago
tools/lib/perf/cpumap.c              | 49 +++++++++++++------------
tools/lib/perf/evlist.c              |  2 +-
tools/lib/perf/include/perf/cpumap.h |  4 +--
tools/perf/tests/cpumap.c            | 54 ++++++++++++++++++++++------
tools/perf/util/mem-events.c         |  5 ++-
5 files changed, 77 insertions(+), 37 deletions(-)
[PATCH v2 0/3] perf cpumap: Refactor perf_cpu_map__merge()
Posted by Leo Yan 2 weeks, 2 days ago
perf_cpu_map__merge() has two arguments, 'orig' and 'other'.  The
function definition might cause confusion as it could give
the impression that the CPU maps in the two arguments are copied into a
new allocated structure, which is then returned as the result.

This patch series refactors perf_cpu_map__merge(), makes that the first
argument 'orig' as a pointer to pointer, the merged result will be
updated into 'orig' rather than returning a pointer.  This can be clear
for the semantics that it merges 'other' into 'orig'.

The perf test has been updated for covering more cases for CPU map
merging.  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


Leo Yan (3):
  libperf cpumap: Refactor perf_cpu_map__merge()
  perf cpumap: Add more tests for CPU map merging
  perf cpumap: Add checking for reference counter

 tools/lib/perf/cpumap.c              | 49 +++++++++++++------------
 tools/lib/perf/evlist.c              |  2 +-
 tools/lib/perf/include/perf/cpumap.h |  4 +--
 tools/perf/tests/cpumap.c            | 54 ++++++++++++++++++++++------
 tools/perf/util/mem-events.c         |  5 ++-
 5 files changed, 77 insertions(+), 37 deletions(-)

-- 
2.34.1