Thread (63 messages) 63 messages, 3 authors, 2021-12-11
STALE1635d

[RFC PATCH v1 12/37] perf evlist: add multithreading to evlist__enable

From: Riccardo Mancini <hidden>
Date: 2021-08-21 09:20:47
Also in: lkml
Subsystem: performance events subsystem, the rest · Maintainers: Peter Zijlstra, Ingo Molnar, Arnaldo Carvalho de Melo, Namhyung Kim, Linus Torvalds

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 <redacted>
---
 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
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help