* [PATCH 0/3] replace old wq(s), added WQ_PERCPU to alloc_workqueue
@ 2025-11-04 11:25 Marco Crivellari
2025-11-04 11:25 ` [PATCH 1/3] nvmet: replace use of system_wq with system_percpu_wq Marco Crivellari
` (2 more replies)
0 siblings, 3 replies; 6+ messages in thread
From: Marco Crivellari @ 2025-11-04 11:25 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!
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] 6+ messages in thread
* [PATCH 1/3] nvmet: replace use of system_wq with system_percpu_wq
2025-11-04 11:25 [PATCH 0/3] replace old wq(s), added WQ_PERCPU to alloc_workqueue Marco Crivellari
@ 2025-11-04 11:25 ` Marco Crivellari
2025-11-04 11:25 ` [PATCH 2/3] nvme: add WQ_PERCPU to alloc_workqueue users Marco Crivellari
2025-11-04 11:25 ` [PATCH 3/3] nvmet-fc: " Marco Crivellari
2 siblings, 0 replies; 6+ messages in thread
From: Marco Crivellari @ 2025-11-04 11:25 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
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.
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")
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.
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 3e378153a781..29281f410cc6 100644
--- a/drivers/nvme/target/admin-cmd.c
+++ b/drivers/nvme/target/admin-cmd.c
@@ -1604,7 +1604,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 bf01ec414c55..8f504bf891de 100644
--- a/drivers/nvme/target/fabrics-cmd-auth.c
+++ b/drivers/nvme/target/fabrics-cmd-auth.c
@@ -390,7 +390,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.51.1
^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH 2/3] nvme: add WQ_PERCPU to alloc_workqueue users
2025-11-04 11:25 [PATCH 0/3] replace old wq(s), added WQ_PERCPU to alloc_workqueue Marco Crivellari
2025-11-04 11:25 ` [PATCH 1/3] nvmet: replace use of system_wq with system_percpu_wq Marco Crivellari
@ 2025-11-04 11:25 ` Marco Crivellari
2025-11-04 11:25 ` [PATCH 3/3] nvmet-fc: " Marco Crivellari
2 siblings, 0 replies; 6+ messages in thread
From: Marco Crivellari @ 2025-11-04 11:25 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
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.
alloc_workqueue() treats all queues as per-CPU by default, while unbound
workqueues must opt-in via WQ_UNBOUND.
This default is suboptimal: most workloads benefit from unbound queues,
allowing the scheduler to place worker threads where they’re needed and
reducing noise when CPUs are isolated.
This change adds a new WQ_PERCPU flag to explicitly request alloc_workqueue()
to be per-cpu when WQ_UNBOUND has not been specified.
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")
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.
Once migration is complete, WQ_UNBOUND can be removed and unbound will
become the implicit default.
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 5d7d483bfbe3..ae8e903b55ad 100644
--- a/drivers/nvme/target/core.c
+++ b/drivers/nvme/target/core.c
@@ -1943,12 +1943,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 470bf37e5a63..fa7a56626bcc 100644
--- a/drivers/nvme/target/tcp.c
+++ b/drivers/nvme/target/tcp.c
@@ -2198,7 +2198,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.51.1
^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH 3/3] nvmet-fc: add WQ_PERCPU to alloc_workqueue users
2025-11-04 11:25 [PATCH 0/3] replace old wq(s), added WQ_PERCPU to alloc_workqueue Marco Crivellari
2025-11-04 11:25 ` [PATCH 1/3] nvmet: replace use of system_wq with system_percpu_wq Marco Crivellari
2025-11-04 11:25 ` [PATCH 2/3] nvme: add WQ_PERCPU to alloc_workqueue users Marco Crivellari
@ 2025-11-04 11:25 ` Marco Crivellari
2025-11-04 22:39 ` Justin Tee
2026-01-13 9:09 ` Marco Crivellari
2 siblings, 2 replies; 6+ messages in thread
From: Marco Crivellari @ 2025-11-04 11:25 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
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.
alloc_workqueue() treats all queues as per-CPU by default, while unbound
workqueues must opt-in via WQ_UNBOUND.
This default is suboptimal: most workloads benefit from unbound queues,
allowing the scheduler to place worker threads where they’re needed and
reducing noise when CPUs are isolated.
This change adds a new WQ_PERCPU flag to explicitly request alloc_workqueue()
to be per-cpu when WQ_UNBOUND has not been specified.
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")
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.
Once migration is complete, WQ_UNBOUND can be removed and unbound will
become the implicit default.
Cc: Justin Tee <justin.tee@broadcom.com>
Cc: Naresh Gottumukkala <nareshgottumukkala83@gmail.com>
CC: Paul Ely <paul.ely@broadcom.com>
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 7d84527d5a43..ac730f2e6ea1 100644
--- a/drivers/nvme/target/fc.c
+++ b/drivers/nvme/target/fc.c
@@ -795,9 +795,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.51.1
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH 3/3] nvmet-fc: add WQ_PERCPU to alloc_workqueue users
2025-11-04 11:25 ` [PATCH 3/3] nvmet-fc: " Marco Crivellari
@ 2025-11-04 22:39 ` Justin Tee
2026-01-13 9:09 ` Marco Crivellari
1 sibling, 0 replies; 6+ messages in thread
From: Justin Tee @ 2025-11-04 22:39 UTC (permalink / raw)
To: Marco Crivellari, linux-kernel, linux-nvme
Cc: Tejun Heo, Lai Jiangshan, Frederic Weisbecker,
Sebastian Andrzej Siewior, Michal Hocko, Christoph Hellwig,
Sagi Grimberg, Chaitanya Kulkarni, Justin Tee,
Naresh Gottumukkala, Paul Ely
Reviewed-by: Justin Tee <justin.tee@broadcom.com>
Regards,
Justin
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH 3/3] nvmet-fc: add WQ_PERCPU to alloc_workqueue users
2025-11-04 11:25 ` [PATCH 3/3] nvmet-fc: " Marco Crivellari
2025-11-04 22:39 ` Justin Tee
@ 2026-01-13 9:09 ` Marco Crivellari
1 sibling, 0 replies; 6+ messages in thread
From: Marco Crivellari @ 2026-01-13 9:09 UTC (permalink / raw)
To: linux-kernel, linux-nvme
Cc: 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, Nov 4, 2025 at 12:25 PM Marco Crivellari
<marco.crivellari@suse.com> wrote:
> [...]
> 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 7d84527d5a43..ac730f2e6ea1 100644
> --- a/drivers/nvme/target/fc.c
> +++ b/drivers/nvme/target/fc.c
Hi,
Gentle ping.
Thanks!
--
Marco Crivellari
L3 Support Engineer
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2026-01-13 9:09 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-11-04 11:25 [PATCH 0/3] replace old wq(s), added WQ_PERCPU to alloc_workqueue Marco Crivellari
2025-11-04 11:25 ` [PATCH 1/3] nvmet: replace use of system_wq with system_percpu_wq Marco Crivellari
2025-11-04 11:25 ` [PATCH 2/3] nvme: add WQ_PERCPU to alloc_workqueue users Marco Crivellari
2025-11-04 11:25 ` [PATCH 3/3] nvmet-fc: " Marco Crivellari
2025-11-04 22:39 ` Justin Tee
2026-01-13 9:09 ` Marco Crivellari
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®