* [PATCH v2 0/3] replace old wq(s), added WQ_PERCPU to alloc_workqueue
@ 2026-02-23 10:23 Marco Crivellari
2026-02-23 10:23 ` [PATCH v2 1/3] nvmet: replace use of system_wq with system_percpu_wq Marco Crivellari
` (3 more replies)
0 siblings, 4 replies; 10+ messages in thread
From: Marco Crivellari @ 2026-02-23 10:23 UTC (permalink / raw)
To: linux-kernel, linux-nvme
Cc: Tejun Heo, Lai Jiangshan, Frederic Weisbecker,
Sebastian Andrzej Siewior, Marco Crivellari, Michal Hocko,
Christoph Hellwig, Sagi Grimberg, Chaitanya Kulkarni, Justin Tee,
Naresh Gottumukkala, Paul Ely
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] Replace uses of system_wq
system_wq is a per-CPU workqueue, but his name is not clear.
Because of that, system_wq has been replaced with system_percpu_wq.
2) [P 2-3] add WQ_PERCPU to all relevant alloc_workqueue() users
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:
- improved commit logs
- rebased on v7.0-rc1
Marco Crivellari (3):
nvmet: replace use of system_wq with system_percpu_wq
nvme: add WQ_PERCPU to alloc_workqueue users
nvmet-fc: add WQ_PERCPU to alloc_workqueue users
drivers/nvme/target/admin-cmd.c | 2 +-
drivers/nvme/target/core.c | 5 +++--
drivers/nvme/target/fabrics-cmd-auth.c | 2 +-
drivers/nvme/target/fc.c | 6 +++---
drivers/nvme/target/tcp.c | 2 +-
5 files changed, 9 insertions(+), 8 deletions(-)
--
2.51.1
^ permalink raw reply [flat|nested] 10+ messages in thread
* [PATCH v2 1/3] nvmet: replace use of system_wq with system_percpu_wq
2026-02-23 10:23 [PATCH v2 0/3] replace old wq(s), added WQ_PERCPU to alloc_workqueue Marco Crivellari
@ 2026-02-23 10:23 ` Marco Crivellari
2026-03-20 7:57 ` Christoph Hellwig
2026-02-23 10:23 ` [PATCH v2 2/3] nvme: add WQ_PERCPU to alloc_workqueue users Marco Crivellari
` (2 subsequent siblings)
3 siblings, 1 reply; 10+ messages in thread
From: Marco Crivellari @ 2026-02-23 10:23 UTC (permalink / raw)
To: linux-kernel, linux-nvme
Cc: Tejun Heo, Lai Jiangshan, Frederic Weisbecker,
Sebastian Andrzej Siewior, Marco Crivellari, Michal Hocko,
Christoph Hellwig, Sagi Grimberg, Chaitanya Kulkarni
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.
Link: https://lore.kernel.org/all/20250221112003.1dSuoGyc@linutronix.de/
Suggested-by: Tejun Heo <tj@kernel.org>
Signed-off-by: Marco Crivellari <marco.crivellari@suse.com>
---
drivers/nvme/target/admin-cmd.c | 2 +-
drivers/nvme/target/fabrics-cmd-auth.c | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/nvme/target/admin-cmd.c b/drivers/nvme/target/admin-cmd.c
index 9de93f65d7d7..ed60e48ee82f 100644
--- a/drivers/nvme/target/admin-cmd.c
+++ b/drivers/nvme/target/admin-cmd.c
@@ -1603,7 +1603,7 @@ void nvmet_execute_keep_alive(struct nvmet_req *req)
pr_debug("ctrl %d update keep-alive timer for %d secs\n",
ctrl->cntlid, ctrl->kato);
- mod_delayed_work(system_wq, &ctrl->ka_work, ctrl->kato * HZ);
+ mod_delayed_work(system_percpu_wq, &ctrl->ka_work, ctrl->kato * HZ);
out:
nvmet_req_complete(req, status);
}
diff --git a/drivers/nvme/target/fabrics-cmd-auth.c b/drivers/nvme/target/fabrics-cmd-auth.c
index 5946681cb0e3..e039650945b1 100644
--- a/drivers/nvme/target/fabrics-cmd-auth.c
+++ b/drivers/nvme/target/fabrics-cmd-auth.c
@@ -391,7 +391,7 @@ void nvmet_execute_auth_send(struct nvmet_req *req)
req->sq->dhchap_step != NVME_AUTH_DHCHAP_MESSAGE_FAILURE2) {
unsigned long auth_expire_secs = ctrl->kato ? ctrl->kato : 120;
- mod_delayed_work(system_wq, &req->sq->auth_expired_work,
+ mod_delayed_work(system_percpu_wq, &req->sq->auth_expired_work,
auth_expire_secs * HZ);
goto complete;
}
--
2.52.0
^ permalink raw reply related [flat|nested] 10+ messages in thread
* [PATCH v2 2/3] nvme: add WQ_PERCPU to alloc_workqueue users
2026-02-23 10:23 [PATCH v2 0/3] replace old wq(s), added WQ_PERCPU to alloc_workqueue Marco Crivellari
2026-02-23 10:23 ` [PATCH v2 1/3] nvmet: replace use of system_wq with system_percpu_wq Marco Crivellari
@ 2026-02-23 10:23 ` Marco Crivellari
2026-03-20 7:58 ` Christoph Hellwig
2026-02-23 10:23 ` [PATCH v2 3/3] nvmet-fc: " Marco Crivellari
2026-03-24 15:23 ` [PATCH v2 0/3] replace old wq(s), added WQ_PERCPU to alloc_workqueue Keith Busch
3 siblings, 1 reply; 10+ messages in thread
From: Marco Crivellari @ 2026-02-23 10:23 UTC (permalink / raw)
To: linux-kernel, linux-nvme
Cc: Tejun Heo, Lai Jiangshan, Frederic Weisbecker,
Sebastian Andrzej Siewior, Marco Crivellari, Michal Hocko,
Christoph Hellwig, Sagi Grimberg, Chaitanya Kulkarni
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.
Link: https://lore.kernel.org/all/20250221112003.1dSuoGyc@linutronix.de/
Suggested-by: Tejun Heo <tj@kernel.org>
Signed-off-by: Marco Crivellari <marco.crivellari@suse.com>
---
drivers/nvme/target/core.c | 5 +++--
drivers/nvme/target/tcp.c | 2 +-
2 files changed, 4 insertions(+), 3 deletions(-)
diff --git a/drivers/nvme/target/core.c b/drivers/nvme/target/core.c
index 5e43d0acc86e..376d38b62da2 100644
--- a/drivers/nvme/target/core.c
+++ b/drivers/nvme/target/core.c
@@ -1942,12 +1942,13 @@ static int __init nvmet_init(void)
if (!nvmet_bvec_cache)
return -ENOMEM;
- zbd_wq = alloc_workqueue("nvmet-zbd-wq", WQ_MEM_RECLAIM, 0);
+ zbd_wq = alloc_workqueue("nvmet-zbd-wq", WQ_MEM_RECLAIM | WQ_PERCPU,
+ 0);
if (!zbd_wq)
goto out_destroy_bvec_cache;
buffered_io_wq = alloc_workqueue("nvmet-buffered-io-wq",
- WQ_MEM_RECLAIM, 0);
+ WQ_MEM_RECLAIM | WQ_PERCPU, 0);
if (!buffered_io_wq)
goto out_free_zbd_work_queue;
diff --git a/drivers/nvme/target/tcp.c b/drivers/nvme/target/tcp.c
index acc71a26733f..4b8b02341ddc 100644
--- a/drivers/nvme/target/tcp.c
+++ b/drivers/nvme/target/tcp.c
@@ -2225,7 +2225,7 @@ static int __init nvmet_tcp_init(void)
int ret;
nvmet_tcp_wq = alloc_workqueue("nvmet_tcp_wq",
- WQ_MEM_RECLAIM | WQ_HIGHPRI, 0);
+ WQ_MEM_RECLAIM | WQ_HIGHPRI | WQ_PERCPU, 0);
if (!nvmet_tcp_wq)
return -ENOMEM;
--
2.52.0
^ permalink raw reply related [flat|nested] 10+ messages in thread
* [PATCH v2 3/3] nvmet-fc: add WQ_PERCPU to alloc_workqueue users
2026-02-23 10:23 [PATCH v2 0/3] replace old wq(s), added WQ_PERCPU to alloc_workqueue Marco Crivellari
2026-02-23 10:23 ` [PATCH v2 1/3] nvmet: replace use of system_wq with system_percpu_wq Marco Crivellari
2026-02-23 10:23 ` [PATCH v2 2/3] nvme: add WQ_PERCPU to alloc_workqueue users Marco Crivellari
@ 2026-02-23 10:23 ` Marco Crivellari
2026-03-20 7:58 ` Christoph Hellwig
2026-03-24 15:23 ` [PATCH v2 0/3] replace old wq(s), added WQ_PERCPU to alloc_workqueue Keith Busch
3 siblings, 1 reply; 10+ messages in thread
From: Marco Crivellari @ 2026-02-23 10:23 UTC (permalink / raw)
To: linux-kernel, linux-nvme
Cc: Tejun Heo, Lai Jiangshan, Frederic Weisbecker,
Sebastian Andrzej Siewior, Marco Crivellari, Michal Hocko,
Christoph Hellwig, Sagi Grimberg, Chaitanya Kulkarni, Justin Tee,
Naresh Gottumukkala, Paul Ely
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.
Cc: Justin Tee <justin.tee@broadcom.com>
Cc: Naresh Gottumukkala <nareshgottumukkala83@gmail.com>
CC: Paul Ely <paul.ely@broadcom.com>
Link: https://lore.kernel.org/all/20250221112003.1dSuoGyc@linutronix.de/
Suggested-by: Tejun Heo <tj@kernel.org>
Signed-off-by: Marco Crivellari <marco.crivellari@suse.com>
---
drivers/nvme/target/fc.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/drivers/nvme/target/fc.c b/drivers/nvme/target/fc.c
index 4eaadc711c99..d161707559ce 100644
--- a/drivers/nvme/target/fc.c
+++ b/drivers/nvme/target/fc.c
@@ -792,9 +792,9 @@ nvmet_fc_alloc_target_queue(struct nvmet_fc_tgt_assoc *assoc,
if (!queue)
return NULL;
- queue->work_q = alloc_workqueue("ntfc%d.%d.%d", 0, 0,
- assoc->tgtport->fc_target_port.port_num,
- assoc->a_id, qid);
+ queue->work_q = alloc_workqueue("ntfc%d.%d.%d", WQ_PERCPU, 0,
+ assoc->tgtport->fc_target_port.port_num,
+ assoc->a_id, qid);
if (!queue->work_q)
goto out_free_queue;
--
2.52.0
^ permalink raw reply related [flat|nested] 10+ messages in thread
* Re: [PATCH v2 1/3] nvmet: replace use of system_wq with system_percpu_wq
2026-02-23 10:23 ` [PATCH v2 1/3] nvmet: replace use of system_wq with system_percpu_wq Marco Crivellari
@ 2026-03-20 7:57 ` Christoph Hellwig
2026-03-20 8:30 ` Sebastian Andrzej Siewior
0 siblings, 1 reply; 10+ messages in thread
From: Christoph Hellwig @ 2026-03-20 7:57 UTC (permalink / raw)
To: Marco Crivellari
Cc: linux-kernel, linux-nvme, Tejun Heo, Lai Jiangshan,
Frederic Weisbecker, Sebastian Andrzej Siewior, Michal Hocko,
Christoph Hellwig, Sagi Grimberg, Chaitanya Kulkarni
On Mon, Feb 23, 2026 at 11:23:27AM +0100, Marco Crivellari wrote:
> system_unbound_wq -> system_dfl_wq
"dfl" is a weird acronym, that doesn't really help understanding the
code. What does it even mean?
Either way given that this has already been picked, I guess we're stuck
with it, so:
Reviewed-by: Christoph Hellwig <hch@lst.de>
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH v2 2/3] nvme: add WQ_PERCPU to alloc_workqueue users
2026-02-23 10:23 ` [PATCH v2 2/3] nvme: add WQ_PERCPU to alloc_workqueue users Marco Crivellari
@ 2026-03-20 7:58 ` Christoph Hellwig
0 siblings, 0 replies; 10+ messages in thread
From: Christoph Hellwig @ 2026-03-20 7:58 UTC (permalink / raw)
To: Marco Crivellari
Cc: linux-kernel, linux-nvme, Tejun Heo, Lai Jiangshan,
Frederic Weisbecker, Sebastian Andrzej Siewior, Michal Hocko,
Christoph Hellwig, Sagi Grimberg, Chaitanya Kulkarni
Looks good:
Reviewed-by: Christoph Hellwig <hch@lst.de>
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH v2 3/3] nvmet-fc: add WQ_PERCPU to alloc_workqueue users
2026-02-23 10:23 ` [PATCH v2 3/3] nvmet-fc: " Marco Crivellari
@ 2026-03-20 7:58 ` Christoph Hellwig
0 siblings, 0 replies; 10+ messages in thread
From: Christoph Hellwig @ 2026-03-20 7:58 UTC (permalink / raw)
To: Marco Crivellari
Cc: linux-kernel, linux-nvme, Tejun Heo, Lai Jiangshan,
Frederic Weisbecker, Sebastian Andrzej Siewior, Michal Hocko,
Christoph Hellwig, Sagi Grimberg, Chaitanya Kulkarni, Justin Tee,
Naresh Gottumukkala, Paul Ely
Looks good:
Reviewed-by: Christoph Hellwig <hch@lst.de>
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH v2 1/3] nvmet: replace use of system_wq with system_percpu_wq
2026-03-20 7:57 ` Christoph Hellwig
@ 2026-03-20 8:30 ` Sebastian Andrzej Siewior
0 siblings, 0 replies; 10+ messages in thread
From: Sebastian Andrzej Siewior @ 2026-03-20 8:30 UTC (permalink / raw)
To: Christoph Hellwig
Cc: Marco Crivellari, linux-kernel, linux-nvme, Tejun Heo,
Lai Jiangshan, Frederic Weisbecker, Michal Hocko, Sagi Grimberg,
Chaitanya Kulkarni
On 2026-03-20 08:57:50 [+0100], Christoph Hellwig wrote:
> "dfl" is a weird acronym, that doesn't really help understanding the
> code. What does it even mean?
default
^ ^ ^
Sebastian
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH v2 0/3] replace old wq(s), added WQ_PERCPU to alloc_workqueue
2026-02-23 10:23 [PATCH v2 0/3] replace old wq(s), added WQ_PERCPU to alloc_workqueue Marco Crivellari
` (2 preceding siblings ...)
2026-02-23 10:23 ` [PATCH v2 3/3] nvmet-fc: " Marco Crivellari
@ 2026-03-24 15:23 ` Keith Busch
2026-03-24 15:30 ` Marco Crivellari
3 siblings, 1 reply; 10+ messages in thread
From: Keith Busch @ 2026-03-24 15:23 UTC (permalink / raw)
To: Marco Crivellari
Cc: linux-kernel, linux-nvme, Tejun Heo, Lai Jiangshan,
Frederic Weisbecker, Sebastian Andrzej Siewior, Michal Hocko,
Christoph Hellwig, Sagi Grimberg, Chaitanya Kulkarni, Justin Tee,
Naresh Gottumukkala, Paul Ely
On Mon, Feb 23, 2026 at 11:23:26AM +0100, Marco Crivellari wrote:
> 1) [P 1] Replace uses of system_wq
>
> system_wq is a per-CPU workqueue, but his name is not clear.
> Because of that, system_wq has been replaced with system_percpu_wq.
>
> 2) [P 2-3] add WQ_PERCPU to all relevant alloc_workqueue() users
>
> 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 applied to nvme-7.1.
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH v2 0/3] replace old wq(s), added WQ_PERCPU to alloc_workqueue
2026-03-24 15:23 ` [PATCH v2 0/3] replace old wq(s), added WQ_PERCPU to alloc_workqueue Keith Busch
@ 2026-03-24 15:30 ` Marco Crivellari
0 siblings, 0 replies; 10+ messages in thread
From: Marco Crivellari @ 2026-03-24 15:30 UTC (permalink / raw)
To: Keith Busch
Cc: linux-kernel, linux-nvme, Tejun Heo, Lai Jiangshan,
Frederic Weisbecker, Sebastian Andrzej Siewior, Michal Hocko,
Christoph Hellwig, Sagi Grimberg, Chaitanya Kulkarni, Justin Tee,
Naresh Gottumukkala, Paul Ely
On Tue, Mar 24, 2026 at 4:23 PM Keith Busch <kbusch@kernel.org> wrote:
> [...]
> Thanks applied to nvme-7.1.
Many thanks!
--
Marco Crivellari
L3 Support Engineer
^ permalink raw reply [flat|nested] 10+ messages in thread
end of thread, other threads:[~2026-03-24 15:30 UTC | newest]
Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-02-23 10:23 [PATCH v2 0/3] replace old wq(s), added WQ_PERCPU to alloc_workqueue Marco Crivellari
2026-02-23 10:23 ` [PATCH v2 1/3] nvmet: replace use of system_wq with system_percpu_wq Marco Crivellari
2026-03-20 7:57 ` Christoph Hellwig
2026-03-20 8:30 ` Sebastian Andrzej Siewior
2026-02-23 10:23 ` [PATCH v2 2/3] nvme: add WQ_PERCPU to alloc_workqueue users Marco Crivellari
2026-03-20 7:58 ` Christoph Hellwig
2026-02-23 10:23 ` [PATCH v2 3/3] nvmet-fc: " Marco Crivellari
2026-03-20 7:58 ` Christoph Hellwig
2026-03-24 15:23 ` [PATCH v2 0/3] replace old wq(s), added WQ_PERCPU to alloc_workqueue Keith Busch
2026-03-24 15:30 ` Marco Crivellari
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox