From: Leo Yan <leo.yan@arm.com>
To: Peter Zijlstra <peterz@infradead.org>,
Ingo Molnar <mingo@redhat.com>,
Arnaldo Carvalho de Melo <acme@kernel.org>,
Namhyung Kim <namhyung@kernel.org>,
Mark Rutland <mark.rutland@arm.com>,
Ian Rogers <irogers@google.com>,
Adrian Hunter <adrian.hunter@intel.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 v3 3/5] perf auxtrace: Refactor evlist__enable_event_idx()
Date: Tue, 6 Aug 2024 21:48:11 +0100 [thread overview]
Message-ID: <20240806204813.722372-4-leo.yan@arm.com> (raw)
In-Reply-To: <20240806204813.722372-1-leo.yan@arm.com>
This commit splits the evlist__enable_event_idx() function into two
steps. The first step uses a new function evlist__find_cpu_map_idx() to
find the CPU map index, based on the found CPU map index or a thread map
index, it continues to call evlist__enable_event_idx() for enabling the
corresponding event.
Signed-off-by: Leo Yan <leo.yan@arm.com>
---
tools/perf/util/auxtrace.c | 42 +++++++++++++++++++++++++++++---------
1 file changed, 32 insertions(+), 10 deletions(-)
diff --git a/tools/perf/util/auxtrace.c b/tools/perf/util/auxtrace.c
index d5015d27b6dd..174d486056e0 100644
--- a/tools/perf/util/auxtrace.c
+++ b/tools/perf/util/auxtrace.c
@@ -651,20 +651,30 @@ int auxtrace_parse_snapshot_options(struct auxtrace_record *itr,
return -EINVAL;
}
-static int evlist__enable_event_idx(struct evlist *evlist, struct evsel *evsel, int idx)
+static int evlist__find_cpu_map_idx(struct evlist *evlist, struct evsel *evsel,
+ int idx)
{
bool per_cpu_mmaps = !perf_cpu_map__has_any_cpu(evlist->core.user_requested_cpus);
+ struct perf_cpu evlist_cpu;
+ int cpu_map_idx;
- if (per_cpu_mmaps) {
- struct perf_cpu evlist_cpu = perf_cpu_map__cpu(evlist->core.all_cpus, idx);
- int cpu_map_idx = perf_cpu_map__idx(evsel->core.cpus, evlist_cpu);
+ if (!per_cpu_mmaps)
+ return -EINVAL;
- if (cpu_map_idx == -1)
- return -EINVAL;
- return perf_evsel__enable_cpu(&evsel->core, cpu_map_idx);
- }
+ evlist_cpu = perf_cpu_map__cpu(evlist->core.all_cpus, idx);
+ cpu_map_idx = perf_cpu_map__idx(evsel->core.cpus, evlist_cpu);
+ if (cpu_map_idx == -1)
+ return -ENOENT;
+
+ return cpu_map_idx;
+}
- return perf_evsel__enable_thread(&evsel->core, idx);
+static int evlist__enable_event_idx(struct evsel *evsel, int cpu_mode, int idx)
+{
+ if (cpu_mode)
+ return perf_evsel__enable_cpu(&evsel->core, idx);
+ else
+ return perf_evsel__enable_thread(&evsel->core, idx);
}
int auxtrace_record__read_finish(struct auxtrace_record *itr, int idx)
@@ -675,10 +685,22 @@ int auxtrace_record__read_finish(struct auxtrace_record *itr, int idx)
return -EINVAL;
evlist__for_each_entry(itr->evlist, evsel) {
+ int cpu_map_idx;
+
if (evsel__is_aux_event(evsel)) {
if (evsel->disabled)
return 0;
- return evlist__enable_event_idx(itr->evlist, evsel, idx);
+
+ cpu_map_idx = evlist__find_cpu_map_idx(itr->evlist,
+ evsel, idx);
+ /* No map is found in per CPU mmap */
+ if (cpu_map_idx == -ENOENT)
+ return cpu_map_idx;
+
+ if (cpu_map_idx >= 0)
+ return evlist__enable_event_idx(evsel, 1, cpu_map_idx);
+ else
+ return evlist__enable_event_idx(evsel, 0, idx);
}
}
return -EINVAL;
--
2.34.1
next prev parent reply other threads:[~2024-08-06 20:48 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-08-06 20:48 [PATCH v3 0/5] perf auxtrace: Support multiple AUX events Leo Yan
2024-08-06 20:48 ` [PATCH v3 1/5] perf/core: Allow multiple AUX PMU events with the same module Leo Yan
2024-08-06 21:14 ` Peter Zijlstra
2024-08-06 21:51 ` Leo Yan
2024-08-06 20:48 ` [PATCH v3 2/5] perf auxtrace: Introduce auxtrace_record__validate_events() Leo Yan
2024-08-06 20:48 ` Leo Yan [this message]
2024-08-06 20:48 ` [PATCH v3 4/5] perf auxtrace: Bails out after finding the event for the map index Leo Yan
2024-08-06 20:48 ` [PATCH v3 5/5] perf auxtrace: Iterate all AUX events when finish reading Leo Yan
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=20240806204813.722372-4-leo.yan@arm.com \
--to=leo.yan@arm.com \
--cc=acme@kernel.org \
--cc=adrian.hunter@intel.com \
--cc=irogers@google.com \
--cc=james.clark@linaro.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=mingo@redhat.com \
--cc=namhyung@kernel.org \
--cc=peterz@infradead.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®