From: Jens Axboe <[email protected]>
To: [email protected]
Cc: Jens Axboe <[email protected]>
Subject: [PATCH 4/4] io_uring: add support for sharing kernel io-wq workqueue
Date: Thu, 23 Jan 2020 16:16:14 -0700 [thread overview]
Message-ID: <[email protected]> (raw)
In-Reply-To: <[email protected]>
An id field is added to io_uring_params, which always returns the ID of
the io-wq backend that is associated with an io_uring context. If an 'id'
is provided and IORING_SETUP_SHARED is set in the creation flags, then
we attempt to attach to an existing io-wq instead of setting up a new one.
This allows creation of "sibling" io_urings, where we prefer to keep the
SQ/CQ private, but want to share the async backend to minimize the amount
of overhead associated with having multiple rings that belong to the same
backend.
Signed-off-by: Jens Axboe <[email protected]>
---
fs/io_uring.c | 9 +++++++--
include/uapi/linux/io_uring.h | 4 +++-
2 files changed, 10 insertions(+), 3 deletions(-)
diff --git a/fs/io_uring.c b/fs/io_uring.c
index 25f29ef81698..857cdf3f5ff6 100644
--- a/fs/io_uring.c
+++ b/fs/io_uring.c
@@ -5796,13 +5796,18 @@ static int io_sq_offload_start(struct io_ring_ctx *ctx,
/* Do QD, or 4 * CPUS, whatever is smallest */
concurrency = min(ctx->sq_entries, 4 * num_online_cpus());
- ctx->io_wq = io_wq_create(concurrency, &data);
+
+ if (ctx->flags & IORING_SETUP_SHARED)
+ ctx->io_wq = io_wq_create_id(concurrency, &data, p->id);
+ else
+ ctx->io_wq = io_wq_create(concurrency, &data);
if (IS_ERR(ctx->io_wq)) {
ret = PTR_ERR(ctx->io_wq);
ctx->io_wq = NULL;
goto err;
}
+ p->id = io_wq_id(ctx->io_wq);
return 0;
err:
io_finish_async(ctx);
@@ -6626,7 +6631,7 @@ static long io_uring_setup(u32 entries, struct io_uring_params __user *params)
if (p.flags & ~(IORING_SETUP_IOPOLL | IORING_SETUP_SQPOLL |
IORING_SETUP_SQ_AFF | IORING_SETUP_CQSIZE |
- IORING_SETUP_CLAMP))
+ IORING_SETUP_CLAMP | IORING_SETUP_SHARED))
return -EINVAL;
ret = io_uring_create(entries, &p);
diff --git a/include/uapi/linux/io_uring.h b/include/uapi/linux/io_uring.h
index cffa6fd33827..c74681d30e92 100644
--- a/include/uapi/linux/io_uring.h
+++ b/include/uapi/linux/io_uring.h
@@ -75,6 +75,7 @@ enum {
#define IORING_SETUP_SQ_AFF (1U << 2) /* sq_thread_cpu is valid */
#define IORING_SETUP_CQSIZE (1U << 3) /* app defines CQ size */
#define IORING_SETUP_CLAMP (1U << 4) /* clamp SQ/CQ ring sizes */
+#define IORING_SETUP_SHARED (1U << 5) /* share workqueue */
enum {
IORING_OP_NOP,
@@ -184,7 +185,8 @@ struct io_uring_params {
__u32 sq_thread_cpu;
__u32 sq_thread_idle;
__u32 features;
- __u32 resv[4];
+ __u32 id;
+ __u32 resv[3];
struct io_sqring_offsets sq_off;
struct io_cqring_offsets cq_off;
};
--
2.25.0
next prev parent reply other threads:[~2020-01-23 23:16 UTC|newest]
Thread overview: 36+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-01-23 23:16 [PATCHSET 0/4] Add support for shared io-wq backends Jens Axboe
2020-01-23 23:16 ` [PATCH 1/4] io-wq: make the io_wq ref counted Jens Axboe
2020-01-23 23:16 ` [PATCH 2/4] io-wq: add 'id' to io_wq Jens Axboe
2020-01-23 23:16 ` [PATCH 3/4] io-wq: allow lookup of existing io_wq with given id Jens Axboe
2020-01-24 9:54 ` Stefan Metzmacher
2020-01-24 16:41 ` Jens Axboe
2020-01-23 23:16 ` Jens Axboe [this message]
2020-01-24 9:51 ` [PATCHSET 0/4] Add support for shared io-wq backends Stefan Metzmacher
2020-01-24 16:43 ` Jens Axboe
2020-01-24 19:14 ` Stefan Metzmacher
2020-01-24 21:37 ` Jens Axboe
2020-01-24 20:34 ` Pavel Begunkov
2020-01-24 21:38 ` Jens Axboe
2020-01-26 1:51 ` Daurnimator
2020-01-26 15:11 ` Pavel Begunkov
2020-01-26 17:00 ` Jens Axboe
2020-01-27 13:29 ` Pavel Begunkov
2020-01-27 13:39 ` Jens Axboe
2020-01-27 14:07 ` Pavel Begunkov
2020-01-27 19:39 ` Pavel Begunkov
2020-01-27 19:45 ` Jens Axboe
2020-01-27 20:33 ` Jens Axboe
2020-01-27 21:45 ` Pavel Begunkov
2020-01-27 22:40 ` Jens Axboe
2020-01-27 23:00 ` Jens Axboe
2020-01-27 23:17 ` Pavel Begunkov
2020-01-27 23:23 ` Jens Axboe
2020-01-27 23:25 ` Pavel Begunkov
2020-01-27 23:38 ` Jens Axboe
2020-01-28 10:01 ` Stefan Metzmacher
2020-01-28 10:30 ` Pavel Begunkov
2020-01-28 10:35 ` Stefan Metzmacher
2020-01-28 10:51 ` Pavel Begunkov
-- strict thread matches above, loose matches on Subject: below --
2020-01-24 21:31 [PATCHSET v2 " Jens Axboe
2020-01-24 21:31 ` [PATCH 4/4] io_uring: add support for sharing kernel io-wq workqueue Jens Axboe
2020-01-25 7:45 ` Stefan Metzmacher
2020-01-25 16:44 ` Jens Axboe
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
[email protected] \
[email protected] \
[email protected] \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox