* [PATCH 1/1] io_uring: compile out compat param passing
@ 2025-02-23 17:43 Pavel Begunkov
2025-02-24 2:56 ` Anuj gupta
0 siblings, 1 reply; 3+ messages in thread
From: Pavel Begunkov @ 2025-02-23 17:43 UTC (permalink / raw)
To: io-uring; +Cc: asml.silence
Even when COMPAT is compiled out, we still have to pass
ctx->compat to __import_iovec(). Replace the read with an indirection
with a constant when the kernel doesn't support compat.
Signed-off-by: Pavel Begunkov <[email protected]>
---
io_uring/io_uring.h | 5 +++++
io_uring/rw.c | 4 ++--
2 files changed, 7 insertions(+), 2 deletions(-)
diff --git a/io_uring/io_uring.h b/io_uring/io_uring.h
index 650f81dac5d0..da71067a10bc 100644
--- a/io_uring/io_uring.h
+++ b/io_uring/io_uring.h
@@ -147,6 +147,11 @@ static inline void io_lockdep_assert_cq_locked(struct io_ring_ctx *ctx)
#endif
}
+static inline bool io_is_compat(struct io_ring_ctx *ctx)
+{
+ return IS_ENABLED(CONFIG_COMPAT) && ctx->compat;
+}
+
static inline void io_req_task_work_add(struct io_kiocb *req)
{
__io_req_task_work_add(req, 0);
diff --git a/io_uring/rw.c b/io_uring/rw.c
index 16f12f94943f..c3849a370a2e 100644
--- a/io_uring/rw.c
+++ b/io_uring/rw.c
@@ -75,7 +75,7 @@ static int io_iov_buffer_select_prep(struct io_kiocb *req)
return -EINVAL;
#ifdef CONFIG_COMPAT
- if (req->ctx->compat)
+ if (io_is_compat(req->ctx))
return io_iov_compat_buffer_select_prep(rw);
#endif
@@ -120,7 +120,7 @@ static int __io_import_iovec(int ddir, struct io_kiocb *req,
nr_segs = 1;
}
ret = __import_iovec(ddir, buf, sqe_len, nr_segs, &iov, &io->iter,
- req->ctx->compat);
+ io_is_compat(req->ctx));
if (unlikely(ret < 0))
return ret;
if (iov) {
--
2.48.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH 1/1] io_uring: compile out compat param passing
2025-02-23 17:43 [PATCH 1/1] io_uring: compile out compat param passing Pavel Begunkov
@ 2025-02-24 2:56 ` Anuj gupta
2025-02-24 12:16 ` Pavel Begunkov
0 siblings, 1 reply; 3+ messages in thread
From: Anuj gupta @ 2025-02-24 2:56 UTC (permalink / raw)
To: Pavel Begunkov; +Cc: io-uring
> #ifdef CONFIG_COMPAT
> - if (req->ctx->compat)
> + if (io_is_compat(req->ctx))
> return io_iov_compat_buffer_select_prep(rw);
> #endif
Should the #ifdef CONFIG_COMPAT be removed here since io_is_compat() already
accounts for it?
> @@ -120,7 +120,7 @@ static int __io_import_iovec(int ddir, struct io_kiocb *req,
> nr_segs = 1;
> }
> ret = __import_iovec(ddir, buf, sqe_len, nr_segs, &iov, &io->iter,
> - req->ctx->compat);
> + io_is_compat(req->ctx));
Should we also update other places that use ctx->compat (e.g., rsrc.c, net.c,
uring_cmd.c) to use the new io_is_compat() helper for consistency?
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH 1/1] io_uring: compile out compat param passing
2025-02-24 2:56 ` Anuj gupta
@ 2025-02-24 12:16 ` Pavel Begunkov
0 siblings, 0 replies; 3+ messages in thread
From: Pavel Begunkov @ 2025-02-24 12:16 UTC (permalink / raw)
To: Anuj gupta; +Cc: io-uring
On 2/24/25 02:56, Anuj gupta wrote:
>> #ifdef CONFIG_COMPAT
>> - if (req->ctx->compat)
>> + if (io_is_compat(req->ctx))
>> return io_iov_compat_buffer_select_prep(rw);
>> #endif
>
> Should the #ifdef CONFIG_COMPAT be removed here since io_is_compat() already
> accounts for it?
We can if same is done for io_iov_compat_buffer_select_prep() and
we can prove it doesn't use anything compiled out for !COMPAT (which
seems so).
>> @@ -120,7 +120,7 @@ static int __io_import_iovec(int ddir, struct io_kiocb *req,
>> nr_segs = 1;
>> }
>> ret = __import_iovec(ddir, buf, sqe_len, nr_segs, &iov, &io->iter,
>> - req->ctx->compat);
>> + io_is_compat(req->ctx));
>
> Should we also update other places that use ctx->compat (e.g., rsrc.c, net.c,
> uring_cmd.c) to use the new io_is_compat() helper for consistency?
That would be a wider messier change split in multiple patches, which
I was thinking to avoid. This patch is a good first step, and once
merged future changes can be made independently.
Let me see what I can do, but I don't want touching rsrc.c for now
to avoid unnecessary changes. And then more can be done to get more
code out of ifdef and let the compiler optimise it out.
--
Pavel Begunkov
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2025-02-24 12:15 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-02-23 17:43 [PATCH 1/1] io_uring: compile out compat param passing Pavel Begunkov
2025-02-24 2:56 ` Anuj gupta
2025-02-24 12:16 ` Pavel Begunkov
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox