From: Pavel Begunkov <asml.silence@gmail.com>
To: io-uring@vger.kernel.org
Cc: asml.silence@gmail.com, axboe@kernel.dk
Subject: [PATCH v2 1/1] io_uring/net: separate notification user_data
Date: Mon, 16 Feb 2026 17:20:44 +0000 [thread overview]
Message-ID: <5f4edc94666e8b5e895ec0d212d1e0ceb8ca0165.1771261811.git.asml.silence@gmail.com> (raw)
People previously asked for the notification CQE to have a different
user_data value from the main request completion. It's useful to
separate buffer and request handling logic and avoid separately
refcounting the request.
Introduce a new flag IORING_SEND_ZC_NOTIF_USER_DATA. If set, the
notification user_data will contain the value from sqe->addr3 instead of
inheriting it from the original request.
Note, it doesn't change the rules for when the user can expect a
notification CQE, and it should still check the IORING_CQE_F_MORE flag.
Signed-off-by: Pavel Begunkov <asml.silence@gmail.com>
---
include/uapi/linux/io_uring.h | 6 ++++++
io_uring/net.c | 13 +++++++++++--
2 files changed, 17 insertions(+), 2 deletions(-)
diff --git a/include/uapi/linux/io_uring.h b/include/uapi/linux/io_uring.h
index 6750c383a2ab..e3648147b98e 100644
--- a/include/uapi/linux/io_uring.h
+++ b/include/uapi/linux/io_uring.h
@@ -425,6 +425,11 @@ enum io_uring_op {
*
* IORING_SEND_VECTORIZED If set, SEND[_ZC] will take a pointer to a io_vec
* to allow vectorized send operations.
+ *
+ * IORING_SEND_ZC_NOTIF_USER_DATA
+ * If set, the notification CQE user_data will be
+ * set to the value specified in the addr3 field
+ * of the SQE.
*/
#define IORING_RECVSEND_POLL_FIRST (1U << 0)
#define IORING_RECV_MULTISHOT (1U << 1)
@@ -432,6 +437,7 @@ enum io_uring_op {
#define IORING_SEND_ZC_REPORT_USAGE (1U << 3)
#define IORING_RECVSEND_BUNDLE (1U << 4)
#define IORING_SEND_VECTORIZED (1U << 5)
+#define IORING_SEND_ZC_NOTIF_USER_DATA (1U << 6)
/*
* cqe.res for IORING_CQE_F_NOTIF if
diff --git a/io_uring/net.c b/io_uring/net.c
index 8576c6cb2236..79c424717f9b 100644
--- a/io_uring/net.c
+++ b/io_uring/net.c
@@ -1317,7 +1317,9 @@ void io_send_zc_cleanup(struct io_kiocb *req)
}
}
-#define IO_ZC_FLAGS_COMMON (IORING_RECVSEND_POLL_FIRST | IORING_RECVSEND_FIXED_BUF)
+#define IO_ZC_FLAGS_COMMON (IORING_RECVSEND_POLL_FIRST |\
+ IORING_RECVSEND_FIXED_BUF |\
+ IORING_SEND_ZC_NOTIF_USER_DATA)
#define IO_ZC_FLAGS_VALID (IO_ZC_FLAGS_COMMON | IORING_SEND_ZC_REPORT_USAGE | \
IORING_SEND_VECTORIZED)
@@ -1331,7 +1333,7 @@ int io_send_zc_prep(struct io_kiocb *req, const struct io_uring_sqe *sqe)
zc->done_io = 0;
- if (unlikely(READ_ONCE(sqe->__pad2[0]) || READ_ONCE(sqe->addr3)))
+ if (unlikely(READ_ONCE(sqe->__pad2[0])))
return -EINVAL;
/* we don't support IOSQE_CQE_SKIP_SUCCESS just yet */
if (req->flags & REQ_F_CQE_SKIP)
@@ -1358,6 +1360,13 @@ int io_send_zc_prep(struct io_kiocb *req, const struct io_uring_sqe *sqe)
}
}
+ if (zc->flags & IORING_SEND_ZC_NOTIF_USER_DATA) {
+ notif->cqe.user_data = READ_ONCE(sqe->addr3);
+ } else {
+ if (READ_ONCE(sqe->addr3))
+ return -EINVAL;
+ }
+
zc->len = READ_ONCE(sqe->len);
zc->msg_flags = READ_ONCE(sqe->msg_flags) | MSG_NOSIGNAL | MSG_ZEROCOPY;
req->buf_index = READ_ONCE(sqe->buf_index);
--
2.52.0
reply other threads:[~2026-02-16 17:20 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=5f4edc94666e8b5e895ec0d212d1e0ceb8ca0165.1771261811.git.asml.silence@gmail.com \
--to=asml.silence@gmail.com \
--cc=axboe@kernel.dk \
--cc=io-uring@vger.kernel.org \
/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