Re: [PATCH v2] workqueue: Remove the warning in wq_worker_sleeping()
From: Daniel Jordan
Date: Fri Apr 03 2020 - 13:47:16 EST
Hi Sebastian,
On Sat, Mar 28, 2020 at 12:29:59AM +0100, Sebastian Andrzej Siewior wrote:
> v1âv2: - Drop the warning instead of using cmpxchg_local().
> Tglx pointed out that wq_worker_sleeping() is already invoked
> with disabled preemption so the race described can not happen.
I guess you mean this race:
> However, if the interrupt occurs in wq_worker_sleeping() between reading and
> setting `sleeping' i.e.
>
> | if (WARN_ON_ONCE(worker->sleeping))
> | return;
> *interrupt*
> | worker->sleeping = 1;
>
> then pool->nr_running will be decremented twice in wq_worker_sleeping()
> but it will be incremented only once in wq_worker_running().
Why would preemption prevent it? Interrupts are still enabled.
What am I missing? :-)