Re: [PATCH] irq_work: Replace wait loop with rcuwait_wait_event

From: Frederic Weisbecker
Date: Mon Sep 23 2024 - 17:41:37 EST


Le Thu, Sep 19, 2024 at 11:43:26AM -0400, Steven Davis a écrit :
> The previous implementation of irq_work_sync used a busy-wait
> loop with cpu_relax() to check the status of IRQ work. This
> approach, while functional, could lead to inefficiencies in
> CPU usage.
>
> This commit replaces the busy-wait loop with the rcuwait_wait_event
> mechanism. This change leverages the RCU wait mechanism to handle
> waiting for IRQ work completion more efficiently, improving CPU
> responsiveness and reducing unnecessary CPU usage.
>
> Signed-off-by: Steven Davis <goldside000@xxxxxxxxxxx>
> ---
> kernel/irq_work.c | 3 +--
> 1 file changed, 1 insertion(+), 2 deletions(-)
>
> diff --git a/kernel/irq_work.c b/kernel/irq_work.c
> index 2f4fb336dda1..2b092a1d07a9 100644
> --- a/kernel/irq_work.c
> +++ b/kernel/irq_work.c
> @@ -295,8 +295,7 @@ void irq_work_sync(struct irq_work *work)
> return;
> }
>
> - while (irq_work_is_busy(work))
> - cpu_relax();
> + rcuwait_wait_event(&work->irqwait, !irq_work_is_busy(work), TASK_UNINTERRUPTIBLE);

So you can remove the CONFIG_PREEMPT_RT special case in this function, right?

Thanks.

> }
> EXPORT_SYMBOL_GPL(irq_work_sync);
>
> --
> 2.39.5
>