Re: [PATCH] workqueue: Use active mask for new worker when pool is DISASSOCIATED

From: Lai Jiangshan
Date: Mon Aug 01 2022 - 00:00:56 EST


On Sat, Jul 30, 2022 at 12:19 PM Schspa Shi <schspa@xxxxxxxxx> wrote:
>
>
> Peter Zijlstra <peterz@xxxxxxxxxxxxx> writes:
>
> > On Wed, Jul 13, 2022 at 05:52:58PM +0800, Lai Jiangshan wrote:
> >>
> >>
> >> CC Peter.
> >> Peter has changed the CPU binding code in workqueue.c.
> >
> > [ 1622.829091] WARNING: CPU: 3 PID: 31 at kernel/sched/core.c:7756 sched_cpu_dying+0x74/0x204
> > [ 1622.829374] CPU: 3 PID: 31 Comm: migration/3 Tainted: P O 5.10.59-rt52 #2
> > ^^^^^^^^^^^^^^^^^^^^^
> >
> > I think we can ignore this as being some ancient kernel. Please try
> > something recent.
>
> Hi peter:
>
> I spent a few days writing a test case and reproduced the problem on
> kernel 5.19. I think it's time for us to review the V3 patch for a fix.
>
> The V3 patch is at
> https://lore.kernel.org/all/20220714031645.28004-1-schspa@xxxxxxxxx/
> Please help to review it.

Because of the implementation of is_cpu_allowed(),
I am still suspicious about how the newly created worker can be woken
up in the dying cpu since it has no KTHREAD_IS_PER_CPU set.

Is it a dying cpu when onlining a CPU fails? I think balance_push
is not set in this case when it fails at some point during online.
But I haven't looked into the details and linked the clues.


>
> Test branch as:
> https://git.kernel.org/pub/scm/linux/kernel/git/rt/linux-rt-devel.git/tag/?h=v5.19-rc8-rt8
>

Can it only be triggered in the rt kernel?

> I think this code is new enough to demonstrate that the problem persists.
>
> The log as fellowing:
>
> [ 3103.198684] ------------[ cut here ]------------
> [ 3103.198684] Dying CPU not properly vacated!
> [ 3103.198684] WARNING: CPU: 1 PID: 23 at kernel/sched/core.c:9575 sched_cpu_dying.cold+0xc/0xc3
> [ 3103.198684] Modules linked in: work_test(O)

Could you give me the code of this module?