* [PATCH] io_uring/msg_ring: Pass custom flags to the cqe
@ 2023-01-03 16:05 leitao
2023-01-09 17:33 ` Jens Axboe
0 siblings, 1 reply; 2+ messages in thread
From: leitao @ 2023-01-03 16:05 UTC (permalink / raw)
To: dylany, axboe, asml.silence, io-uring; +Cc: leit, linux-kernel, Breno Leitao
From: Breno Leitao <[email protected]>
This patch adds a new flag (IORING_MSG_RING_FLAGS_PASS) in the message
ring operations (IORING_OP_MSG_RING). This new flag enables the sender
to specify custom flags, which will be copied over to cqe->flags in the
receiving ring. These custom flags should be specified using the
sqe->file_index field.
This mechanism provides additional flexibility when sending messages
between rings.
The changes on liburing side could be seen at
https://github.com/axboe/liburing/pull/765
Signed-off-by: Breno Leitao <[email protected]>
---
include/uapi/linux/io_uring.h | 2 ++
io_uring/msg_ring.c | 23 +++++++++++++++++++----
2 files changed, 21 insertions(+), 4 deletions(-)
diff --git a/include/uapi/linux/io_uring.h b/include/uapi/linux/io_uring.h
index 2780bce62faf..636a4c2c1294 100644
--- a/include/uapi/linux/io_uring.h
+++ b/include/uapi/linux/io_uring.h
@@ -347,6 +347,8 @@ enum {
* applicable for IORING_MSG_DATA, obviously.
*/
#define IORING_MSG_RING_CQE_SKIP (1U << 0)
+/* Pass through the flags from sqe->file_index to cqe->flags */
+#define IORING_MSG_RING_FLAGS_PASS (1U << 1)
/*
* IO completion data structure (Completion Queue Entry)
diff --git a/io_uring/msg_ring.c b/io_uring/msg_ring.c
index 2d3cd945a531..dc233f72a541 100644
--- a/io_uring/msg_ring.c
+++ b/io_uring/msg_ring.c
@@ -13,6 +13,11 @@
#include "filetable.h"
#include "msg_ring.h"
+
+/* All valid masks for MSG_RING */
+#define IORING_MSG_RING_MASK (IORING_MSG_RING_CQE_SKIP | \
+ IORING_MSG_RING_FLAGS_PASS)
+
struct io_msg {
struct file *file;
struct file *src_file;
@@ -21,7 +26,10 @@ struct io_msg {
u32 len;
u32 cmd;
u32 src_fd;
- u32 dst_fd;
+ union {
+ u32 dst_fd;
+ u32 cqe_flags;
+ };
u32 flags;
};
@@ -57,10 +65,17 @@ static int io_msg_ring_data(struct io_kiocb *req)
{
struct io_ring_ctx *target_ctx = req->file->private_data;
struct io_msg *msg = io_kiocb_to_cmd(req, struct io_msg);
+ u32 flags = 0;
- if (msg->src_fd || msg->dst_fd || msg->flags)
+ if (msg->src_fd || msg->flags & ~IORING_MSG_RING_FLAGS_PASS)
return -EINVAL;
+ if (!(msg->flags & IORING_MSG_RING_FLAGS_PASS) && msg->dst_fd)
+ return -EINVAL;
+
+ if (msg->flags & IORING_MSG_RING_FLAGS_PASS)
+ flags = msg->cqe_flags;
+
if (target_ctx->task_complete && current != target_ctx->submitter_task) {
init_task_work(&msg->tw, io_msg_tw_complete);
if (task_work_add(target_ctx->submitter_task, &msg->tw,
@@ -71,7 +86,7 @@ static int io_msg_ring_data(struct io_kiocb *req)
return IOU_ISSUE_SKIP_COMPLETE;
}
- if (io_post_aux_cqe(target_ctx, msg->user_data, msg->len, 0))
+ if (io_post_aux_cqe(target_ctx, msg->user_data, msg->len, flags))
return 0;
return -EOVERFLOW;
@@ -207,7 +222,7 @@ int io_msg_ring_prep(struct io_kiocb *req, const struct io_uring_sqe *sqe)
msg->src_fd = READ_ONCE(sqe->addr3);
msg->dst_fd = READ_ONCE(sqe->file_index);
msg->flags = READ_ONCE(sqe->msg_ring_flags);
- if (msg->flags & ~IORING_MSG_RING_CQE_SKIP)
+ if (msg->flags & ~IORING_MSG_RING_MASK)
return -EINVAL;
return 0;
--
2.30.2
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] io_uring/msg_ring: Pass custom flags to the cqe
2023-01-03 16:05 [PATCH] io_uring/msg_ring: Pass custom flags to the cqe leitao
@ 2023-01-09 17:33 ` Jens Axboe
0 siblings, 0 replies; 2+ messages in thread
From: Jens Axboe @ 2023-01-09 17:33 UTC (permalink / raw)
To: dylany, asml.silence, io-uring, leitao; +Cc: leit, linux-kernel
On Tue, 03 Jan 2023 08:05:07 -0800, [email protected] wrote:
> This patch adds a new flag (IORING_MSG_RING_FLAGS_PASS) in the message
> ring operations (IORING_OP_MSG_RING). This new flag enables the sender
> to specify custom flags, which will be copied over to cqe->flags in the
> receiving ring. These custom flags should be specified using the
> sqe->file_index field.
>
> This mechanism provides additional flexibility when sending messages
> between rings.
>
> [...]
Applied, thanks!
[1/1] io_uring/msg_ring: Pass custom flags to the cqe
commit: 5ab697ff917844acbd898009261fb0c2f0faec54
Best regards,
--
Jens Axboe
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2023-01-09 17:33 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-01-03 16:05 [PATCH] io_uring/msg_ring: Pass custom flags to the cqe leitao
2023-01-09 17:33 ` Jens Axboe
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox