Skip to contentSkip to conversation

Add WQ_PERCPU to alloc_workqueue users and workqueue replacement

PATCH In review Marco Crivellari 4 participants 13 messages May 5 – May 8

Subsystems (7)
lore
Share & tools
lore
#0 lore raw

cover Add WQ_PERCPU to alloc_workqueue users and workqueue replacement

Hi,

This series collect all the workqueue changes related to Workqueue, specifically:

- add WQ_PERCPU to alloc_workqueue() users, so to make explicit they are per-cpu;

- replacement of system_unbound_wq and system_wq with system_dfl_wq and system_percpu_wq.

Those changes didn't received feedback and the discussions can be found at the following URLs:

- virt: acrn: Add WQ_PERCPU to alloc_workqueue users
https://lore.kernel.org/all/[email protected]/

- media: synopsys: hdmirx: replace use of system_unbound_wq with system_dfl_wq
https://lore.kernel.org/all/[email protected]/

- platform: cznic: turris-omnia-mcu: replace use of system_wq with system_percpu_wq
https://lore.kernel.org/all/[email protected]/

- media: ddbridge: add WQ_PERCPU to alloc_workqueue users
https://lore.kernel.org/all/[email protected]/

- rapidio: rio: add WQ_PERCPU to alloc_workqueue users
https://lore.kernel.org/all/[email protected]/

- umh: replace use of system_unbound_wq with system_dfl_wq
https://lore.kernel.org/all/[email protected]/

Thanks!

Marco Crivellari (6):
virt: acrn: Add WQ_PERCPU to alloc_workqueue users
media: synopsys: hdmirx: replace use of system_unbound_wq with
system_dfl_wq
platform: cznic: turris-omnia-mcu: replace use of system_wq with
system_percpu_wq
media: ddbridge: add WQ_PERCPU to alloc_workqueue users
rapidio: rio: add WQ_PERCPU to alloc_workqueue users
umh: replace use of system_unbound_wq with system_dfl_wq

 drivers/media/pci/ddbridge/ddbridge-core.c           | 2 +-
 drivers/media/platform/synopsys/hdmirx/snps_hdmirx.c | 8 ++++----
 drivers/platform/cznic/turris-omnia-mcu-gpio.c       | 2 +-
 drivers/rapidio/rio.c                                | 2 +-
 drivers/virt/acrn/irqfd.c                            | 2 +-
 kernel/umh.c                                         | 2 +-
 6 files changed, 9 insertions(+), 9 deletions(-)
Signature · 1 line
2.53.0
#1 lore raw

PATCH 1/6 virt: acrn: Add WQ_PERCPU to alloc_workqueue users

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")

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/virt/acrn/irqfd.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/virt/acrn/irqfd.c +1 -1
index acf8cd5f8f8c..aab15f94166a 100644
@@ -206,7 +206,7 @@ int acrn_irqfd_init(struct acrn_vm *vm)
 {
 	INIT_LIST_HEAD(&vm->irqfds);
 	mutex_init(&vm->irqfds_lock);
-	vm->irqfd_wq = alloc_workqueue("acrn_irqfd-%u", 0, 0, vm->vmid);
+	vm->irqfd_wq = alloc_workqueue("acrn_irqfd-%u", WQ_PERCPU, 0, vm->vmid);
 	if (!vm->irqfd_wq)
 		return -ENOMEM;
 
Signature · 1 line
2.53.0
#2 lore raw

PATCH 2/6 media: synopsys: hdmirx: replace use of system_unbound_wq with system_dfl_wq

In reply to Marco Crivellari

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.

---
 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
index 61ad20b18b8d..1061ab50dd64 100644
@@ -1776,7 +1776,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));
 }
