* [PATCH] io_uring: do not assume that ktime_t is equal to nanoseconds
@ 2025-02-13 15:44 Dmitry Antipov
2025-02-13 18:13 ` Jens Axboe
2025-02-13 19:13 ` Jeff Moyer
0 siblings, 2 replies; 3+ messages in thread
From: Dmitry Antipov @ 2025-02-13 15:44 UTC (permalink / raw)
To: Jens Axboe; +Cc: Pavel Begunkov, io-uring, Dmitry Antipov
In 'io_cqring_schedule_timeout()', do not assume that 'ktime_t' is
equal to nanoseconds and prefer 'ktime_add()' over 'ktime_add_ns()'
to sum two 'ktime_t' values. Compile tested only.
Fixes: 1100c4a2656d ("io_uring: add support for batch wait timeout")
Signed-off-by: Dmitry Antipov <[email protected]>
---
io_uring/io_uring.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/io_uring/io_uring.c b/io_uring/io_uring.c
index ceacf6230e34..7f2500aca95c 100644
--- a/io_uring/io_uring.c
+++ b/io_uring/io_uring.c
@@ -2434,7 +2434,7 @@ static int io_cqring_schedule_timeout(struct io_wait_queue *iowq,
ktime_t timeout;
if (iowq->min_timeout) {
- timeout = ktime_add_ns(iowq->min_timeout, start_time);
+ timeout = ktime_add(iowq->min_timeout, start_time);
hrtimer_setup_on_stack(&iowq->t, io_cqring_min_timer_wakeup, clock_id,
HRTIMER_MODE_ABS);
} else {
--
2.48.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] io_uring: do not assume that ktime_t is equal to nanoseconds
2025-02-13 15:44 [PATCH] io_uring: do not assume that ktime_t is equal to nanoseconds Dmitry Antipov
@ 2025-02-13 18:13 ` Jens Axboe
2025-02-13 19:13 ` Jeff Moyer
1 sibling, 0 replies; 3+ messages in thread
From: Jens Axboe @ 2025-02-13 18:13 UTC (permalink / raw)
To: Dmitry Antipov; +Cc: Pavel Begunkov, io-uring
On Thu, 13 Feb 2025 18:44:52 +0300, Dmitry Antipov wrote:
> In 'io_cqring_schedule_timeout()', do not assume that 'ktime_t' is
> equal to nanoseconds and prefer 'ktime_add()' over 'ktime_add_ns()'
> to sum two 'ktime_t' values. Compile tested only.
>
>
Applied, thanks!
[1/1] io_uring: do not assume that ktime_t is equal to nanoseconds
commit: 9bdc384a837b366c2a83bdcfbd97584ceba442c6
Best regards,
--
Jens Axboe
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] io_uring: do not assume that ktime_t is equal to nanoseconds
2025-02-13 15:44 [PATCH] io_uring: do not assume that ktime_t is equal to nanoseconds Dmitry Antipov
2025-02-13 18:13 ` Jens Axboe
@ 2025-02-13 19:13 ` Jeff Moyer
1 sibling, 0 replies; 3+ messages in thread
From: Jeff Moyer @ 2025-02-13 19:13 UTC (permalink / raw)
To: Dmitry Antipov; +Cc: Jens Axboe, Pavel Begunkov, io-uring
Dmitry Antipov <[email protected]> writes:
> In 'io_cqring_schedule_timeout()', do not assume that 'ktime_t' is
> equal to nanoseconds and prefer 'ktime_add()' over 'ktime_add_ns()'
> to sum two 'ktime_t' values. Compile tested only.
>
> Fixes: 1100c4a2656d ("io_uring: add support for batch wait timeout")
> Signed-off-by: Dmitry Antipov <[email protected]>
> ---
> io_uring/io_uring.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/io_uring/io_uring.c b/io_uring/io_uring.c
> index ceacf6230e34..7f2500aca95c 100644
> --- a/io_uring/io_uring.c
> +++ b/io_uring/io_uring.c
> @@ -2434,7 +2434,7 @@ static int io_cqring_schedule_timeout(struct io_wait_queue *iowq,
> ktime_t timeout;
>
> if (iowq->min_timeout) {
> - timeout = ktime_add_ns(iowq->min_timeout, start_time);
> + timeout = ktime_add(iowq->min_timeout, start_time);
I don't think this solves the issue stated in the commit message. Look
at where the min_timeout comes from, in io_get_ext_arg:
ext_arg->min_time = READ_ONCE(w->min_wait_usec) * NSEC_PER_USEC;
Perhaps that should be:
ext_arg->min_time = us_to_ktime(READ_ONCE(w->min_wait_usec));
I also don't know whether this warrants a fixes tag, given it doesn't
change any behavior.
Cheers,
Jeff
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2025-02-13 19:14 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-02-13 15:44 [PATCH] io_uring: do not assume that ktime_t is equal to nanoseconds Dmitry Antipov
2025-02-13 18:13 ` Jens Axboe
2025-02-13 19:13 ` Jeff Moyer
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox