Re: [PATCH v2] workqueue: Remove the warning in wq_worker_sleeping()

From: Tejun Heo
Date: Fri Apr 03 2020 - 10:53:30 EST


Hello,

On Sat, Mar 28, 2020 at 12:29:59AM +0100, Sebastian Andrzej Siewior wrote:
> The kernel test robot triggered a warning with the following race:
> task-ctx A interrupt-ctx B
> worker
> -> process_one_work()
> -> work_item()
> -> schedule();
> -> sched_submit_work()
> -> wq_worker_sleeping()
> -> ->sleeping = 1
> atomic_dec_and_test(nr_running)
> __schedule(); *interrupt*
> async_page_fault()
> -> local_irq_enable();
> -> schedule();
> -> sched_submit_work()
> -> wq_worker_sleeping()
> -> if (WARN_ON(->sleeping)) return
> -> __schedule()
> -> sched_update_worker()
> -> wq_worker_running()
> -> atomic_inc(nr_running);
> -> ->sleeping = 0;
>
> -> sched_update_worker()
> -> wq_worker_running()
> if (!->sleeping) return
>
> In this context the warning is pointless everything is fine.

This is not a usual control flow, right? Can we annotate this case specifically
instead of weakening santiy check for generic cases?

Thanks.

--
tejun