linux-api.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v3] io-wq: provide IO_WQ_* constants for IORING_REGISTER_IOWQ_MAX_WORKERS arg items
@ 2021-09-13 15:44 Eugene Syromiatnikov
  2021-09-13 16:38 ` Jens Axboe
  0 siblings, 1 reply; 2+ messages in thread
From: Eugene Syromiatnikov @ 2021-09-13 15:44 UTC (permalink / raw)
  To: Jens Axboe, Pavel Begunkov
  Cc: io-uring, linux-kernel, Dmitry V. Levin, linux-api

The items passed in the array pointed by the arg parameter
of IORING_REGISTER_IOWQ_MAX_WORKERS io_uring_register operation
carry certain semantics: they refer to different io-wq worker categories;
provide IO_WQ_* constants in the UAPI, so these categories can be referenced
in the user space code.

Suggested-by: Jens Axboe <axboe@kernel.dk>
Complements: 2e480058ddc21ec5 ("io-wq: provide a way to limit max number of workers")
Signed-off-by: Eugene Syromiatnikov <esyr@redhat.com>
---
v3:
 - Constants are named in accordance with the suggestion, the internal enum
   is no longer touched, BUILD_BUG_ON checks are added.

v2: https://lore.kernel.org/lkml/20210913104101.GA29616@asgard.redhat.com/
 - IO_WQ_ACCT_NR is no longer exposed directly in UAPI, per Jens Axboe's
    suggestion.

v1: https://lore.kernel.org/lkml/20210912122411.GA27679@asgard.redhat.com/
---
 fs/io-wq.c                    | 5 +++++
 include/uapi/linux/io_uring.h | 8 +++++++-
 2 files changed, 12 insertions(+), 1 deletion(-)

diff --git a/fs/io-wq.c b/fs/io-wq.c
index 6c55362..3d21568 100644
--- a/fs/io-wq.c
+++ b/fs/io-wq.c
@@ -14,6 +14,7 @@
 #include <linux/rculist_nulls.h>
 #include <linux/cpu.h>
 #include <linux/tracehook.h>
+#include <uapi/linux/io_uring.h>
 
 #include "io-wq.h"
 
@@ -1287,6 +1288,10 @@ int io_wq_max_workers(struct io_wq *wq, int *new_count)
 {
 	int i, node, prev = 0;
 
+	BUILD_BUG_ON((int) IO_WQ_ACCT_BOUND   != (int) IO_WQ_BOUND);
+	BUILD_BUG_ON((int) IO_WQ_ACCT_UNBOUND != (int) IO_WQ_UNBOUND);
+	BUILD_BUG_ON((int) IO_WQ_ACCT_NR      != 2);
+
 	for (i = 0; i < 2; i++) {
 		if (new_count[i] > task_rlimit(current, RLIMIT_NPROC))
 			new_count[i] = task_rlimit(current, RLIMIT_NPROC);
diff --git a/include/uapi/linux/io_uring.h b/include/uapi/linux/io_uring.h
index 59ef351..b270a07 100644
--- a/include/uapi/linux/io_uring.h
+++ b/include/uapi/linux/io_uring.h
@@ -317,13 +317,19 @@ enum {
 	IORING_REGISTER_IOWQ_AFF		= 17,
 	IORING_UNREGISTER_IOWQ_AFF		= 18,
 
-	/* set/get max number of workers */
+	/* set/get max number of io-wq workers */
 	IORING_REGISTER_IOWQ_MAX_WORKERS	= 19,
 
 	/* this goes last */
 	IORING_REGISTER_LAST
 };
 
+/* io-wq worker categories */
+enum {
+	IO_WQ_BOUND,
+	IO_WQ_UNBOUND,
+};
+
 /* deprecated, see struct io_uring_rsrc_update */
 struct io_uring_files_update {
 	__u32 offset;
-- 
2.1.4


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH v3] io-wq: provide IO_WQ_* constants for IORING_REGISTER_IOWQ_MAX_WORKERS arg items
  2021-09-13 15:44 [PATCH v3] io-wq: provide IO_WQ_* constants for IORING_REGISTER_IOWQ_MAX_WORKERS arg items Eugene Syromiatnikov
@ 2021-09-13 16:38 ` Jens Axboe
  0 siblings, 0 replies; 2+ messages in thread
From: Jens Axboe @ 2021-09-13 16:38 UTC (permalink / raw)
  To: Eugene Syromiatnikov, Pavel Begunkov
  Cc: io-uring, linux-kernel, Dmitry V. Levin, linux-api

On 9/13/21 9:44 AM, Eugene Syromiatnikov wrote:
> The items passed in the array pointed by the arg parameter
> of IORING_REGISTER_IOWQ_MAX_WORKERS io_uring_register operation
> carry certain semantics: they refer to different io-wq worker categories;
> provide IO_WQ_* constants in the UAPI, so these categories can be referenced
> in the user space code.

Applied, thanks.

-- 
Jens Axboe


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2021-09-13 16:39 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-09-13 15:44 [PATCH v3] io-wq: provide IO_WQ_* constants for IORING_REGISTER_IOWQ_MAX_WORKERS arg items Eugene Syromiatnikov
2021-09-13 16:38 ` Jens Axboe

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).