linux-perf-users.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v1 0/5] perf cpumap: Correct for perf_cpu_map__merge()
@ 2024-09-25 19:53 Leo Yan
  2024-09-25 19:53 ` [PATCH v1 1/5] libperf cpumap: Correct reference count " Leo Yan
                   ` (5 more replies)
  0 siblings, 6 replies; 13+ messages in thread
From: Leo Yan @ 2024-09-25 19:53 UTC (permalink / raw)
  To: Arnaldo Carvalho de Melo, Adrian Hunter, Namhyung Kim,
	Mark Rutland, Alexander Shishkin, Jiri Olsa, Ian Rogers,
	Liang, Kan, James Clark, linux-perf-users, linux-kernel
  Cc: Leo Yan

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/3f03541e-6dab-472f-bad9-4cdc0c0dc061@intel.com/


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(-)

-- 
2.34.1


^ permalink raw reply	[flat|nested] 13+ messages in thread

end of thread, other threads:[~2024-10-11  9:51 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-09-25 19:53 [PATCH v1 0/5] perf cpumap: Correct for perf_cpu_map__merge() Leo Yan
2024-09-25 19:53 ` [PATCH v1 1/5] libperf cpumap: Correct reference count " Leo Yan
2024-10-10 17:41   ` Adrian Hunter
2024-10-11  9:34     ` Leo Yan
2024-10-11  9:40       ` Leo Yan
2024-10-11  9:46         ` Adrian Hunter
2024-10-11  9:51           ` Leo Yan
2024-09-25 19:53 ` [PATCH v1 2/5] perf: Release old CPU maps after merging Leo Yan
2024-09-25 19:53 ` [PATCH v1 3/5] perf cpumap: Update CPU map merging test Leo Yan
2024-09-25 19:53 ` [PATCH v1 4/5] perf cpumap: Add more tests for CPU map merging Leo Yan
2024-09-25 19:53 ` [PATCH v1 5/5] perf cpumap: Add checking for reference counter Leo Yan
2024-10-10 15:01 ` [PATCH v1 0/5] perf cpumap: Correct for perf_cpu_map__merge() Leo Yan
2024-10-10 16:10   ` Namhyung Kim

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).