Re: [PATCH -tip V3 8/8] workqueue: Fix affinity of kworkers when attaching into pool
From: Lai Jiangshan
Date: Tue Dec 29 2020 - 05:14:50 EST
On Tue, Dec 29, 2020 at 6:06 PM Hillf Danton <hdanton@xxxxxxxx> wrote:
>
> On Sat, 26 Dec 2020 10:51:16 +0800
> > From: Lai Jiangshan <laijs@xxxxxxxxxxxxxxxxx>
> >
> > When worker_attach_to_pool() is called, we should not put the workers
> > to pool->attrs->cpumask when there is not CPU online in it.
> >
> > We have to use wq_online_cpumask in worker_attach_to_pool() to check
> > if pool->attrs->cpumask is valid rather than cpu_online_mask or
> > cpu_active_mask due to gaps between stages in cpu hot[un]plug.
>
> In 5/8 pool->attrs->cpumask is not restored to avoid triggering
> the warning added in e9d867a67fd03ccc ("sched: Allow
> per-cpu kernel threads to run on online && !active"), is it likely
> needed to repeat that trick here?
> Is the above gap no longer existing here at the presence of
> wq_online_cpumask?
It still exists. When online, wq_online_cpumask is always
cpu_online_mask, no thing changed.
An alternative way is to move the code into a work item, which adds
the proper protection against cpu hotlug and does the work.
I don't want to add too much complex in this patchset.