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

[RFC PATCH v1 13/37] perf evlist: add multithreading to evlist__close

From: Riccardo Mancini <hidden>
Date: 2021-08-21 09:20:49
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__close to
allow it to run in parallel.

Signed-off-by: Riccardo Mancini <redacted>
---
 tools/perf/util/evlist.c | 23 +++++++++--------------
 1 file changed, 9 insertions(+), 14 deletions(-)
diff --git a/tools/perf/util/evlist.c b/tools/perf/util/evlist.c
index fbe2d6ed8ecc8f21..f0a839107e8849bf 100644
--- a/tools/perf/util/evlist.c
+++ b/tools/perf/util/evlist.c
@@ -1340,11 +1340,17 @@ void evlist__set_selected(struct evlist *evlist, struct evsel *evsel)
 	evlist->selected = evsel;
 }
 
+static int __evlist__close_evsel_cpu_func(struct evlist *evlist __maybe_unused,
+					struct evsel *evsel, int cpu,
+					void *args __maybe_unused)
+{
+	perf_evsel__close_cpu(&evsel->core, cpu);
+	return 0;
+}
+
 void evlist__close(struct evlist *evlist)
 {
 	struct evsel *evsel;
-	struct affinity affinity;
-	int cpu, i, cpu_idx;
 
 	/*
 	 * With perf record core.cpus is usually NULL.
@@ -1356,19 +1362,8 @@ void evlist__close(struct evlist *evlist)
 		return;
 	}
 
-	if (affinity__setup(&affinity) < 0)
-		return;
-	evlist__for_each_cpu(evlist, i, cpu) {
-		affinity__set(&affinity, cpu);
+	evlist__for_each_evsel_cpu(evlist, __evlist__close_evsel_cpu_func, NULL);
 
-		evlist__for_each_entry_reverse(evlist, evsel) {
-			cpu_idx = evsel__find_cpu(evsel, cpu);
-			if (cpu_idx < 0)
-				continue;
-			perf_evsel__close_cpu(&evsel->core, cpu_idx);
-		}
-	}
-	affinity__cleanup(&affinity);
 	evlist__for_each_entry_reverse(evlist, evsel) {
 		perf_evsel__free_fd(&evsel->core);
 		perf_evsel__free_id(&evsel->core);
-- 
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