Skip to contentSkip to conversation

Add WQ_PERCPU to alloc_workqueue users

PATCH Applied Marco Crivellari 2 participants 8 messages Feb 23 – Apr 20

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

v2 cover Add WQ_PERCPU to alloc_workqueue users

Hi,

Recently the workqueue code has been changed introducing two new workqueue, system_percpu_wq and system_dfl_wq, as a future replacement for system_wq and system_unbound_wq respectively, and a new flag, alloc_workqueue() WQ_PERCPU. This flag must be used when WQ_UNBOUND is not present, making explicit the workqueue is per-cpu.

The changes has been introduced by:
commit 128ea9f6ccfb ("workqueue: Add system_percpu_wq and system_dfl_wq") commit 930c2ea566af ("workqueue: Add new WQ_PERCPU flag")

The old workqueue(s) will be removed in a next release cycle.

=== Introduced Changes by this series ===

1) [P 1-2] add WQ_PERCPU 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 v2:
- patches unified in 1 series
- rebase on v7.0-rc1

Marco Crivellari (2):
block: Add WQ_PERCPU to alloc_workqueue users block/blk-throttle: Add WQ_PERCPU to alloc_workqueue users

 block/bio-integrity-auto.c | 2 +-
 block/bio.c                | 2 +-
 block/blk-core.c           | 2 +-
 block/blk-throttle.c       | 2 +-
 4 files changed, 4 insertions(+), 4 deletions(-)
Signature · 1 line
2.52.0
#1 lore raw

PATCH v2 1/2 block: 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.

---
 block/bio-integrity-auto.c | 2 +-
 block/bio.c                | 2 +-
 block/blk-core.c           | 2 +-
 3 files changed, 3 insertions(+), 3 deletions(-)
block/bio-integrity-auto.c +1 -1
index 44dcdf7520c5..a2bccb3c4baa 100644
@@ -183,7 +183,7 @@ static int __init blk_integrity_auto_init(void)
 	 * Make it highpri CPU intensive wq with max concurrency of 1.
 	 */
 	kintegrityd_wq = alloc_workqueue("kintegrityd", WQ_MEM_RECLAIM |
-					 WQ_HIGHPRI | WQ_CPU_INTENSIVE, 1);
+					 WQ_HIGHPRI | WQ_CPU_INTENSIVE | WQ_PERCPU, 1);
 	if (!kintegrityd_wq)
 		panic("Failed to create kintegrityd\n");
 	return 0;
block/bio.c +1 -1
index d80d5d26804e..fd8073fbffb2 100644
@@ -1956,7 +1956,7 @@ int bioset_init(struct bio_set *bs,
 
 	if (flags & BIOSET_NEED_RESCUER) {
 		bs->rescue_workqueue = alloc_workqueue("bioset",
-							WQ_MEM_RECLAIM, 0);
+							WQ_MEM_RECLAIM | WQ_PERCPU, 0);
 		if (!bs->rescue_workqueue)
 			goto bad;
 	}
block/blk-core.c +1 -1
index 474700ffaa1c..17450058ea6d 100644
@@ -1282,7 +1282,7 @@ int __init blk_dev_init(void)
 
 	/* used for unplugging and affects IO latency/throughput - HIGHPRI */
 	kblockd_workqueue = alloc_workqueue("kblockd",
-					    WQ_MEM_RECLAIM | WQ_HIGHPRI, 0);
+					    WQ_MEM_RECLAIM | WQ_HIGHPRI | WQ_PERCPU, 0);
 	if (!kblockd_workqueue)
 		panic("Failed to create kblockd\n");
 
Signature · 1 line
2.52.0
#2 lore raw

PATCH v2 2/2 block/blk-throttle: 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.

---
 block/blk-throttle.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
block/blk-throttle.c +1 -1
index 97188a795848..cabf91f0d0dc 100644
@@ -1839,7 +1839,7 @@ void blk_throtl_exit(struct gendisk *disk)
 
 static int __init throtl_init(void)
 {
-	kthrotld_workqueue = alloc_workqueue("kthrotld", WQ_MEM_RECLAIM, 0);
+	kthrotld_workqueue = alloc_workqueue("kthrotld", WQ_MEM_RECLAIM | WQ_PERCPU, 0);
 	if (!kthrotld_workqueue)
 		panic("Failed to create kthrotld\n");
 
Signature · 1 line
2.52.0
#3 lore raw
In reply to Marco Crivellari
Quoted 4 lines · Marco Crivellari

[...]
Marco Crivellari (2):
block: Add WQ_PERCPU to alloc_workqueue users block/blk-throttle: Add WQ_PERCPU to alloc_workqueue users

Hi,

Gentle ping.

Thanks!

Signature · 3 lines
Marco Crivellari

L3 Support Engineer
#4 lore raw
In reply to Marco Crivellari
Quoted 10 lines · Marco Crivellari

[...]
Marco Crivellari (2):
block: Add WQ_PERCPU to alloc_workqueue users block/blk-throttle: Add WQ_PERCPU to alloc_workqueue users

 block/bio-integrity-auto.c | 2 +-
 block/bio.c                | 2 +-
 block/blk-core.c           | 2 +-
 block/blk-throttle.c       | 2 +-
 4 files changed, 4 insertions(+), 4 deletions(-)

Hi,

Gentle ping.

Thanks!

Signature · 3 lines
Marco Crivellari

L3 Support Engineer
#5 lore raw
In reply to Marco Crivellari
Quoted 10 lines · Marco Crivellari

[...]
Marco Crivellari (2):
block: Add WQ_PERCPU to alloc_workqueue users block/blk-throttle: Add WQ_PERCPU to alloc_workqueue users

 block/bio-integrity-auto.c | 2 +-
 block/bio.c                | 2 +-
 block/blk-core.c           | 2 +-
 block/blk-throttle.c       | 2 +-
 4 files changed, 4 insertions(+), 4 deletions(-)

Hi,

Gentle ping.

Thanks!

Signature · 3 lines
Marco Crivellari

SUSE Labs
maintainer Applied
#6 lore raw
In reply to Marco Crivellari
Quoted 11 lines · Marco Crivellari

Recently the workqueue code has been changed introducing two new workqueue, system_percpu_wq and system_dfl_wq, as a future replacement for system_wq and system_unbound_wq respectively, and a new flag, alloc_workqueue() WQ_PERCPU. This flag must be used when WQ_UNBOUND is not present, making explicit the workqueue is per-cpu.

The changes has been introduced by:
commit 128ea9f6ccfb ("workqueue: Add system_percpu_wq and system_dfl_wq") commit 930c2ea566af ("workqueue: Add new WQ_PERCPU flag")

[...]

Applied, thanks!

[1/2] block: Add WQ_PERCPU to alloc_workqueue users

      commit: 98236343bb5dbbf3fcb3260795be2bbb1e3d2001
[2/2] block/blk-throttle: Add WQ_PERCPU to alloc_workqueue users
      commit: 19d32966e1f68623ac9d95fbcf34b1fb1a7be48d

Best regards,

Signature · 1 line
Jens Axboe
#7 lore raw
Quoted 7 lines · Jens Axboe

[...]
Applied, thanks!

[1/2] block: Add WQ_PERCPU to alloc_workqueue users

      commit: 98236343bb5dbbf3fcb3260795be2bbb1e3d2001
[2/2] block/blk-throttle: Add WQ_PERCPU to alloc_workqueue users
      commit: 19d32966e1f68623ac9d95fbcf34b1fb1a7be48d

Many thanks!

Signature · 3 lines
Marco Crivellari

SUSE Labs