[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <7dd234195436b7f6db850719292f6d9d63fdd6ff.1629490974.git.rickyman7@gmail.com>
Date: Sat, 21 Aug 2021 11:19:17 +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 11/37] perf evlist: add multithreading to evlist__disable
In this patch, evlist__for_each_evsel_cpu is used in evlist__disable to
allow it to run in parallel.
Signed-off-by: Riccardo Mancini <rickyman7@...il.com>
---
tools/perf/util/evlist.c | 57 +++++++++++++++++++++-------------------
1 file changed, 30 insertions(+), 27 deletions(-)
diff --git a/tools/perf/util/evlist.c b/tools/perf/util/evlist.c
index f9fdbd85a163ee97..5c82246813c51c51 100644
--- a/tools/perf/util/evlist.c
+++ b/tools/perf/util/evlist.c
@@ -486,41 +486,44 @@ int evlist__for_each_evsel_cpu(struct evlist *evlist, evsel__cpu_func func, void
}
+struct evlist_disable_args {
+ char *evsel_name;
+ int imm;
+};
+
+static int __evlist__disable_evsel_cpu_func(struct evlist *evlist __maybe_unused,
+ struct evsel *pos, int cpu, void *_args)
+{
+ int ret = 0;
+ struct evlist_disable_args *args = _args;
+
+ if (evsel__strcmp(pos, args->evsel_name))
+ return 0;
+ if (pos->disabled || !evsel__is_group_leader(pos) || !pos->core.fd)
+ return 0;
+ if (pos->immediate)
+ ret = 1;
+ if (pos->immediate != args->imm)
+ return ret;
+ evsel__disable_cpu(pos, cpu);
+
+ return ret;
+}
+
+
static void __evlist__disable(struct evlist *evlist, char *evsel_name)
{
struct evsel *pos;
- struct affinity affinity;
- int cpu, i, imm = 0, cpu_idx;
- bool has_imm = false;
-
- if (affinity__setup(&affinity) < 0)
- return;
+ int ret;
+ struct evlist_disable_args args = { .evsel_name = evsel_name };
/* Disable 'immediate' events last */
- for (imm = 0; imm <= 1; imm++) {
- evlist__for_each_cpu(evlist, i, cpu) {
- affinity__set(&affinity, cpu);
-
- evlist__for_each_entry(evlist, pos) {
- if (evsel__strcmp(pos, evsel_name))
- continue;
- cpu_idx = evsel__find_cpu(pos, cpu);
- if (cpu_idx < 0)
- continue;
- if (pos->disabled || !evsel__is_group_leader(pos) || !pos->core.fd)
- continue;
- if (pos->immediate)
- has_imm = true;
- if (pos->immediate != imm)
- continue;
- evsel__disable_cpu(pos, cpu_idx);
- }
- }
- if (!has_imm)
+ for (args.imm = 0; args.imm <= 1; args.imm++) {
+ ret = evlist__for_each_evsel_cpu(evlist, __evlist__disable_evsel_cpu_func, &args);
+ if (!ret) // does not have immediate evsels
break;
}
- affinity__cleanup(&affinity);
evlist__for_each_entry(evlist, pos) {
if (evsel__strcmp(pos, evsel_name))
continue;
--
2.31.1
Powered by blists - more mailing lists