Re: [PATCH] smp: Fix missed destroy_work_on_stack() calls in smp_call_on_cpu()

From: Paul E. McKenney
Date: Tue Jul 09 2024 - 13:41:35 EST


On Thu, Jul 04, 2024 at 02:52:13PM +0800, Zqiang wrote:
> For builts with CONFIG_DEBUG_OBJECTS_WORK=y kernels, the sscs.work
> defined using INIT_WORK_ONSTACK() will be initialized by
> debug_object_init_on_stack() for debug check in __init_work().
> This commit therefore invoke destroy_work_on_stack() to free
> sscs.work debug objects before smp_call_on_cpu() returns.
>
> Signed-off-by: Zqiang <qiang.zhang1211@xxxxxxxxx>

I have queued this for testing. My guess is that it should go to
mainline some other way, so:

Tested-by: Paul E. McKenney <paulmck@xxxxxxxxxx>

> ---
> kernel/smp.c | 1 +
> 1 file changed, 1 insertion(+)
>
> diff --git a/kernel/smp.c b/kernel/smp.c
> index cc13e73a887c..61f10f982341 100644
> --- a/kernel/smp.c
> +++ b/kernel/smp.c
> @@ -1135,6 +1135,7 @@ int smp_call_on_cpu(unsigned int cpu, int (*func)(void *), void *par, bool phys)
>
> queue_work_on(cpu, system_wq, &sscs.work);
> wait_for_completion(&sscs.done);
> + destroy_work_on_stack(&sscs.work);
>
> return sscs.ret;
> }
> --
> 2.17.1
>