Re: [PATCH -tip V3 3/8] workqueue: introduce wq_online_cpumask
From: Lai Jiangshan
Date: Mon Jan 04 2021 - 21:42:17 EST
On Mon, Jan 4, 2021 at 9:56 PM Peter Zijlstra <peterz@xxxxxxxxxxxxx> wrote:
>
> On Sat, Dec 26, 2020 at 10:51:11AM +0800, Lai Jiangshan wrote:
> > From: Lai Jiangshan <laijs@xxxxxxxxxxxxxxxxx>
> >
> > wq_online_cpumask is the cached result of cpu_online_mask with the
> > going-down cpu cleared.
>
> You can't use cpu_active_mask ?
When a cpu is going out:
(cpu_active_mask is not protected by workqueue mutexs.)
create_worker() for unbound pool | cpu offlining
check cpu_active_mask |
| remove bit from cpu_active_mask
| no cpu in pool->attrs->cpumask is active
set pool->attrs->cpumask to worker|
and hit the warning
And when a cpu is onlining, there may be some workers which were just created
after the workqueue hotplug callback is finished but before cpu_active_mask
was updated. workqueue has not call back after cpu_active_mask updated and
these workers' cpumask is not updated.
For percpu workers, these problems can be handled with the help of
POOL_DISASSOCIATED which is protected by workqueue mutexs and the
help of sched/core.c which doesn't warn when per-cpu-kthread.
For unbound workers, the way to handle it without using wq_online_cpumask
is much more complex when a cpu is going out.