[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <9a3eda98548b5db42d5a6677ed3c607928d29af9.1629490974.git.rickyman7@gmail.com>
Date: Sat, 21 Aug 2021 11:19:18 +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 12/37] perf evlist: add multithreading to evlist__enable
In this patch, evlist__for_each_evsel_cpu is used in evlist__enable to
allow it to run in parallel.
Signed-off-by: Riccardo Mancini <rickyman7@...il.com>
---
tools/perf/util/evlist.c | 41 +++++++++++++---------------------------
1 file changed, 13 insertions(+), 28 deletions(-)
diff --git a/tools/perf/util/evlist.c b/tools/perf/util/evlist.c
index 5c82246813c51c51..fbe2d6ed8ecc8f21 100644
--- a/tools/perf/util/evlist.c
+++ b/tools/perf/util/evlist.c
@@ -552,37 +552,22 @@ void evlist__disable_evsel(struct evlist *evlist, char *evsel_name)
__evlist__disable(evlist, evsel_name);
}
-static void __evlist__enable(struct evlist *evlist, char *evsel_name)
+static int __evlist__enable_evsel_cpu_fun(struct evlist *evlist __maybe_unused,
+ struct evsel *pos, int cpu, void *args)
{
- struct evsel *pos;
- struct affinity affinity;
- int cpu, i, cpu_idx;
+ char *evsel_name = args;
- if (affinity__setup(&affinity) < 0)
- return;
-
- evlist__for_each_cpu(evlist, i, cpu) {
- affinity__set(&affinity, cpu);
+ if (evsel__strcmp(pos, evsel_name))
+ return 0;
+ if (!evsel__is_group_leader(pos) || !pos->core.fd)
+ return 0;
+ evsel__enable_cpu(pos, cpu);
+ return 0;
+}
- 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 (!evsel__is_group_leader(pos) || !pos->core.fd)
- continue;
- evsel__enable_cpu(pos, cpu_idx);
- }
- }
- affinity__cleanup(&affinity);
- evlist__for_each_entry(evlist, pos) {
- if (evsel__strcmp(pos, evsel_name))
- continue;
- if (!evsel__is_group_leader(pos) || !pos->core.fd)
- continue;
- pos->disabled = false;
- }
+static void __evlist__enable(struct evlist *evlist, char *evsel_name)
+{
+ evlist__for_each_evsel_cpu(evlist, __evlist__enable_evsel_cpu_fun, evsel_name);
/*
* Even single event sets the 'enabled' for evlist,
--
2.31.1
Powered by blists - more mailing lists