[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <e4d366eab34d2427faded11de6ecb9efe8b781ef.1629490974.git.rickyman7@gmail.com>
Date: Sat, 21 Aug 2021 11:19:32 +0200
From: Riccardo Mancini <rickyman7@...il.com>
To: Arnaldo Carvalho de Melo <acme@...nel.org>
Cc: Ian Rogers <irogers@...gle.com>,
Namhyung Kim <namhyung@...nel.org>,
Peter Zijlstra <peterz@...radead.org>,
Ingo Molnar <mingo@...hat.com>,
Mark Rutland <mark.rutland@....com>,
Jiri Olsa <jolsa@...hat.com>, linux-kernel@...r.kernel.org,
linux-perf-users@...r.kernel.org,
Riccardo Mancini <rickyman7@...il.com>
Subject: [RFC PATCH v1 26/37] perf evsel: add evsel__open_per_cpu_no_fallback function
This function is equivalent to evsel__open, but without any fallback
mechanism, which should be handled separately.
It is also possible to a starting thread to be able to resume
a previous failing evsel__open_per_cpu_no_fallback.
Signed-off-by: Riccardo Mancini <rickyman7@...il.com>
---
tools/perf/util/evsel.c | 44 +++++++++++++++++++++++++++++++++++++++++
tools/perf/util/evsel.h | 9 +++++++++
2 files changed, 53 insertions(+)
diff --git a/tools/perf/util/evsel.c b/tools/perf/util/evsel.c
index e41f55a7a70ea630..74aad07f3c1102cb 100644
--- a/tools/perf/util/evsel.c
+++ b/tools/perf/util/evsel.c
@@ -2021,6 +2021,50 @@ static struct perf_event_open_result perf_event_open(struct evsel *evsel,
return res;
}
+struct evsel_open_result evsel__open_per_cpu_no_fallback(struct evsel *evsel,
+ struct perf_cpu_map *cpus,
+ struct perf_thread_map *threads,
+ int cpu, int start_thread)
+{
+ int thread, nthreads, pid = -1;
+ struct evsel_open_result res = { .thread = start_thread };
+
+ if (cpus == NULL)
+ cpus = empty_cpu_map;
+
+ if (threads == NULL)
+ threads = empty_thread_map;
+
+ if (evsel->core.system_wide)
+ nthreads = 1;
+ else
+ nthreads = threads->nr;
+
+ if (evsel->cgrp)
+ pid = evsel->cgrp->fd;
+
+ display_attr(&evsel->core.attr);
+
+
+ for (thread = start_thread; thread < nthreads; thread++) {
+ res.peo_res = perf_event_open(evsel, pid, cpu, thread, cpus,
+ threads);
+
+ switch (res.peo_res.err) {
+ case PEO_SUCCESS:
+ continue;
+ case PEO_FALLBACK:
+ goto out;
+ default:
+ case PEO_ERROR:
+ goto out;
+ }
+ }
+out:
+ res.thread = thread;
+ return res;
+}
+
static int evsel__open_cpu(struct evsel *evsel, struct perf_cpu_map *cpus,
struct perf_thread_map *threads,
int start_cpu, int end_cpu)
diff --git a/tools/perf/util/evsel.h b/tools/perf/util/evsel.h
index 8c9827a93ac001a7..fa0d732d0a088016 100644
--- a/tools/perf/util/evsel.h
+++ b/tools/perf/util/evsel.h
@@ -294,10 +294,19 @@ struct perf_event_open_result {
int fd;
};
+struct evsel_open_result {
+ int thread;
+ struct perf_event_open_result peo_res;
+};
+
int evsel__open_per_cpu(struct evsel *evsel, struct perf_cpu_map *cpus, int cpu);
int evsel__open_per_thread(struct evsel *evsel, struct perf_thread_map *threads);
int evsel__open(struct evsel *evsel, struct perf_cpu_map *cpus,
struct perf_thread_map *threads);
+struct evsel_open_result evsel__open_per_cpu_no_fallback(struct evsel *evsel,
+ struct perf_cpu_map *cpus,
+ struct perf_thread_map *threads,
+ int cpu, int start_thread);
void evsel__close(struct evsel *evsel);
int evsel__prepare_open(struct evsel *evsel, struct perf_cpu_map *cpus,
struct perf_thread_map *threads);
--
2.31.1
Powered by blists - more mailing lists