Replace old wq name and add WQ_PERCPU and WQ_UNBOUND to alloc_workqueue users
Subsystems (3)
v3 cover Replace old wq name and add WQ_PERCPU and WQ_UNBOUND to alloc_workqueue users
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-2] Replace uses of system_wq and system_unbound_wq
system_wq is a per-CPU workqueue, but his name is not clear. system_unbound_wq is to be used when locality is not required.
Because these specific workloads have no benefits from a per-cpu wq, both have been replaced with system_dfl_wq.
2) [P 3] WQ_UNBOUND added to alloc_workqueue (amdfk) This change make sure alloc_workqueue in amd/amdfkd is unbound, explicitly adding WQ_UNBOUND to the alloc_workqueue() user.
3) [P 4] 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!
---
Changes in v3:
- improved message commits
- rebased on v6.19-rc2
Changes in v2:
- system_wq replaced with system_dfl_wq instead of system_percpu_wq, because a per-cpu workload is not strictly needed.
- use WQ_UNBOUND instead of WQ_PERCPU, because this workload will benefit from unbound work.
- commits log integrated with commits about recent Workqueue API changes.
- work rebased on v6.18-rc4
Marco Crivellari (4):
drm/amdgpu: replace use of system_unbound_wq with system_dfl_wq drm/amdgpu: replace use of system_wq with system_dfl_wq amd/amdkfd: add WQ_UNBOUND to alloc_workqueue users drm/radeon: add WQ_PERCPU to alloc_workqueue users
drivers/gpu/drm/amd/amdgpu/aldebaran.c | 2 +- drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 6 +++--- drivers/gpu/drm/amd/amdgpu/amdgpu_reset.c | 2 +- drivers/gpu/drm/amd/amdkfd/kfd_process.c | 3 ++- drivers/gpu/drm/radeon/radeon_display.c | 3 ++- 5 files changed, 9 insertions(+), 7 deletions(-)
Signature · 1 line
2.52.0
PATCH v3 1/4 drm/amdgpu: replace use of system_unbound_wq with system_dfl_wq
This patch continues the effort to refactor workqueue APIs, which has begun with the changes introducing new workqueues and a new alloc_workqueue flag:
commit 128ea9f6ccfb ("workqueue: Add system_percpu_wq and system_dfl_wq") commit 930c2ea566af ("workqueue: Add new WQ_PERCPU flag")
The point of the refactoring is to eventually alter the default behavior of workqueues to become unbound by default so that their workload placement is optimized by the scheduler.
Before that to happen after a careful review and conversion of each individual case, workqueue users must be converted to the better named new workqueues with no intended behaviour changes:
system_wq -> system_percpu_wq
system_unbound_wq -> system_dfl_wq
This way the old obsolete workqueues (system_wq, system_unbound_wq) can be removed in the future.
--- drivers/gpu/drm/amd/amdgpu/aldebaran.c | 2 +- drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 2 +- drivers/gpu/drm/amd/amdgpu/amdgpu_reset.c | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-)
drivers/gpu/drm/amd/amdgpu/aldebaran.c +1 -1
@@ -179,7 +179,7 @@ aldebaran_mode2_perform_reset(struct amdgpu_reset_control *reset_ctl,list_for_each_entry (tmp_adev, reset_device_list, reset_list) {/* For XGMI run all resets in parallel to speed up the process */ if (tmp_adev->gmc.xgmi.num_physical_nodes >1 ) { -if (!queue_work (system_unbound_wq, +if (!queue_work (system_dfl_wq, &tmp_adev->reset_cntl->reset_work)) r = -EALREADY ; }else
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +1 -1
@@ -6173,7 +6173,7 @@ int amdgpu_do_asic_reset(struct list_head *device_list_handle,list_for_each_entry (tmp_adev, device_list_handle, reset_list) {/* For XGMI run all resets in parallel to speed up the process */ if (tmp_adev->gmc.xgmi.num_physical_nodes >1 ) { -if (!queue_work (system_unbound_wq, +if (!queue_work (system_dfl_wq, &tmp_adev->xgmi_reset_work)) r = -EALREADY ; }else
drivers/gpu/drm/amd/amdgpu/amdgpu_reset.c +1 -1
@@ -116,7 +116,7 @@ static int amdgpu_reset_xgmi_reset_on_init_perform_reset(/* Mode1 reset needs to be triggered on all devices together */ list_for_each_entry (tmp_adev, reset_device_list, reset_list) {/* For XGMI run all resets in parallel to speed up the process */ -if (!queue_work (system_unbound_wq, &tmp_adev->xgmi_reset_work)) +if (!queue_work (system_dfl_wq, &tmp_adev->xgmi_reset_work)) r = -EALREADY ;if (r) { dev_err(tmp_adev->dev,
Signature · 1 line
2.52.0
Alex Deucher
AppliedRe: [PATCH v3 1/4] drm/amdgpu: replace use of system_unbound_wq with system_dfl_wq
Applied the series. Thanks!
Alex
Quoted 71 lines · Marco Crivellari
This patch continues the effort to refactor workqueue APIs, which has begun with the changes introducing new workqueues and a new
alloc_workqueueflag:commit
128ea9f6ccfb("workqueue: Addsystem_percpu_wqandsystem_dfl_wq") commit930c2ea566af("workqueue: Add newWQ_PERCPUflag")The point of the refactoring is to eventually alter the default behavior of workqueues to become unbound by default so that their workload placement is optimized by the scheduler.
Before that to happen after a careful review and conversion of each individual case, workqueue users must be converted to the better named new workqueues with no intended behaviour changes:
system_wq -> system_percpu_wq system_unbound_wq -> system_dfl_wqThis way the old obsolete workqueues (
system_wq,system_unbound_wq) can be removed in the future.Suggested-by Tejun Heo <[email protected]>Signed-off-by Marco Crivellari <[email protected]>--- drivers/gpu/drm/amd/amdgpu/aldebaran.c | 2 +- drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 2 +- drivers/gpu/drm/amd/amdgpu/amdgpu_reset.c | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-)drivers/gpu/drm/amd/amdgpu/aldebaran.c +1
-1@@ -179,7 +179,7 @@ aldebaran_mode2_perform_reset(struct amdgpu_reset_control *reset_ctl,list_for_each_entry (tmp_adev, reset_device_list, reset_list) {/* For XGMI run all resets in parallel to speed up the process */ if (tmp_adev->gmc.xgmi.num_physical_nodes >1 ) { -if (!queue_work (system_unbound_wq, +if (!queue_work (system_dfl_wq, &tmp_adev->reset_cntl->reset_work)) r = -EALREADY ; }else drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +1
-1@@ -6173,7 +6173,7 @@ int amdgpu_do_asic_reset(struct list_head *device_list_handle,list_for_each_entry (tmp_adev, device_list_handle, reset_list) {/* For XGMI run all resets in parallel to speed up the process */ if (tmp_adev->gmc.xgmi.num_physical_nodes >1 ) { -if (!queue_work (system_unbound_wq, +if (!queue_work (system_dfl_wq, &tmp_adev->xgmi_reset_work)) r = -EALREADY ; }else drivers/gpu/drm/amd/amdgpu/amdgpu_reset.c +1
-2@@ -116,7 +116,7 @@ static int amdgpu_reset_xgmi_reset_on_init_perform_reset(/* Mode1 reset needs to be triggered on all devices together */ list_for_each_entry (tmp_adev, reset_device_list, reset_list) {/* For XGMI run all resets in parallel to speed up the process */ -if (!queue_work (system_unbound_wq, &tmp_adev->xgmi_reset_work)) +if (!queue_work (system_dfl_wq, &tmp_adev->xgmi_reset_work)) r = -EALREADY ;if (r) { dev_err(tmp_adev->dev, --2.52.0
Re: [PATCH v3 1/4] drm/amdgpu: replace use of system_unbound_wq with system_dfl_wq
Quoted 4 lines · Alex Deucher
Applied the series. Thanks!
Alex
Many thanks!
Signature · 3 lines
Marco Crivellari L3 Support Engineer
PATCH v3 2/4 drm/amdgpu: replace use of system_wq with system_dfl_wq
In reply to Marco CrivellariThis patch continues the effort to refactor workqueue APIs, which has begun with the changes introducing new workqueues and a new alloc_workqueue flag:
commit 128ea9f6ccfb ("workqueue: Add system_percpu_wq and system_dfl_wq") commit 930c2ea566af ("workqueue: Add new WQ_PERCPU flag")
The point of the refactoring is to eventually alter the default behavior of workqueues to become unbound by default so that their workload placement is optimized by the scheduler.
Before that to happen after a careful review and conversion of each individual case, workqueue users must be converted to the better named new workqueues with no intended behaviour changes:
system_wq -> system_percpu_wq
system_unbound_wq -> system_dfl_wq
This way the old obsolete workqueues (system_wq, system_unbound_wq) can be removed in the future.
--- drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +2 -2
@@ -4922,7 +4922,7 @@ int amdgpu_device_init(struct amdgpu_device *adev, }/* must succeed. */ amdgpu_ras_resume (adev); -queue_delayed_work (system_wq, &adev->delayed_init_work, +queue_delayed_work (system_dfl_wq, &adev->delayed_init_work,msecs_to_jiffies (AMDGPU_RESUME_MS )); }
@@ -5469,7 +5469,7 @@ int amdgpu_device_resume(struct drm_device *dev, bool notify_clients)if (r) goto exit; -queue_delayed_work (system_wq, &adev->delayed_init_work, +queue_delayed_work (system_dfl_wq, &adev->delayed_init_work,msecs_to_jiffies (AMDGPU_RESUME_MS )); exit:if (amdgpu_sriov_vf (adev)) {
Signature · 1 line
2.52.0
PATCH v3 3/4 amd/amdkfd: add WQ_UNBOUND to alloc_workqueue users
In reply to Marco CrivellariThis 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")
The refactoring is going to alter the default behavior of alloc_workqueue() to be unbound by default.
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. For more details see the Link tag below.
This specific workload has no benefit being per-cpu, so its behavior has been changed using explicitly WQ_UNBOUND.
--- drivers/gpu/drm/amd/amdkfd/kfd_process.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/gpu/drm/amd/amdkfd/kfd_process.c +2 -1
@@ -690,7 +690,8 @@ void kfd_procfs_del_queue(struct queue *q)int kfd_process_create_wq (void ) {if (!kfd_process_wq) - kfd_process_wq =alloc_workqueue ("kfd_process_wq" ,0 ,0 ); + kfd_process_wq =alloc_workqueue ("kfd_process_wq" ,WQ_UNBOUND , +0 );if (!kfd_restore_wq) kfd_restore_wq =alloc_ordered_workqueue ("kfd_restore_wq" ,WQ_FREEZABLE );
Signature · 1 line
2.52.0
PATCH v3 4/4 drm/radeon: add WQ_PERCPU to alloc_workqueue users
In reply to Marco CrivellariThis 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")
The refactoring is going to alter the default behavior of alloc_workqueue() to be unbound by default.
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. For more details see the Link tag below.
In order to keep alloc_workqueue() behavior identical, explicitly request WQ_PERCPU.
--- drivers/gpu/drm/radeon/radeon_display.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/gpu/drm/radeon/radeon_display.c +2 -1
@@ -685,7 +685,8 @@ static void radeon_crtc_init(struct drm_device *dev, int index)if (radeon_crtc ==NULL )return ; - radeon_crtc->flip_queue =alloc_workqueue ("radeon-crtc" ,WQ_HIGHPRI ,0 ); + radeon_crtc->flip_queue =alloc_workqueue ("radeon-crtc" , +WQ_HIGHPRI |WQ_PERCPU ,0 );if (!radeon_crtc->flip_queue) {kfree (radeon_crtc);return ;
Signature · 1 line
2.52.0
Alex Deucher
AppliedRe: [PATCH v3 4/4] drm/radeon: add WQ_PERCPU to alloc_workqueue users
Applied. Thanks!
Alex
Quoted 40 lines · Marco Crivellari
This continues the effort to refactor workqueue APIs, which began with the introduction of new workqueues and a new
alloc_workqueueflag in:commit
128ea9f6ccfb("workqueue: Addsystem_percpu_wqandsystem_dfl_wq") commit930c2ea566af("workqueue: Add newWQ_PERCPUflag")The refactoring is going to alter the default behavior of
alloc_workqueue()to be unbound by default.With the introduction of the
WQ_PERCPUflag (equivalent to !WQ_UNBOUND), anyalloc_workqueue()caller that doesn’t explicitly specifyWQ_UNBOUNDmust now useWQ_PERCPU. For more details see the Link tag below.In order to keep
alloc_workqueue()behavior identical, explicitly requestWQ_PERCPU.Suggested-by Tejun Heo <[email protected]>Signed-off-by Marco Crivellari <[email protected]>--- drivers/gpu/drm/radeon/radeon_display.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)drivers/gpu/drm/radeon/radeon_display.c +2
-2@@ -685,7 +685,8 @@ static void radeon_crtc_init(struct drm_device *dev, int index)if (radeon_crtc ==NULL )return ; - radeon_crtc->flip_queue =alloc_workqueue ("radeon-crtc" ,WQ_HIGHPRI ,0 ); + radeon_crtc->flip_queue =alloc_workqueue ("radeon-crtc" , +WQ_HIGHPRI |WQ_PERCPU ,0 );if (!radeon_crtc->flip_queue) {kfree (radeon_crtc);return ; --2.52.0
Quoted 7 lines · Marco Crivellari
[ ...]
Marco Crivellari (4):
drm/amdgpu: replace use ofsystem_unbound_wqwithsystem_dfl_wqdrm/amdgpu: replace use ofsystem_wqwithsystem_dfl_wqamd/amdkfd: addWQ_UNBOUNDtoalloc_workqueueusers drm/radeon: addWQ_PERCPUtoalloc_workqueueusers
Quoted 6 lines
drivers/gpu/drm/amd/amdgpu/aldebaran.c | 2 +- drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 6 +++--- drivers/gpu/drm/amd/amdgpu/amdgpu_reset.c | 2 +- drivers/gpu/drm/amd/amdkfd/kfd_process.c | 3 ++- drivers/gpu/drm/radeon/radeon_display.c | 3 ++- 5 files changed, 9 insertions(+), 7 deletions(-)
Gentle ping.
Thanks!
--
Marco Crivellari
L3 Support Engineer
Quoted 7 lines · Marco Crivellari
[...]
Marco Crivellari (4):
drm/amdgpu: replace use ofsystem_unbound_wqwithsystem_dfl_wqdrm/amdgpu: replace use ofsystem_wqwithsystem_dfl_wqamd/amdkfd: addWQ_UNBOUNDtoalloc_workqueueusers drm/radeon: addWQ_PERCPUtoalloc_workqueueusers
Quoted 6 lines
drivers/gpu/drm/amd/amdgpu/aldebaran.c | 2 +- drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 6 +++--- drivers/gpu/drm/amd/amdgpu/amdgpu_reset.c | 2 +- drivers/gpu/drm/amd/amdkfd/kfd_process.c | 3 ++- drivers/gpu/drm/radeon/radeon_display.c | 3 ++- 5 files changed, 9 insertions(+), 7 deletions(-)
Gentle ping.
Thanks.
Signature · 3 lines
Marco Crivellari L3 Support Engineer
Christian König
maintainerQuoted 9 lines · Marco Crivellari
Quoted 7 lines · Marco Crivellari
[...]
Marco Crivellari (4):
drm/amdgpu: replace use ofsystem_unbound_wqwithsystem_dfl_wqdrm/amdgpu: replace use ofsystem_wqwithsystem_dfl_wqamd/amdkfd: addWQ_UNBOUNDtoalloc_workqueueusers drm/radeon: addWQ_PERCPUtoalloc_workqueueusers
Quoted 8 lines
Quoted 6 lines
drivers/gpu/drm/amd/amdgpu/aldebaran.c | 2 +- drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 6 +++--- drivers/gpu/drm/amd/amdgpu/amdgpu_reset.c | 2 +- drivers/gpu/drm/amd/amdkfd/kfd_process.c | 3 ++- drivers/gpu/drm/radeon/radeon_display.c | 3 ++- 5 files changed, 9 insertions(+), 7 deletions(-)Gentle ping.
I don't have time to go over that again in detail, but skimming over it looks good to me.
Feel free to add Acked-by: Christian König <[email protected]> to the radeon and amdgpu patches.
Felix or Philip might want to check the amdkfd patches.
Regards,
Christian.
Quoted 3 lines
Thanks.
Quoted 6 lines · Christian König
[...]
I don't have time to go over that again in detail, but skimming over it looks good to me.Feel free to add Acked-by: Christian König <[email protected]> to the radeon and amdgpu patches.
Felix or Philip might want to check the amdkfd patches.
Thanks for the ack, Christian!
Signature · 3 lines
Marco Crivellari L3 Support Engineer
Quoted 8 lines · Marco Crivellari
[...]
Marco Crivellari (4):
drm/amdgpu: replace use ofsystem_unbound_wqwithsystem_dfl_wqdrm/amdgpu: replace use ofsystem_wqwithsystem_dfl_wqamd/amdkfd: addWQ_UNBOUNDtoalloc_workqueueusers drm/radeon: addWQ_PERCPUtoalloc_workqueueusers
Quoted 6 lines
drivers/gpu/drm/amd/amdgpu/aldebaran.c | 2 +- drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 6 +++--- drivers/gpu/drm/amd/amdgpu/amdgpu_reset.c | 2 +- drivers/gpu/drm/amd/amdkfd/kfd_process.c | 3 ++- drivers/gpu/drm/radeon/radeon_display.c | 3 ++- 5 files changed, 9 insertions(+), 7 deletions(-)
Hi,
Gentle ping.
Thanks!
Signature · 3 lines
Marco Crivellari L3 Support Engineer