lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <5e564cefbf2612ff492a77f25ba4289ad3efcee0.1629490974.git.rickyman7@gmail.com>
Date:   Sat, 21 Aug 2021 11:19:13 +0200
From:   Riccardo Mancini <rickyman7@...il.com>
To:     Arnaldo Carvalho de Melo <acme@...nel.org>
Cc:     Ian Rogers <irogers@...gle.com>,
        Namhyung Kim <namhyung@...nel.org>,
        Peter Zijlstra <peterz@...radead.org>,
        Ingo Molnar <mingo@...hat.com>,
        Mark Rutland <mark.rutland@....com>,
        Jiri Olsa <jolsa@...hat.com>, linux-kernel@...r.kernel.org,
        linux-perf-users@...r.kernel.org,
        Riccardo Mancini <rickyman7@...il.com>
Subject: [RFC PATCH v1 07/37] perf workqueue: add support for setting affinities to workers

This patch adds an interface to workqueue to set affinities to the
underlying threadpool threads.

Signed-off-by: Riccardo Mancini <rickyman7@...il.com>
---
 tools/perf/util/workqueue/workqueue.c | 21 +++++++++++++++++++++
 tools/perf/util/workqueue/workqueue.h |  6 ++++++
 2 files changed, 27 insertions(+)

diff --git a/tools/perf/util/workqueue/workqueue.c b/tools/perf/util/workqueue/workqueue.c
index 7daac65abb5d57d1..61f1b6c41deba031 100644
--- a/tools/perf/util/workqueue/workqueue.c
+++ b/tools/perf/util/workqueue/workqueue.c
@@ -50,6 +50,7 @@ static const char * const workqueue_errno_str[] = {
 	"Error executing function in threadpool",
 	"Error stopping the threadpool",
 	"Error starting thread in the threadpool",
+	"Error setting affinity in threadpool",
 	"Error sending message to worker",
 	"Error receiving message from worker",
 	"Received unexpected message from worker",
@@ -758,6 +759,26 @@ int flush_workqueue(struct workqueue_struct *wq)
 	return err;
 }
 
+/**
+ * workqueue_set_affinities - set affinities to all threads in @wq->pool
+ */
+int workqueue_set_affinities(struct workqueue_struct *wq,
+				struct mmap_cpu_mask *affinities)
+{
+	wq->pool_errno = threadpool__set_affinities(wq->pool, affinities);
+	return wq->pool_errno ? -WORKQUEUE_ERROR__POOLAFFINITY : 0;
+}
+
+/**
+ * workqueue_set_affinities - set affinity to thread @tidx in @wq->pool
+ */
+int workqueue_set_affinity(struct workqueue_struct *wq, int tidx,
+				struct mmap_cpu_mask *affinity)
+{
+	wq->pool_errno = threadpool__set_affinity(wq->pool, tidx, affinity);
+	return wq->pool_errno ? -WORKQUEUE_ERROR__POOLAFFINITY : 0;
+}
+
 /**
  * init_work - initialize the @work struct
  */
diff --git a/tools/perf/util/workqueue/workqueue.h b/tools/perf/util/workqueue/workqueue.h
index 7a0eda923df25d85..dc6baee138b22ab2 100644
--- a/tools/perf/util/workqueue/workqueue.h
+++ b/tools/perf/util/workqueue/workqueue.h
@@ -28,6 +28,11 @@ extern int queue_work_on_worker(int tidx, struct workqueue_struct *wq, struct wo
 
 extern int flush_workqueue(struct workqueue_struct *wq);
 
+extern int workqueue_set_affinities(struct workqueue_struct *wq,
+				struct mmap_cpu_mask *affinities);
+extern int workqueue_set_affinity(struct workqueue_struct *wq, int tidx,
+				struct mmap_cpu_mask *affinity);
+
 extern void init_work(struct work_struct *work);
 
 /* parallel_for utility */
@@ -92,6 +97,7 @@ enum {
 	WORKQUEUE_ERROR__POOLEXE,
 	WORKQUEUE_ERROR__POOLSTOP,
 	WORKQUEUE_ERROR__POOLSTARTTHREAD,
+	WORKQUEUE_ERROR__POOLAFFINITY,
 	WORKQUEUE_ERROR__WRITEPIPE,
 	WORKQUEUE_ERROR__READPIPE,
 	WORKQUEUE_ERROR__INVALIDMSG,
-- 
2.31.1

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