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

[RFC PATCH v3 12/15] perf record: setup global workqueue

From: Riccardo Mancini <hidden>
Date: 2021-08-20 10:55:06
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-record 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-record.c | 15 +++++++++++++++
 1 file changed, 15 insertions(+)
diff --git a/tools/perf/builtin-record.c b/tools/perf/builtin-record.c
index 548c1dbde6c52ed6..4d7b610b1d0bb9af 100644
--- a/tools/perf/builtin-record.c
+++ b/tools/perf/builtin-record.c
@@ -49,6 +49,7 @@
 #include "util/clockid.h"
 #include "util/pmu-hybrid.h"
 #include "util/evlist-hybrid.h"
+#include "util/workqueue/workqueue.h"
 #include "asm/bug.h"
 #include "perf.h"
 
@@ -2894,7 +2895,21 @@ int cmd_record(int argc, const char **argv)
 		rec->opts.comp_level = comp_level_max;
 	pr_debug("comp level: %d\n", rec->opts.comp_level);
 
+	if (rec->opts.nr_threads_synthesize == UINT_MAX)
+		rec->opts.nr_threads_synthesize = sysconf(_SC_NPROCESSORS_ONLN);
+	if (rec->opts.nr_threads_synthesize > 1) {
+		err = setup_global_workqueue(rec->opts.nr_threads_synthesize);
+		if (err) {
+			create_workqueue_strerror(global_wq, errbuf, sizeof(errbuf));
+			pr_err("setup_global_workqueue: %s\n", errbuf);
+			goto out;
+		}
+	}
+
 	err = __cmd_record(&record, argc, argv);
+
+	if (rec->opts.nr_threads_synthesize > 1)
+		teardown_global_workqueue();
 out:
 	bitmap_free(rec->affinity_mask.bits);
 	evlist__delete(rec->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