From: Pavel Begunkov <[email protected]>
To: [email protected]
Cc: Jens Axboe <[email protected]>,
[email protected], Dylan Yudaken <[email protected]>,
Stefan Metzmacher <[email protected]>
Subject: [RFC 1/2] io_uring/notif: change notif CQE uapi format
Date: Tue, 16 Aug 2022 08:42:00 +0100 [thread overview]
Message-ID: <1ef0d539e1eb74d9aa0456d07198ecaadaf1b6a4.1660635140.git.asml.silence@gmail.com> (raw)
In-Reply-To: <[email protected]>
Change the notification CQE layout while we can, put the seq number into
cqe->res so we can cqe->flags to mark notification CQEs with
IORING_CQE_F_NOTIF and add other flags in the future if needed. This
will be needed to distinguish notifications from send completions when
they use the same user_data.
Also, limit the sequence number to u16 and reserve upper 16 bits for the
future. We also want it to mask out the sign bit for userspace
convenience as it's easier to test for (cqe->res < 0).
Signed-off-by: Pavel Begunkov <[email protected]>
---
include/uapi/linux/io_uring.h | 6 ++++++
io_uring/notif.c | 4 ++--
2 files changed, 8 insertions(+), 2 deletions(-)
diff --git a/include/uapi/linux/io_uring.h b/include/uapi/linux/io_uring.h
index 1463cfecb56b..20368394870e 100644
--- a/include/uapi/linux/io_uring.h
+++ b/include/uapi/linux/io_uring.h
@@ -286,6 +286,9 @@ enum io_uring_op {
#define IORING_RECVSEND_FIXED_BUF (1U << 2)
#define IORING_RECVSEND_NOTIF_FLUSH (1U << 3)
+/* cqe->res mask for extracting the notification sequence number */
+#define IORING_NOTIF_SEQ_MASK 0xFFFFU
+
/*
* accept flags stored in sqe->ioprio
*/
@@ -337,10 +340,13 @@ struct io_uring_cqe {
* IORING_CQE_F_BUFFER If set, the upper 16 bits are the buffer ID
* IORING_CQE_F_MORE If set, parent SQE will generate more CQE entries
* IORING_CQE_F_SOCK_NONEMPTY If set, more data to read after socket recv
+ * IORING_CQE_F_NOTIF Set for notification CQEs. Can be used to distinct
+ * them from sends.
*/
#define IORING_CQE_F_BUFFER (1U << 0)
#define IORING_CQE_F_MORE (1U << 1)
#define IORING_CQE_F_SOCK_NONEMPTY (1U << 2)
+#define IORING_CQE_F_NOTIF (1U << 3)
enum {
IORING_CQE_BUFFER_SHIFT = 16,
diff --git a/io_uring/notif.c b/io_uring/notif.c
index 714715678817..6e17d1ae5a0d 100644
--- a/io_uring/notif.c
+++ b/io_uring/notif.c
@@ -60,8 +60,8 @@ struct io_kiocb *io_alloc_notif(struct io_ring_ctx *ctx,
notif->rsrc_node = NULL;
io_req_set_rsrc_node(notif, ctx, 0);
notif->cqe.user_data = slot->tag;
- notif->cqe.flags = slot->seq++;
- notif->cqe.res = 0;
+ notif->cqe.flags = IORING_CQE_F_NOTIF;
+ notif->cqe.res = slot->seq++ & IORING_NOTIF_SEQ_MASK;
nd = io_notif_to_data(notif);
nd->account_pages = 0;
--
2.37.0
next prev parent reply other threads:[~2022-08-16 9:27 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-08-16 7:41 [RFC 0/2] io_uring zc notification tag override Pavel Begunkov
2022-08-16 7:42 ` Pavel Begunkov [this message]
2022-08-16 8:14 ` [RFC 1/2] io_uring/notif: change notif CQE uapi format Stefan Metzmacher
2022-08-16 7:42 ` [RFC 2/2] io_uring/net: allow to override notification tag Pavel Begunkov
2022-08-16 8:23 ` Stefan Metzmacher
2022-08-17 12:42 ` Pavel Begunkov
2022-08-18 18:13 ` Stefan Metzmacher
2022-08-19 11:42 ` Pavel Begunkov
2022-08-19 12:36 ` Stefan Metzmacher
2022-08-22 11:49 ` Pavel Begunkov
2022-08-16 8:37 ` Dylan Yudaken
2022-08-17 10:48 ` Pavel Begunkov
2022-08-17 12:04 ` Dylan Yudaken
2022-08-17 12:44 ` Pavel Begunkov
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 \
--in-reply-to=1ef0d539e1eb74d9aa0456d07198ecaadaf1b6a4.1660635140.git.asml.silence@gmail.com \
[email protected] \
[email protected] \
[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