From: Leo Yan <leo.yan@arm.com>
To: Arnaldo Carvalho de Melo <acme@kernel.org>,
Adrian Hunter <adrian.hunter@intel.com>,
Namhyung Kim <namhyung@kernel.org>,
Mark Rutland <mark.rutland@arm.com>,
Alexander Shishkin <alexander.shishkin@linux.intel.com>,
Jiri Olsa <jolsa@kernel.org>, Ian Rogers <irogers@google.com>,
"Liang, Kan" <kan.liang@linux.intel.com>,
James Clark <james.clark@linaro.org>,
linux-perf-users@vger.kernel.org, linux-kernel@vger.kernel.org
Cc: Leo Yan <leo.yan@arm.com>
Subject: [PATCH v1 2/5] perf: Release old CPU maps after merging
Date: Wed, 25 Sep 2024 20:53:22 +0100 [thread overview]
Message-ID: <20240925195325.426533-3-leo.yan@arm.com> (raw)
In-Reply-To: <20240925195325.426533-1-leo.yan@arm.com>
After CPU maps are merged, the old CPU map will not automatically
released.
This commit adds a new variable to record old CPU map, after merging the
new allocated map is returned, and release the old CPU map.
Signed-off-by: Leo Yan <leo.yan@arm.com>
---
tools/lib/perf/evlist.c | 4 ++++
tools/perf/util/mem-events.c | 4 +++-
2 files changed, 7 insertions(+), 1 deletion(-)
diff --git a/tools/lib/perf/evlist.c b/tools/lib/perf/evlist.c
index c6d67fc9e57e..37920e0b0cd6 100644
--- a/tools/lib/perf/evlist.c
+++ b/tools/lib/perf/evlist.c
@@ -36,6 +36,8 @@ void perf_evlist__init(struct perf_evlist *evlist)
static void __perf_evlist__propagate_maps(struct perf_evlist *evlist,
struct perf_evsel *evsel)
{
+ struct perf_cpu_map *old_all_cpus;
+
if (evsel->system_wide) {
/* System wide: set the cpu map of the evsel to all online CPUs. */
perf_cpu_map__put(evsel->cpus);
@@ -75,7 +77,9 @@ static void __perf_evlist__propagate_maps(struct perf_evlist *evlist,
evsel->threads = perf_thread_map__get(evlist->threads);
}
+ old_all_cpus = evlist->all_cpus;
evlist->all_cpus = perf_cpu_map__merge(evlist->all_cpus, evsel->cpus);
+ perf_cpu_map__put(old_all_cpus);
}
static void perf_evlist__propagate_maps(struct perf_evlist *evlist)
diff --git a/tools/perf/util/mem-events.c b/tools/perf/util/mem-events.c
index 051feb93ed8d..016a1f4adb5d 100644
--- a/tools/perf/util/mem-events.c
+++ b/tools/perf/util/mem-events.c
@@ -257,7 +257,7 @@ int perf_mem_events__record_args(const char **rec_argv, int *argv_nr)
int i = *argv_nr;
const char *s;
char *copy;
- struct perf_cpu_map *cpu_map = NULL;
+ struct perf_cpu_map *cpu_map = NULL, *old_cpu_map;
while ((pmu = perf_pmus__scan_mem(pmu)) != NULL) {
for (int j = 0; j < PERF_MEM_EVENTS__MAX; j++) {
@@ -283,7 +283,9 @@ int perf_mem_events__record_args(const char **rec_argv, int *argv_nr)
rec_argv[i++] = "-e";
rec_argv[i++] = copy;
+ old_cpu_map = cpu_map;
cpu_map = perf_cpu_map__merge(cpu_map, pmu->cpus);
+ perf_cpu_map__put(old_cpu_map);
}
}
--
2.34.1
next prev parent reply other threads:[~2024-09-25 19:53 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
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 ` Leo Yan [this message]
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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20240925195325.426533-3-leo.yan@arm.com \
--to=leo.yan@arm.com \
--cc=acme@kernel.org \
--cc=adrian.hunter@intel.com \
--cc=alexander.shishkin@linux.intel.com \
--cc=irogers@google.com \
--cc=james.clark@linaro.org \
--cc=jolsa@kernel.org \
--cc=kan.liang@linux.intel.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-perf-users@vger.kernel.org \
--cc=mark.rutland@arm.com \
--cc=namhyung@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®