Skip to contentSkip to conversation

smp: replace use of system_wq with system_percpu_wq

PATCH Applied Marco Crivellari 3 participants 7 messages Nov 10, 2025 – Mar 26

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 smp: replace use of system_wq with system_percpu_wq

Currently if a user enqueues a work item using schedule_delayed_work() the used wq is "system_wq" (per-cpu wq) while queue_delayed_work() use WORK_CPU_UNBOUND (used when a cpu is not specified). The same applies to schedule_work() that is using system_wq and queue_work(), that makes use again of WORK_CPU_UNBOUND.

This lack of consistency cannot be addressed without refactoring the API.

This continues the effort to refactor workqueue APIs, which began with the introduction of new workqueues and a new alloc_workqueue flag in:

commit 128ea9f6ccfb ("workqueue: Add system_percpu_wq and system_dfl_wq") commit 930c2ea566af ("workqueue: Add new WQ_PERCPU flag")

Switch to using system_percpu_wq because system_wq is going away as part of a workqueue restructuring.

---
Changes in v2:
- improved commit log
- rebased on 6.18-rc5

---
 kernel/smp.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
kernel/smp.c +1 -1
index 02f52291fae4..496358eae37c 100644
@@ -1137,7 +1137,7 @@ int smp_call_on_cpu(unsigned int cpu, int (*func)(void *), void *par, bool phys)
 	if (cpu >= nr_cpu_ids || !cpu_online(cpu))
 		return -ENXIO;
 
-	queue_work_on(cpu, system_wq, &sscs.work);
+	queue_work_on(cpu, system_percpu_wq, &sscs.work);
 	wait_for_completion(&sscs.done);
 	destroy_work_on_stack(&sscs.work);
 
Signature · 1 line
2.51.1
#1 lore raw
Quoted 9 lines · Marco Crivellari

[...]

 kernel/smp.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
kernel/smp.c +0 -0
index 02f52291fae4..496358eae37c 100644

kernel/smp.c int smp_call_on_cpu(unsigned int cpu, int (*func)(void *), void *par, bool phys) · line 1143

Quoted 8 lines
kernel/smp.c +1 -1
@@ -1137,7 +1137,7 @@ int smp_call_on_cpu(unsigned int cpu, int (*func)(void *), void *par, bool phys)
        if (cpu >= nr_cpu_ids || !cpu_online(cpu))
                return -ENXIO;
 
-       queue_work_on(cpu, system_wq, &sscs.work);
+       queue_work_on(cpu, system_percpu_wq, &sscs.work);
        wait_for_completion(&sscs.done);
        destroy_work_on_stack(&sscs.work);
 

Gentle ping.

Thanks!

Signature · 3 lines
Marco Crivellari

L3 Support Engineer
#2 lore raw
Quoted 4 lines · Marco Crivellari

[...]

Quoted 2 lines
 kernel/smp.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Gentle ping.

Thanks!

Signature · 3 lines
Marco Crivellari

L3 Support Engineer
Reviewed-by on v2 1/1
#3 lore raw
In reply to Marco Crivellari
Quoted 32 lines · Marco Crivellari

Currently if a user enqueues a work item using schedule_delayed_work() the used wq is "system_wq" (per-cpu wq) while queue_delayed_work() use WORK_CPU_UNBOUND (used when a cpu is not specified). The same applies to schedule_work() that is using system_wq and queue_work(), that makes use again of WORK_CPU_UNBOUND.

This lack of consistency cannot be addressed without refactoring the API.

This continues the effort to refactor workqueue APIs, which began with the introduction of new workqueues and a new alloc_workqueue flag in:

commit 128ea9f6ccfb ("workqueue: Add system_percpu_wq and system_dfl_wq") commit 930c2ea566af ("workqueue: Add new WQ_PERCPU flag")

Switch to using system_percpu_wq because system_wq is going away as part of a workqueue restructuring.

---
Changes in v2:
- improved commit log
- rebased on 6.18-rc5

---
 kernel/smp.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
kernel/smp.c +0 -0
index 02f52291fae4..496358eae37c 100644

kernel/smp.c int smp_call_on_cpu(unsigned int cpu, int (*func)(void *), void *par, bool phys) · line 1140

Quoted 5 lines
kernel/smp.c +1 -1
@@ -1137,7 +1137,7 @@ int smp_call_on_cpu(unsigned int cpu, int (*func)(void *), void *par, bool phys)
 	if (cpu >= nr_cpu_ids || !cpu_online(cpu))
 		return -ENXIO;
 
-	queue_work_on(cpu, system_wq, &sscs.work);
+	queue_work_on(cpu, system_percpu_wq, &sscs.work);
Signature · 2 lines
Frederic Weisbecker
SUSE Labs
#4 lore raw
In reply to Marco Crivellari
Quoted 8 lines · Marco Crivellari

[...]
Changes in v2:
- improved commit log
- rebased on 6.18-rc5

---
 kernel/smp.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Gentle ping.

Thanks!

Signature · 3 lines
Marco Crivellari

L3 Support Engineer
#6 lore raw

[tip: smp/core] smp: Use system_percpu_wq instead of system_wq

In reply to Marco Crivellari
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:     7eb28030f641d5bc7682c98602f896304efd31d2
Gitweb:        https://git.kernel.org/tip/7eb28030f641d5bc7682c98602f896304efd31d2
Author:        Marco Crivellari <[email protected]>
AuthorDate:    Mon, 10 Nov 2025 18:03:32 +01:00
Committer:     Thomas Gleixner <[email protected]>
CommitterDate: Thu, 26 Mar 2026 17:31:35 +01:00

smp: Use system_percpu_wq instead of system_wq

When a caller enqueues a work item using schedule_delayed_work() the used wq is "system_wq" (per-cpu wq) while queue_delayed_work() uses WORK_CPU_UNBOUND (used when no target CPU is specified). The same applies to schedule_work() that is using system_wq and queue_work(), which again makes use of WORK_CPU_UNBOUND.

This lack of consistency cannot be addressed without refactoring the API.

Continue the effort to refactor workqueue APIs, which began with the introduction of new workqueues and a new alloc_workqueue() flag in:

commit 128ea9f6ccfb ("workqueue: Add system_percpu_wq and system_dfl_wq") commit 930c2ea566af ("workqueue: Add new WQ_PERCPU flag")

and switch smp_call_on_cpu() to use system_percpu_wq because system_wq is going away once the ongoing workqueue restructuring is done.

---
 kernel/smp.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
kernel/smp.c +1 -1
index 0fc4ff2..6c77848 100644
@@ -1185,7 +1185,7 @@ int smp_call_on_cpu(unsigned int cpu, int (*func)(void *), void *par, bool phys)
 	if (cpu >= nr_cpu_ids || !cpu_online(cpu))
 		return -ENXIO;
 
-	queue_work_on(cpu, system_wq, &sscs.work);
+	queue_work_on(cpu, system_percpu_wq, &sscs.work);
 	wait_for_completion(&sscs.done);
 	destroy_work_on_stack(&sscs.work);