replace system_unbound_wq and system_wq with the new wqs
cover replace system_unbound_wq and system_wq with the new wqs
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 consistentcy 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 of that, system_wq has been replaced with system_percpu_wq, and system_unbound_wq has been replaced with system_dfl_wq.
Thanks!
Marco Crivellari (2):
accel/ivpu: replace use of system_unbound_wq with system_dfl_wq accel/ivpu: replace use of system_wq with system_percpu_wq
drivers/accel/ivpu/ivpu_hw_btrs.c | 2 +- drivers/accel/ivpu/ivpu_ipc.c | 2 +- drivers/accel/ivpu/ivpu_job.c | 2 +- drivers/accel/ivpu/ivpu_mmu.c | 2 +- drivers/accel/ivpu/ivpu_pm.c | 4 ++-- 5 files changed, 6 insertions(+), 6 deletions(-)
Signature · 1 line
2.51.0
PATCH 1/2 accel/ivpu: 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 consistentcy 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/accel/ivpu/ivpu_pm.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/accel/ivpu/ivpu_pm.c +1 -1
@@ -186,7 +186,7 @@ void ivpu_pm_trigger_recovery(struct ivpu_device *vdev, const char *reason)if (atomic_cmpxchg (&vdev->pm->reset_pending,0 ,1 ) ==0 ) {ivpu_hw_diagnose_failure (vdev);ivpu_hw_irq_disable (vdev);/* Disable IRQ early to protect from IRQ storm */ -queue_work (system_unbound_wq, &vdev->pm->recovery_work); +queue_work (system_dfl_wq, &vdev->pm->recovery_work); } }
Signature · 1 line
2.51.0
PATCH 2/2 accel/ivpu: replace use of system_wq with system_percpu_wq
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.
system_wq should be the per-cpu workqueue, yet in this name nothing makes that clear, so replace system_wq with system_percpu_wq.
The old wq (system_wq) will be kept for a few release cycles.
--- drivers/accel/ivpu/ivpu_hw_btrs.c | 2 +- drivers/accel/ivpu/ivpu_ipc.c | 2 +- drivers/accel/ivpu/ivpu_job.c | 2 +- drivers/accel/ivpu/ivpu_mmu.c | 2 +- drivers/accel/ivpu/ivpu_pm.c | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-)
drivers/accel/ivpu/ivpu_hw_btrs.c +1 -1
@@ -673,7 +673,7 @@ bool ivpu_hw_btrs_irq_handler_lnl(struct ivpu_device *vdev, int irq)if (REG_TEST_FLD (VPU_HW_BTRS_LNL_INTERRUPT_STAT ,SURV_ERR , status)) {ivpu_dbg (vdev,IRQ ,"Survivability IRQ\n" ); -queue_work (system_wq, &vdev->irq_dct_work); +queue_work (system_percpu_wq, &vdev->irq_dct_work); }if (REG_TEST_FLD (VPU_HW_BTRS_LNL_INTERRUPT_STAT ,FREQ_CHANGE , status)) {
drivers/accel/ivpu/ivpu_ipc.c +1 -1
@@ -459,7 +459,7 @@ void ivpu_ipc_irq_handler(struct ivpu_device *vdev) } } -queue_work (system_wq, &vdev->irq_ipc_work); +queue_work (system_percpu_wq, &vdev->irq_ipc_work); }void ivpu_ipc_irq_work_fn (struct work_struct *work)
drivers/accel/ivpu/ivpu_job.c +1 -1
@@ -574,7 +574,7 @@ static int ivpu_job_signal_and_destroy(struct ivpu_device *vdev, u32 job_id, u32* status and ensure both are handled in the same way */ job->file_priv->has_mmu_faults = true; -queue_work (system_wq, &vdev->context_abort_work); +queue_work (system_percpu_wq, &vdev->context_abort_work);return 0 ; }
drivers/accel/ivpu/ivpu_mmu.c +1 -1
@@ -970,7 +970,7 @@ void ivpu_mmu_irq_evtq_handler(struct ivpu_device *vdev) } } -queue_work (system_wq, &vdev->context_abort_work); +queue_work (system_percpu_wq, &vdev->context_abort_work); }void ivpu_mmu_evtq_dump (struct ivpu_device *vdev)
drivers/accel/ivpu/ivpu_pm.c +1 -1
@@ -226,7 +226,7 @@ void ivpu_start_job_timeout_detection(struct ivpu_device *vdev)unsigned long timeout_ms = ivpu_tdr_timeout_ms ? ivpu_tdr_timeout_ms : vdev->timeout.tdr;/* No-op if already queued */ -queue_delayed_work (system_wq, &vdev->pm->job_timeout_work,msecs_to_jiffies (timeout_ms)); +queue_delayed_work (system_percpu_wq, &vdev->pm->job_timeout_work,msecs_to_jiffies (timeout_ms)); }void ivpu_stop_job_timeout_detection (struct ivpu_device *vdev)
Signature · 1 line
2.51.0
Re: [PATCH 2/2] accel/ivpu: replace use of system_wq with system_percpu_wq
Quoted 80 lines · Marco Crivellari
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 consistentcy cannot be addressed without refactoring the API.
system_wqshould be the per-cpu workqueue, yet in this name nothing makes that clear, so replacesystem_wqwithsystem_percpu_wq.The old wq (
system_wq) will be kept for a few release cycles.Suggested-by Tejun Heo <[email protected]>Signed-off-by Marco Crivellari <[email protected]>--- drivers/accel/ivpu/ivpu_hw_btrs.c | 2 +- drivers/accel/ivpu/ivpu_ipc.c | 2 +- drivers/accel/ivpu/ivpu_job.c | 2 +- drivers/accel/ivpu/ivpu_mmu.c | 2 +- drivers/accel/ivpu/ivpu_pm.c | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-)drivers/accel/ivpu/ivpu_hw_btrs.c +1
-1@@ -673,7 +673,7 @@ bool ivpu_hw_btrs_irq_handler_lnl(struct ivpu_device *vdev, int irq)if (REG_TEST_FLD (VPU_HW_BTRS_LNL_INTERRUPT_STAT ,SURV_ERR , status)) {ivpu_dbg (vdev,IRQ ,"Survivability IRQ\n" ); -queue_work (system_wq, &vdev->irq_dct_work); +queue_work (system_percpu_wq, &vdev->irq_dct_work); }if (REG_TEST_FLD (VPU_HW_BTRS_LNL_INTERRUPT_STAT ,FREQ_CHANGE , status)) {drivers/accel/ivpu/ivpu_ipc.c +1
-1@@ -459,7 +459,7 @@ void ivpu_ipc_irq_handler(struct ivpu_device *vdev) } } -queue_work (system_wq, &vdev->irq_ipc_work); +queue_work (system_percpu_wq, &vdev->irq_ipc_work); }void ivpu_ipc_irq_work_fn (struct work_struct *work)drivers/accel/ivpu/ivpu_job.c +1
-1@@ -574,7 +574,7 @@ static int ivpu_job_signal_and_destroy(struct ivpu_device *vdev, u32 job_id, u32* status and ensure both are handled in the same way */ job->file_priv->has_mmu_faults = true; -queue_work (system_wq, &vdev->context_abort_work); +queue_work (system_percpu_wq, &vdev->context_abort_work);return 0 ; }drivers/accel/ivpu/ivpu_mmu.c +1
-1@@ -970,7 +970,7 @@ void ivpu_mmu_irq_evtq_handler(struct ivpu_device *vdev) } } -queue_work (system_wq, &vdev->context_abort_work); +queue_work (system_percpu_wq, &vdev->context_abort_work); }void ivpu_mmu_evtq_dump (struct ivpu_device *vdev)drivers/accel/ivpu/ivpu_pm.c +0
-0
drivers/accel/ivpu/ivpu_pm.c void ivpu_start_job_timeout_detection(struct ivpu_device *vdev) · line 229
Quoted 5 lines
drivers/accel/ivpu/ivpu_pm.c +1
-1@@ -226,7 +226,7 @@ void ivpu_start_job_timeout_detection(struct ivpu_device *vdev)unsigned long timeout_ms = ivpu_tdr_timeout_ms ? ivpu_tdr_timeout_ms : vdev->timeout.tdr;/* No-op if already queued */ -queue_delayed_work (system_wq, &vdev->pm->job_timeout_work,msecs_to_jiffies (timeout_ms)); +queue_delayed_work (system_percpu_wq, &vdev->pm->job_timeout_work,msecs_to_jiffies (timeout_ms));
Thanks for the patch. Please fix the checkpatch warning:
WARNING: line length of 104 exceeds 100
columns
#90: FILE:drivers/accel/ivpu/ivpu_pm.c:229:
+ queue_delayed_work(system_percpu_wq, &vdev->pm->job_timeout_work, msecs_to_jiffies(timeout_ms));
drivers/accel/ivpu/ivpu_pm.c void ivpu_start_job_timeout_detection(struct ivpu_device *vdev) · line 232
Quoted 3 lines
drivers/accel/ivpu/ivpu_pm.c +0
-0}void ivpu_stop_job_timeout_detection (struct ivpu_device *vdev)
Also there's a typo "consistentcy" -> "consistency" that can get fixed with together with that warning.
Re: [PATCH 2/2] accel/ivpu: replace use of system_wq with system_percpu_wq
Quoted 12 lines · Karol Wachowski
[...]
Thanks for the patch. Please fix the checkpatch warning:WARNING: line length of 104 exceeds 100
columns
Also there's a typo "consistentcy" -> "consistency" that can get fixed with together with that warning.[...]Tested-by Karol Wachowski <[email protected]>
Hello Karol, thank you, I will fix both.
Signature · 3 lines
Marco Crivellari L3 Support Engineer, Technology & Product