lkml.org 
[lkml]   [2021]   [Aug]   [20]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[RFC PATCH v3 13/15] perf top: setup global workqueue
Date
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 <rickyman7@gmail.com>
---
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
\
 
 \ /
  Last update: 2021-08-20 12:55    [W:0.127 / U:1.060 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site