@@ -2238,7 +2238,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 {
@@ -2253,7 +2253,7 @@ static irqreturn_t hdmirx_5v_det_irq_handler(int irq, void *dev_id)
 {
 	struct snps_hdmirx_dev *hdmirx_dev = dev_id;
 
-	queue_delayed_work(system_unbound_wq,
+	queue_delayed_work(system_dfl_wq,
 			   &hdmirx_dev->delayed_work_hotplug,
 			   msecs_to_jiffies(10));
 
@@ -2518,7 +2518,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.53.0
#3 lore raw

PATCH 3/6 platform: cznic: turris-omnia-mcu: replace use of system_wq with system_percpu_wq

In reply to 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 patch continues the effort to refactor worqueue APIs, which has begun with the change 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")

Replace system_wq with system_percpu_wq, keeping the same behavior. The old wq (system_wq) will be kept for a few release cycles.

---
 drivers/platform/cznic/turris-omnia-mcu-gpio.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/platform/cznic/turris-omnia-mcu-gpio.c +1 -1
index 7f0ada4fa606..4e430d6c3fc4 100644
@@ -893,7 +893,7 @@ static bool omnia_irq_read_pending_old(struct omnia_mcu *mcu,
 
 	if (status & OMNIA_STS_BUTTON_PRESSED) {
 		mcu->button_pressed_emul = true;
-		mod_delayed_work(system_wq, &mcu->button_release_emul_work,
+		mod_delayed_work(system_percpu_wq, &mcu->button_release_emul_work,
 				 msecs_to_jiffies(FRONT_BUTTON_RELEASE_DELAY_MS));
 	} else if (mcu->button_pressed_emul) {
 		status |= OMNIA_STS_BUTTON_PRESSED;
Signature · 1 line
2.53.0
maintainer Acked-by on v1 3/6
#4 lore raw

Re: [PATCH 3/6] platform: cznic: turris-omnia-mcu: replace use of system_wq with system_percpu_wq

Quoted 40 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 patch continues the effort to refactor worqueue APIs, which has begun with the change 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")

Replace system_wq with system_percpu_wq, keeping the same behavior. The old wq (system_wq) will be kept for a few release cycles.

---
 drivers/platform/cznic/turris-omnia-mcu-gpio.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/platform/cznic/turris-omnia-mcu-gpio.c +1 -1
index 7f0ada4fa606..4e430d6c3fc4 100644
@@ -893,7 +893,7 @@ static bool omnia_irq_read_pending_old(struct omnia_mcu *mcu,
 
 	if (status & OMNIA_STS_BUTTON_PRESSED) {
 		mcu->button_pressed_emul = true;
-		mod_delayed_work(system_wq, &mcu->button_release_emul_work,
+		mod_delayed_work(system_percpu_wq, &mcu->button_release_emul_work,
 				 msecs_to_jiffies(FRONT_BUTTON_RELEASE_DELAY_MS));
 	} else if (mcu->button_pressed_emul) {
 		status |= OMNIA_STS_BUTTON_PRESSED;
Signature · 1 line
2.53.0
#5 lore raw

PATCH 4/6 media: ddbridge: add WQ_PERCPU to alloc_workqueue users

In reply to Marco Crivellari

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")

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/media/pci/ddbridge/ddbridge-core.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/media/pci/ddbridge/ddbridge-core.c +1 -1
index 40e6c873c36d..d240e291ba4f 100644
@@ -3430,7 +3430,7 @@ int ddb_init_ddbridge(void)
 
 	if (ddb_class_create() < 0)
 		return -1;
-	ddb_wq = alloc_workqueue("ddbridge", 0, 0);
+	ddb_wq = alloc_workqueue("ddbridge", WQ_PERCPU, 0);
 	if (!ddb_wq)
 		return ddb_exit_ddbridge(1, -1);
 
Signature · 1 line
2.53.0
#6 lore raw

PATCH 5/6 rapidio: rio: add WQ_PERCPU to alloc_workqueue users

In reply to Marco Crivellari

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")

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/rapidio/rio.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/rapidio/rio.c +1 -1
index 0c175e6d424f..f45e58b0971f 100644
@@ -1994,7 +1994,7 @@ int rio_init_mports(void)
 	 * TODO: Implement restart of discovery process for all or
 	 * individual discovering mports.
 	 */
-	rio_wq = alloc_workqueue("riodisc", 0, 0);
+	rio_wq = alloc_workqueue("riodisc", WQ_PERCPU, 0);
 	if (!rio_wq) {
 		pr_err("RIO: unable allocate rio_wq\n");
 		goto no_disc;
Signature · 1 line
2.53.0
#7 lore raw

PATCH 6/6 umh: replace use of system_unbound_wq with system_dfl_wq

In reply to Marco Crivellari

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.

---
 kernel/umh.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
kernel/umh.c +1 -1
index cffda97d961c..48117c569e1a 100644
@@ -430,7 +430,7 @@ int call_usermodehelper_exec(struct subprocess_info *sub_info, int wait)
 	sub_info->complete = (wait == UMH_NO_WAIT) ? NULL : &done;
 	sub_info->wait = wait;
 
-	queue_work(system_unbound_wq, &sub_info->work);
+	queue_work(system_dfl_wq, &sub_info->work);
 	if (wait == UMH_NO_WAIT)	/* task has freed sub_info */
 		goto unlock;
 
Signature · 1 line
2.53.0
#8 lore raw
In reply to Marco Crivellari

Hello,

These are equivalent conversions that are part of tree-wide conversion. I'll route these through the workqueue tree in a day or two. Please holler if there are any objections.

Thanks.

Signature · 1 line
tejun
#9 lore raw
Quoted 5 lines · Tejun Heo

Hello,

These are equivalent conversions that are part of tree-wide conversion. I'll route these through the workqueue tree in a day or two. Please holler if there are any objections.

Thanks a lot!

Quoted 5 lines

Thanks.

Signature · 1 line
tejun
Signature · 2 lines
Frederic Weisbecker
SUSE Labs
#10 lore raw
In reply to Tejun Heo
Quoted 8 lines · Tejun Heo

Hello,

These are equivalent conversions that are part of tree-wide conversion. I'll route these through the workqueue tree in a day or two. Please holler if there are any objections.

Thanks.

Many thanks!

Signature · 3 lines
Marco Crivellari

SUSE Labs
#11 lore raw
In reply to Marco Crivellari

Hello,

Quoted 7 lines

Marco Crivellari (6):
virt: acrn: Add WQ_PERCPU to alloc_workqueue users
media: synopsys: hdmirx: replace use of system_unbound_wq with system_dfl_wq
platform: cznic: turris-omnia-mcu: replace use of system_wq with system_percpu_wq
media: ddbridge: add WQ_PERCPU to alloc_workqueue users
rapidio: rio: add WQ_PERCPU to alloc_workqueue users
umh: replace use of system_unbound_wq with system_dfl_wq

Applied 1-6 to wq/for-7.2 with Acked-by from Dmitry Osipenko on patch 2 and Reviewed-by from Frederic Weisbecker on patch 6 carried over from the prior solo postings.

Thanks.

--
tejun

#12 lore raw
Quoted 11 lines · Tejun Heo
Quoted 7 lines

Marco Crivellari (6):
virt: acrn: Add WQ_PERCPU to alloc_workqueue users
media: synopsys: hdmirx: replace use of system_unbound_wq with system_dfl_wq
platform: cznic: turris-omnia-mcu: replace use of system_wq with system_percpu_wq
media: ddbridge: add WQ_PERCPU to alloc_workqueue users
rapidio: rio: add WQ_PERCPU to alloc_workqueue users
umh: replace use of system_unbound_wq with system_dfl_wq

Applied 1-6 to wq/for-7.2 with Acked-by from Dmitry Osipenko on patch 2 and Reviewed-by from Frederic Weisbecker on patch 6 carried over from the prior solo postings.

Many thanks, Tejun!

Signature · 3 lines
Marco Crivellari

SUSE Labs