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 14/15] perf test/synthesis: setup global workqueue
Date
This patch sets up the global workqueue in the synthesis test.
The next patch will use it for synthesis.

Signed-off-by: Riccardo Mancini <rickyman7@gmail.com>
---
tools/perf/bench/synthesize.c | 16 ++++++++++++++--
1 file changed, 14 insertions(+), 2 deletions(-)

diff --git a/tools/perf/bench/synthesize.c b/tools/perf/bench/synthesize.c
index 05f7c923c745b4e8..738821113a005a6c 100644
--- a/tools/perf/bench/synthesize.c
+++ b/tools/perf/bench/synthesize.c
@@ -16,6 +16,7 @@
#include "../util/thread_map.h"
#include "../util/tool.h"
#include "../util/util.h"
+#include "../util/workqueue/workqueue.h"
#include <linux/atomic.h>
#include <linux/err.h>
#include <linux/time64.h>
@@ -208,6 +209,7 @@ static int run_multi_threaded(void)
};
unsigned int nr_threads_synthesize;
int err;
+ char errbuf[BUFSIZ];

if (max_threads == UINT_MAX)
max_threads = sysconf(_SC_NPROCESSORS_ONLN);
@@ -219,10 +221,17 @@ static int run_multi_threaded(void)
for (nr_threads_synthesize = min_threads;
nr_threads_synthesize <= max_threads;
nr_threads_synthesize++) {
- if (nr_threads_synthesize == 1)
+ if (nr_threads_synthesize == 1) {
perf_set_singlethreaded();
- else
+ } else {
+ err = setup_global_workqueue(nr_threads_synthesize);
+ if (err) {
+ create_workqueue_strerror(global_wq, errbuf, sizeof(errbuf));
+ pr_err("setup_global_workqueue: %s\n", errbuf);
+ return err;
+ }
perf_set_multithreaded();
+ }

printf(" Number of synthesis threads: %u\n",
nr_threads_synthesize);
@@ -230,6 +239,9 @@ static int run_multi_threaded(void)
err = do_run_multi_threaded(&target, nr_threads_synthesize);
if (err)
return err;
+
+ if (nr_threads_synthesize > 1)
+ teardown_global_workqueue();
}
perf_set_singlethreaded();
return 0;
--
2.31.1
\
 
 \ /
  Last update: 2021-08-20 12:56    [W:0.311 / U:0.060 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site