[RESEND PATCH v2 05/19] io_uring: Remove redundant hrtimer's callback function setup

Nam Cao posted 19 patches 3 weeks, 3 days ago
[RESEND PATCH v2 05/19] io_uring: Remove redundant hrtimer's callback function setup
Posted by Nam Cao 3 weeks, 3 days ago
The IORING_OP_TIMEOUT command uses hrtimer underneath. The timer's callback
function is setup in io_timeout(), and then the callback function is setup
again when the timer is rearmed.

Since the callback function is the same for both cases, the latter setup is
redundant, therefore remove it.

Signed-off-by: Nam Cao <namcao@linutronix.de>
Cc: Jens Axboe <axboe@kernel.dk>
---
 io_uring/timeout.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/io_uring/timeout.c b/io_uring/timeout.c
index 9973876d91b0..2ffe5e1dc68a 100644
--- a/io_uring/timeout.c
+++ b/io_uring/timeout.c
@@ -76,7 +76,6 @@ static void io_timeout_complete(struct io_kiocb *req, struct io_tw_state *ts)
 			/* re-arm timer */
 			spin_lock_irq(&ctx->timeout_lock);
 			list_add(&timeout->list, ctx->timeout_list.prev);
-			data->timer.function = io_timeout_fn;
 			hrtimer_start(&data->timer, timespec64_to_ktime(data->ts), data->mode);
 			spin_unlock_irq(&ctx->timeout_lock);
 			return;
-- 
2.39.5
Re: [RESEND PATCH v2 05/19] io_uring: Remove redundant hrtimer's callback function setup
Posted by Jens Axboe 3 weeks, 3 days ago
On 10/31/24 9:14 AM, Nam Cao wrote:
> The IORING_OP_TIMEOUT command uses hrtimer underneath. The timer's callback
> function is setup in io_timeout(), and then the callback function is setup
> again when the timer is rearmed.
> 
> Since the callback function is the same for both cases, the latter setup is
> redundant, therefore remove it.
> 
> Signed-off-by: Nam Cao <namcao@linutronix.de>
> Cc: Jens Axboe <axboe@kernel.dk>
> ---
>  io_uring/timeout.c | 1 -
>  1 file changed, 1 deletion(-)
> 
> diff --git a/io_uring/timeout.c b/io_uring/timeout.c
> index 9973876d91b0..2ffe5e1dc68a 100644
> --- a/io_uring/timeout.c
> +++ b/io_uring/timeout.c
> @@ -76,7 +76,6 @@ static void io_timeout_complete(struct io_kiocb *req, struct io_tw_state *ts)
>  			/* re-arm timer */
>  			spin_lock_irq(&ctx->timeout_lock);
>  			list_add(&timeout->list, ctx->timeout_list.prev);
> -			data->timer.function = io_timeout_fn;
>  			hrtimer_start(&data->timer, timespec64_to_ktime(data->ts), data->mode);
>  			spin_unlock_irq(&ctx->timeout_lock);
>  			return;

Should be fine, io_timeout_complete() is only used for non-linked
timeouts.

Reviewed-by: Jens Axboe <axboe@kernel.dk:

-- 
Jens Axboe