replaced old wq name, added WQ_PERCPU to alloc_workqueue
Subsystems (3)
cover replaced old wq name, added WQ_PERCPU to alloc_workqueue
Hi,
=== Current situation: problems ===
Let's consider a nohz_full system with isolated CPUs: wq_unbound_cpumask is set to the housekeeping CPUs, for !WQ_UNBOUND the local CPU is selected.
This leads to different scenarios if a work item is scheduled on an isolated CPU where "delay" value is 0 or greater then 0:
schedule_delayed_work(, 0);
This will be handled by __queue_work() that will queue the work item on the current local (isolated) CPU, while:
schedule_delayed_work(, 1);
Will move the timer on an housekeeping CPU, and schedule the work there.
Currently if a user enqueue 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.
=== Recent changes to the WQ API ===
The following, address the recent changes in the Workqueue API:
- commit 128ea9f6ccfb ("workqueue: Add system_percpu_wq and system_dfl_wq")
- commit 930c2ea566af ("workqueue: Add new WQ_PERCPU flag")
The old workqueues will be removed in a future release cycle.
=== Introduced Changes by this series ===
1) [P 1] Replace uses of system_unbound_wq
system_unbound_wq is to be used when locality is not required.
Because of that, system_unbound_wq has been replaced with
system_dfl_wq, to make it clear it should be used if locality is not important.
2) [P 2] WQ_PERCPU added to alloc_workqueue()
This change adds a new WQ_PERCPU flag to explicitly request alloc_workqueue() to be per-cpu when WQ_UNBOUND has not been specified.
Thanks!
Marco Crivellari (2):
drm/nouveau: replace use of system_unbound_wq with system_dfl_wq drm/nouveau: WQ_PERCPU added to alloc_workqueue users
drivers/gpu/drm/nouveau/dispnv50/disp.c | 2 +- drivers/gpu/drm/nouveau/nouveau_drm.c | 2 +- drivers/gpu/drm/nouveau/nouveau_sched.c | 3 ++- 3 files changed, 4 insertions(+), 3 deletions(-)
Signature · 1 line
2.51.0
PATCH 1/2 drm/nouveau: replace use of system_unbound_wq with system_dfl_wq
Currently if a user enqueue 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.
system_unbound_wq should be the default workqueue so as not to enforce locality constraints for random work whenever it's not required.
Adding system_dfl_wq to encourage its use when unbound work should be used.
The old system_unbound_wq will be kept for a few release cycles.
--- drivers/gpu/drm/nouveau/dispnv50/disp.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/nouveau/dispnv50/disp.c +1 -1
@@ -2474,7 +2474,7 @@ nv50_disp_atomic_commit(struct drm_device *dev,pm_runtime_get_noresume (dev->dev);if (nonblock) -queue_work (system_unbound_wq, &state->commit_work); +queue_work (system_dfl_wq, &state->commit_work);else nv50_disp_atomic_commit_tail (state);
Signature · 1 line
2.51.0
Re: [PATCH 1/2] drm/nouveau: replace use of system_unbound_wq with system_dfl_wq
Am 31.10.25 um 11:20 schrieb Marco Crivellari:
Quoted 11 lines
Currently if a user enqueue a work item using
schedule_delayed_work()the used wq is "system_wq" (per-cpu wq) whilequeue_delayed_work()useWORK_CPU_UNBOUND(used when a cpu is not specified). The same applies toschedule_work()that is usingsystem_wqandqueue_work(), that makes use again ofWORK_CPU_UNBOUND.This lack of consistency cannot be addressed without refactoring the API.
system_unbound_wqshould be the default workqueue so as not to enforce locality constraints for random work whenever it's not required.
Quoted 6 lines
Adding
system_dfl_wqto encourage its use when unbound work should be used.The old
system_unbound_wqwill be kept for a few release cycles.Suggested-by Tejun Heo <[email protected]>Signed-off-by Marco Crivellari <[email protected]>
Quoted 17 lines
--- drivers/gpu/drm/nouveau/dispnv50/disp.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/gpu/drm/nouveau/dispnv50/disp.c +1
-1@@ -2474,7 +2474,7 @@ nv50_disp_atomic_commit(struct drm_device *dev,pm_runtime_get_noresume (dev->dev);if (nonblock) -queue_work (system_unbound_wq, &state->commit_work); +queue_work (system_dfl_wq, &state->commit_work);else nv50_disp_atomic_commit_tail (state);
Signature · 6 lines
-- Thomas Zimmermann Graphics Driver Developer SUSE Software Solutions Germany GmbH Frankenstr. 146, 90461 Nürnberg, Germany, www.suse.com GF: Jochen Jaser, Andrew McDonald, Werner Knoblich, (HRB 36809, AG Nürnberg)
PATCH 2/2 drm/nouveau: WQ_PERCPU added to alloc_workqueue users
In reply to Marco CrivellariCurrently if a user enqueue 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 consistentcy cannot be addressed without refactoring the API.
alloc_workqueue() treats all queues as per-CPU by default, while unbound workqueues must opt-in via WQ_UNBOUND.
This default is suboptimal: most workloads benefit from unbound queues, allowing the scheduler to place worker threads where they’re needed and reducing noise when CPUs are isolated.
This change adds a new WQ_PERCPU flag to explicitly request alloc_workqueue() to be per-cpu when WQ_UNBOUND has not been specified.
With the introduction of the WQ_PERCPU flag (equivalent to !WQ_UNBOUND), any alloc_workqueue() caller that doesn’t explicitly specify WQ_UNBOUND must now use WQ_PERCPU.
Once migration is complete, WQ_UNBOUND can be removed and unbound will become the implicit default.
--- drivers/gpu/drm/nouveau/nouveau_drm.c | 2 +- drivers/gpu/drm/nouveau/nouveau_sched.c | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-)
drivers/gpu/drm/nouveau/nouveau_drm.c +1 -1
@@ -631,7 +631,7 @@ nouveau_drm_device_init(struct nouveau_drm *drm)struct drm_device *dev = drm->dev;int ret; - drm->sched_wq =alloc_workqueue ("nouveau_sched_wq_shared" ,0 , + drm->sched_wq =alloc_workqueue ("nouveau_sched_wq_shared" ,WQ_PERCPU ,WQ_MAX_ACTIVE );if (!drm->sched_wq)return -ENOMEM ;
drivers/gpu/drm/nouveau/nouveau_sched.c +2 -1
@@ -416,7 +416,8 @@ nouveau_sched_init(struct nouveau_sched *sched, struct nouveau_drm *drm,int ret;if (!wq) { - wq =alloc_workqueue ("nouveau_sched_wq_%d" ,0 ,WQ_MAX_ACTIVE , + wq =alloc_workqueue ("nouveau_sched_wq_%d" ,WQ_PERCPU , +WQ_MAX_ACTIVE , current->pid);if (!wq)return -ENOMEM ;
Signature · 1 line
2.51.0
Hi,
Quoted 8 lines · Marco Crivellari
Marco Crivellari (2):
drm/nouveau: replace use ofsystem_unbound_wqwithsystem_dfl_wqdrm/nouveau:WQ_PERCPUadded toalloc_workqueueusersdrivers/gpu/drm/nouveau/dispnv50/disp.c | 2 +- drivers/gpu/drm/nouveau/nouveau_drm.c | 2 +- drivers/gpu/drm/nouveau/nouveau_sched.c | 3 ++- 3 files changed, 4 insertions(+), 3 deletions(-)
Gentle ping.
Thanks!
Signature · 3 lines
Marco Crivellari L3 Support Engineer, Technology & Product
Hi,
Quoted 11 lines · Marco Crivellari
[...]
Quoted 8 lines
Marco Crivellari (2):
drm/nouveau: replace use ofsystem_unbound_wqwithsystem_dfl_wqdrm/nouveau:WQ_PERCPUadded toalloc_workqueueusersdrivers/gpu/drm/nouveau/dispnv50/disp.c | 2 +- drivers/gpu/drm/nouveau/nouveau_drm.c | 2 +- drivers/gpu/drm/nouveau/nouveau_sched.c | 3 ++- 3 files changed, 4 insertions(+), 3 deletions(-)Gentle ping.
Hi,
Gentle ping. :-)
Thanks!
Signature · 3 lines
Marco Crivellari L3 Support Engineer
Hi,
Quoted 8 lines · Marco Crivellari
Marco Crivellari (2):
drm/nouveau: replace use ofsystem_unbound_wqwithsystem_dfl_wqdrm/nouveau:WQ_PERCPUadded toalloc_workqueueusersdrivers/gpu/drm/nouveau/dispnv50/disp.c | 2 +- drivers/gpu/drm/nouveau/nouveau_drm.c | 2 +- drivers/gpu/drm/nouveau/nouveau_sched.c | 3 ++- 3 files changed, 4 insertions(+), 3 deletions(-)
Gentle ping.
Thanks!
Signature · 3 lines
Marco Crivellari L3 Support Engineer
Hi,
Quoted 8 lines · Marco Crivellari
Marco Crivellari (2):
drm/nouveau: replace use ofsystem_unbound_wqwithsystem_dfl_wqdrm/nouveau:WQ_PERCPUadded toalloc_workqueueusersdrivers/gpu/drm/nouveau/dispnv50/disp.c | 2 +- drivers/gpu/drm/nouveau/nouveau_drm.c | 2 +- drivers/gpu/drm/nouveau/nouveau_sched.c | 3 ++- 3 files changed, 4 insertions(+), 3 deletions(-)
Gentle ping.
Thanks!
Signature · 3 lines
Marco Crivellari L3 Support Engineer
Quoted 9 lines · Marco Crivellari
[...]
Marco Crivellari (2):
drm/nouveau: replace use ofsystem_unbound_wqwithsystem_dfl_wqdrm/nouveau:WQ_PERCPUadded toalloc_workqueueusersdrivers/gpu/drm/nouveau/dispnv50/disp.c | 2 +- drivers/gpu/drm/nouveau/nouveau_drm.c | 2 +- drivers/gpu/drm/nouveau/nouveau_sched.c | 3 ++- 3 files changed, 4 insertions(+), 3 deletions(-)
Hi,
Gentle ping.
Thanks!
Signature · 3 lines
Marco Crivellari SUSE Labs
Quoted 1 line · Marco Crivellari
[PATCH 0/2] replaced old wq name, added
WQ_PERCPUtoalloc_workqueue
Applied, thanks!
Branch: drm-misc-next
Tree: https://gitlab.freedesktop.org/drm/misc/kernel.git
[1/2] drm/nouveau: replace use of system_unbound_wq with system_dfl_wq
commit: ef1b53284175
[2/2] drm/nouveau: WQ_PERCPU added to alloc_workqueue users
commit: c82a16b0caacThe patches will appear in the next linux-next integration (typically within 24 hours on weekdays).
The patches are queued up for the upcoming merge window for the next major kernel release.
Quoted 6 lines · Danilo Krummrich
Quoted 1 line · Marco Crivellari
[PATCH 0/2] replaced old wq name, added
WQ_PERCPUtoalloc_workqueueApplied, thanks!
Quoted 7 lines
Branch: drm-misc-next
Tree: https://gitlab.freedesktop.org/drm/misc/kernel.git[1/2] drm/nouveau: replace use of
system_unbound_wqwithsystem_dfl_wqcommit: ef1b53284175 [2/2] drm/nouveau: WQ_PERCPU added to alloc_workqueue users commit: c82a16b0caac
Many thanks!
Signature · 3 lines
Marco Crivellari SUSE Labs
Danilo Krummrich
maintainerQuoted 1 line · Marco Crivellari
Many thanks!
No worries, sorry for the delay.
- Danilo