Skip to contentSkip to conversation

smp: Fix missed destroy_work_on_stack() calls in smp_call_on_cpu()

PATCH Applied Zqiang 3 participants 4 messages Jul 4, 2024 – Jul 10, 2024

lore
Share & tools
lore

Zqiang

author
#0 lore raw

PATCH 1/1 smp: Fix missed destroy_work_on_stack() calls in smp_call_on_cpu()

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.

---
 kernel/smp.c | 1 +
 1 file changed, 1 insertion(+)
kernel/smp.c +1 -0
index cc13e73a887c..61f10f982341 100644
@@ -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;
 }
Signature · 1 line
2.17.1
Tested-by on v1 1/1
#1 lore raw
Quoted 7 lines · Zqiang

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.

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

Quoted 19 lines
---
 kernel/smp.c | 1 +
 1 file changed, 1 insertion(+)
kernel/smp.c +1 -0
index cc13e73a887c..61f10f982341 100644
@@ -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;
 }
Signature · 1 line
2.17.1
author
#2 lore raw
Quoted 8 lines · Zqiang
Quoted 6 lines

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.

Quoted 6 lines
Quoted 1 line

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

Thanks Paul for testing this change ;) .

Quoted 20 lines
Quoted 20 lines
---
 kernel/smp.c | 1 +
 1 file changed, 1 insertion(+)
kernel/smp.c +1 -1
index cc13e73a887c..61f10f982341 100644
@@ -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

merge bot Applied
#3 lore raw

[tip: smp/core] smp: Add missing destroy_work_on_stack() call in smp_call_on_cpu()

In reply to Zqiang
The following commit has been merged into the smp/core branch of tip:

The following commit has been merged into the smp/core branch of tip:

Commit-ID:     77aeb1b685f9db73d276bad4bb30d48505a6fd23
Gitweb:        https://git.kernel.org/tip/77aeb1b685f9db73d276bad4bb30d48505a6fd23
Author:        Zqiang <[email protected]>
AuthorDate:    Thu, 04 Jul 2024 14:52:13 +08:00
Committer:     Thomas Gleixner <[email protected]>
CommitterDate: Wed, 10 Jul 2024 22:40:39 +02:00

smp: Add missing destroy_work_on_stack() call in smp_call_on_cpu()

For CONFIG_DEBUG_OBJECTS_WORK=y kernels sscs.work defined by INIT_WORK_ONSTACK() is initialized by debug_object_init_on_stack() for the debug check in __init_work() to work correctly.

But this lacks the counterpart to remove the tracked object from debug objects again, which will cause a debug object warning once the stack is freed.

Add the missing destroy_work_on_stack() invocation to cure that.

[ tglx: Massaged changelog ]

---
 kernel/smp.c | 1 +
 1 file changed, 1 insertion(+)
kernel/smp.c +1 -0
index 1848357..aaffecd 100644
@@ -1119,6 +1119,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;
 }