Thread (22 messages) 22 messages, 3 authors, 2021-08-31
STALE1738d

[RFC PATCH v3 13/15] perf top: setup global workqueue

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

This patch initializes the global workqueue in perf-top if
nr_threads_synthesize is set.

This patch is a preparation for using the global_workqueue in
synthesize.

Signed-off-by: Riccardo Mancini <redacted>
---
 tools/perf/builtin-top.c | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)
diff --git a/tools/perf/builtin-top.c b/tools/perf/builtin-top.c
index a3ae9176a83e2453..9b4f220920780a95 100644
--- a/tools/perf/builtin-top.c
+++ b/tools/perf/builtin-top.c
@@ -49,6 +49,7 @@
 #include "util/term.h"
 #include "util/intlist.h"
 #include "util/parse-branch-options.h"
+#include "util/workqueue/workqueue.h"
 #include "arch/common.h"
 #include "ui/ui.h"
 
@@ -1767,8 +1768,23 @@ int cmd_top(int argc, const char **argv)
 		opts->no_bpf_event = true;
 	}
 
+	if (top.nr_threads_synthesize == UINT_MAX)
+		top.nr_threads_synthesize = sysconf(_SC_NPROCESSORS_ONLN);
+	if (top.nr_threads_synthesize > 1) {
+		status = setup_global_workqueue(top.nr_threads_synthesize);
+		if (status) {
+			create_workqueue_strerror(global_wq, errbuf, sizeof(errbuf));
+			pr_err("setup_global_workqueue: %s\n", errbuf);
+			goto out_stop_sb_th;
+		}
+	}
+
 	status = __cmd_top(&top);
 
+	if (top.nr_threads_synthesize > 1)
+		teardown_global_workqueue();
+
+out_stop_sb_th:
 	if (!opts->no_bpf_event)
 		evlist__stop_sb_thread(top.sb_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