Re: [PATCH] workqueue: missing NOT while checking if Workqueue is offline

From: Geraldo Nascimento
Date: Sat May 28 2022 - 21:26:00 EST


On Sat, May 28, 2022 at 05:07:08PM -0300, Geraldo Nascimento wrote:
> Greetings,
>

Hi, again,

> This is a one-character patch but very important as the kernel workqueue
> __cancel_work_timer will cancel active work without the NOT operator
> added.
>
> During early boot wq_online is false so with the NOT added it will evaluate
> to true. Conversely, after boot is done, workqueue

I meant wq_online. After boot, wq_online will evaluate to true, current
code might as well have an if (true) there. I hurried up the patch
because if I'm right this is a major show stopper to drivers that make
use of cancel_work_timer(). I hit it through amdgpu in conjuction with amdkfd.

> is now true and we want
> it to evaluate to false because otherwise it will cancel important work.
>
> Signed-off-by: Geraldo Nascimento <geraldogabriel@xxxxxxxxx>
>
> --- workqueue.c 2022-05-28 16:54:12.024176123 -0300
> +++ workqueue.c 2022-05-28 16:54:37.698176135 -0300
> @@ -3158,7 +3158,7 @@ static bool __cancel_work_timer(struct w
> * This allows canceling during early boot. We know that @work
> * isn't executing.
> */
> - if (wq_online)
> + if (!wq_online)
> __flush_work(work, true);
>
> clear_work_data(work);