From: lizetao <[email protected]>
To: Dmitry Antipov <[email protected]>, Jens Axboe <[email protected]>
Cc: Jeff Moyer <[email protected]>,
"[email protected]" <[email protected]>
Subject: RE: [PATCH] io_uring: avoid implicit conversion to ktime_t
Date: Fri, 14 Feb 2025 08:08:46 +0000 [thread overview]
Message-ID: <[email protected]> (raw)
In-Reply-To: <[email protected]>
Hi,
> -----Original Message-----
> From: Dmitry Antipov <[email protected]>
> Sent: Friday, February 14, 2025 3:40 PM
> To: Jens Axboe <[email protected]>
> Cc: Jeff Moyer <[email protected]>; [email protected]; Dmitry
> Antipov <[email protected]>
> Subject: [PATCH] io_uring: avoid implicit conversion to ktime_t
>
> In 'io_get_ext_arg()', do not assume that 'min_wait_usec' of 'struct
> io_uring_getevents_arg' (which is '__u32') multiplied by NSEC_PER_USEC may
> be implicitly converted to 'ktime_t' but use the convenient 'us_to_ktime()'
> helper instead. Compile tested only.
>
> Suggested-by: Jeff Moyer <[email protected]>
> Signed-off-by: Dmitry Antipov <[email protected]>
> ---
> I didn't add Fixes: as per Jeff's remark at https://lore.kernel.org/io-
> uring/[email protected]/T/#t;
> if you think that it should be, most likely they are:
>
> aa00f67adc2c ("io_uring: add support for fixed wait regions")
> 7ed9e09e2d13 ("io_uring: wire up min batch wake timeout")
> ---
> io_uring/io_uring.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/io_uring/io_uring.c b/io_uring/io_uring.c index
> 7f2500aca95c..f73555e981fa 100644
> --- a/io_uring/io_uring.c
> +++ b/io_uring/io_uring.c
> @@ -3257,7 +3257,7 @@ static int io_get_ext_arg(struct io_ring_ctx *ctx,
> unsigned flags,
>
> if (w->flags & ~IORING_REG_WAIT_TS)
> return -EINVAL;
> - ext_arg->min_time = READ_ONCE(w->min_wait_usec) *
> NSEC_PER_USEC;
> + ext_arg->min_time = us_to_ktime(READ_ONCE(w-
> >min_wait_usec));
> ext_arg->sig = u64_to_user_ptr(READ_ONCE(w->sigmask));
> ext_arg->argsz = READ_ONCE(w->sigmask_sz);
> if (w->flags & IORING_REG_WAIT_TS) {
> @@ -3286,7 +3286,7 @@ static int io_get_ext_arg(struct io_ring_ctx *ctx,
> unsigned flags,
> if (copy_from_user(&arg, uarg, sizeof(arg)))
> return -EFAULT;
> #endif
> - ext_arg->min_time = arg.min_wait_usec * NSEC_PER_USEC;
> + ext_arg->min_time = us_to_ktime(arg.min_wait_usec);
> ext_arg->sig = u64_to_user_ptr(arg.sigmask);
> ext_arg->argsz = arg.sigmask_sz;
> if (arg.ts) {
> --
> 2.48.1
>
>
Reviewed-by: Li Zetao <[email protected]>
---
Li Zetao
next prev parent reply other threads:[~2025-02-14 8:08 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-02-14 7:39 [PATCH] io_uring: avoid implicit conversion to ktime_t Dmitry Antipov
2025-02-14 8:08 ` lizetao [this message]
2025-02-14 17:34 ` 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] \
[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