media: synopsys: hdmirx: replace use of system_unbound_wq with system_dfl_wq
Subsystems (2)
PATCH 1/1 media: synopsys: hdmirx: 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.
This patch continues the effort to refactor worqueue APIs, which has begun with the change introducing new workqueues:
commit 128ea9f6ccfb ("workqueue: Add system_percpu_wq and system_dfl_wq")
system_dfl_wq should be the default workqueue so as not to enforce locality constraints for random work whenever it's not required.
The old system_unbound_wq will be kept for a few release cycles.
--- drivers/media/platform/synopsys/hdmirx/snps_hdmirx.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/media/platform/synopsys/hdmirx/snps_hdmirx.c +4 -4
@@ -1735,7 +1735,7 @@ static void process_signal_change(struct snps_hdmirx_dev *hdmirx_dev)FIFO_UNDERFLOW_INT_EN | HDMIRX_AXI_ERROR_INT_EN, 0);hdmirx_reset_dma (hdmirx_dev); -queue_delayed_work (system_unbound_wq, +queue_delayed_work (system_dfl_wq, &hdmirx_dev->delayed_work_res_change,msecs_to_jiffies (50 )); }
@@ -2190,7 +2190,7 @@ static void hdmirx_delayed_work_res_change(struct work_struct *work)if (hdmirx_wait_signal_lock (hdmirx_dev)) {hdmirx_plugout (hdmirx_dev); -queue_delayed_work (system_unbound_wq, +queue_delayed_work (system_dfl_wq, &hdmirx_dev->delayed_work_hotplug,msecs_to_jiffies (200 )); }else {
@@ -2209,7 +2209,7 @@ static irqreturn_t hdmirx_5v_det_irq_handler(int irq, void *dev_id) val =gpiod_get_value (hdmirx_dev->detect_5v_gpio);v4l2_dbg (3 , debug, &hdmirx_dev->v4l2_dev,"%s: 5v:%d\n" , __func__, val); -queue_delayed_work (system_unbound_wq, +queue_delayed_work (system_dfl_wq, &hdmirx_dev->delayed_work_hotplug,msecs_to_jiffies (10 ));
@@ -2441,7 +2441,7 @@ static void hdmirx_enable_irq(struct device *dev)enable_irq (hdmirx_dev->dma_irq);enable_irq (hdmirx_dev->det_irq); -queue_delayed_work (system_unbound_wq, +queue_delayed_work (system_dfl_wq, &hdmirx_dev->delayed_work_hotplug,msecs_to_jiffies (110 )); }
Signature · 1 line
2.51.1
Dmitry Osipenko
maintainerHi,
Quoted 29 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 consistency cannot be addressed without refactoring the API.
This patch continues the effort to refactor worqueue APIs, which has begun with the change introducing new workqueues:
commit
128ea9f6ccfb("workqueue: Addsystem_percpu_wqandsystem_dfl_wq")
system_dfl_wqshould be the default workqueue so as not to enforce locality constraints for random work whenever it's not required.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]>--- drivers/media/platform/synopsys/hdmirx/snps_hdmirx.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)drivers/media/platform/synopsys/hdmirx/snps_hdmirx.c +0
-0
drivers/media/platform/synopsys/hdmirx/snps_hdmirx.c static void process_signal_change(struct snps_hdmirx_dev *hdmirx_dev) · line 1738
Quoted 5 lines
drivers/media/platform/synopsys/hdmirx/snps_hdmirx.c +1
-1@@ -1735,7 +1735,7 @@ static void process_signal_change(struct snps_hdmirx_dev *hdmirx_dev)FIFO_UNDERFLOW_INT_EN | HDMIRX_AXI_ERROR_INT_EN, 0);hdmirx_reset_dma (hdmirx_dev); - queue_delayed_work(system_unbound_wq, + queue_delayed_work(system_dfl_wq,
Took me a minute to find what "dfl" stands for. Would be great if the name was self-explanatory as system_default_wq. Even then, not clear to me what's the point of this remaining, the system_dfl_wq naming feels very obscure compared to the explicit system_unbound_wq.
Could you please explain the logic behind the new naming? Doesn't it create more confusion than remove?
AFAICS, right now system_dfl_wq duplicates system_unbound_wq. Suppose, instead, the default wq could alias the system_unbound_wq.
Signature · 2 lines
Best regards, Dmitry
Hi,
Quoted 10 lines · Dmitry Osipenko
Hi,
[...]
Took me a minute to find what "dfl" stands for. Would be great if the name was self-explanatory assystem_default_wq. Even then, not clear to me what's the point of this remaining, thesystem_dfl_wqnaming feels very obscure compared to the explicitsystem_unbound_wq.Could you please explain the logic behind the new naming? Doesn't it create more confusion than remove?
Yes, dfl it is just the abbreviation of default.
The reason is to suggest the use of the unbound workqueue instead of the per-cpu, unless this is really needed, of course.
There are parts of the code who just used system_wq thinking it was the unbound workqueue (the "general" wq to use), so to make explicit the "default" is the unbound (system_dfl_wq) I think it is appropriate.
I saw this myself also in this conversion round: there are maintainers who are asking
to change the wq they were using from system_wq to system_dfl_wq.
Let me share also where the API change (and other stuff) have been discussed:
https://lore.kernel.org/all/[email protected]/
Quoted 2 lines · Dmitry Osipenko
AFAICS, right now
system_dfl_wqduplicatessystem_unbound_wq. Suppose, instead, the default wq could alias thesystem_unbound_wq.
The idea was just give 1 choice, so remove system_unbound_wq (and system_wq) in future.
Personally I don't have a strong opinion, but I think it's easier to have just 1 unbound wq, and 1
per-cpu wq.
But if Tejun has other suggestions, based on your observation, I'm fine with it!
Thanks!
--
Marco Crivellari
L3 Support Engineer, Technology & Product
Quoted 3 lines · Marco Crivellari
[...]
drivers/media/platform/synopsys/hdmirx/snps_hdmirx.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
Gentle ping.
Thanks!
Signature · 3 lines
Marco Crivellari L3 Support Engineer
Dmitry Osipenko
maintainerQuoted 10 lines · Marco Crivellari
Quoted 3 lines · Marco Crivellari
[...]
drivers/media/platform/synopsys/hdmirx/snps_hdmirx.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)Gentle ping.
Thanks!
Would be good to have a reply from Tejun as I feel confused by the two "identical" unbound workqueues. What happens if one part of kernel queues work items to old unbound wq and other queues to new system_dfl at the same time such that all workers are busy?
Signature · 2 lines
Best regards, Dmitry
Quoted 9 lines · Dmitry Osipenko
Quoted 8 lines · Marco Crivellari
Quoted 3 lines · Marco Crivellari
[...]
drivers/media/platform/synopsys/hdmirx/snps_hdmirx.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)Gentle ping.
Quoted 7 lines
Quoted 2 lines
Thanks!
Would be good to have a reply from Tejun as I feel confused by the two "identical" unbound workqueues. What happens if one part of kernel queues work items to old unbound wq and other queues to new
system_dflat the same time such that all workers are busy?
Alright, looking further at the code, apparently there is nothing special RE the two unbound work queues. See some parts of kernel already moved to system_dfl. Would be great is this all was clarified in the commit message.
Signature · 2 lines
Best regards, Dmitry
Quoted 6 lines · Dmitry Osipenko
Alright, looking further at the code, apparently there is nothing special RE the two unbound work queues. See some parts of kernel already moved to
system_dfl. Would be great is this all was clarified in the commit message.Acked-by Dmitry Osipenko <[email protected]>
Hi,
If you want I can send a new version with the improved commit log:
---
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, 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.
---
Let me know what's best.
Thanks!
Signature · 3 lines
Marco Crivellari L3 Support Engineer
Dmitry Osipenko
maintainerQuoted 31 lines · Marco Crivellari
Quoted 6 lines · Dmitry Osipenko
Alright, looking further at the code, apparently there is nothing special RE the two unbound work queues. See some parts of kernel already moved to
system_dfl. Would be great is this all was clarified in the commit message.Acked-by Dmitry Osipenko <[email protected]>Hi,
If you want I can send a new version with the improved commit log:
---
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, 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
Quoted 8 lines
This way the old obsolete workqueues (
system_wq,system_unbound_wq) can be removed in the future.---
Let me know what's best.
That's better, feel free to send the v2. Thanks!
Signature · 2 lines
Best regards, Dmitry