* [PATCH v2 0/3] s390: replace wq users and add WQ_PERCPU to alloc_workqueue() users
@ 2025-09-17 15:38 Marco Crivellari
2025-09-17 15:38 ` [PATCH v2 1/3] drivers/s390: WQ_PERCPU added to alloc_workqueue users Marco Crivellari
` (3 more replies)
0 siblings, 4 replies; 8+ messages in thread
From: Marco Crivellari @ 2025-09-17 15:38 UTC (permalink / raw)
To: linux-kernel, linux-s390
Cc: Tejun Heo, Lai Jiangshan, Frederic Weisbecker,
Sebastian Andrzej Siewior, Marco Crivellari, Michal Hocko,
Alexander Gordeev, Vasily Gorbik, Heiko Carstens
Hi!
Below is a summary of a discussion about the Workqueue API and cpu isolation
considerations. Details and more information are available here:
"workqueue: Always use wq_select_unbound_cpu() for WORK_CPU_UNBOUND."
https://lore.kernel.org/all/20250221112003.1dSuoGyc@linutronix.de/
=== 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 consistentcy cannot be addressed without refactoring the API.
=== Plan and future plans ===
This patchset is the first stone on a refactoring needed in order to
address the points aforementioned; it will have a positive impact also
on the cpu isolation, in the long term, moving away percpu workqueue in
favor to an unbound model.
These are the main steps:
1) API refactoring (that this patch is introducing)
- Make more clear and uniform the system wq names, both per-cpu and
unbound. This to avoid any possible confusion on what should be
used.
- Introduction of WQ_PERCPU: this flag is the complement of WQ_UNBOUND,
introduced in this patchset and used on all the callers that are not
currently using WQ_UNBOUND.
WQ_UNBOUND will be removed in a future release cycle.
Most users don't need to be per-cpu, because they don't have
locality requirements, because of that, a next future step will be
make "unbound" the default behavior.
2) Check who really needs to be per-cpu
- Remove the WQ_PERCPU flag when is not strictly required.
3) Add a new API (prefer local cpu)
- There are users that don't require a local execution, like mentioned
above; despite that, local execution yeld to performance gain.
This new API will prefer the local execution, without requiring it.
=== Introduced Changes by this series ===
1) [P 1] add WQ_PERCPU to remaining alloc_workqueue() users
Every alloc_workqueue() caller should use one among WQ_PERCPU or
WQ_UNBOUND. WQ_PERCPU has been added to every user that is not
actually using WQ_UNBOUND.
WQ_UNBOUND will be removed in a next release cycle.
2) [P 2] Replace use of system_wq
system_wq is a per-CPU workqueue, but his name is not clear.
Because of that, system_wq has been renamed in system_percpu_wq.
3) [P 3] Replace use of system_wq with system_dfl_wq
(arch/s390/kernel/hiperdispatch.c)
system_wq is a per-cpu wq but hiperdispatch users does not benefit
from it. This has been changed with system_dfl_wq (the new unbound wq).
Thanks!
---
Changes in v2:
- New in the series, 2/3: arch/s390/kernel/hiperdispatch.c does not benefit from
system_wq: this has been converted directly to system_unbound_wq.
- the others system_wq users are converted to system_percpu_wq in patch 3/3
Marco Crivellari (3):
drivers/s390: WQ_PERCPU added to alloc_workqueue users
s390/diag324: replace use of system_wq with system_percpu_wq
s390: replace use of system_wq with system_dfl_wq
arch/s390/kernel/diag/diag324.c | 4 ++--
arch/s390/kernel/hiperdispatch.c | 2 +-
drivers/s390/char/tape_3590.c | 2 +-
3 files changed, 4 insertions(+), 4 deletions(-)
--
2.51.0
^ permalink raw reply [flat|nested] 8+ messages in thread
* [PATCH v2 1/3] drivers/s390: WQ_PERCPU added to alloc_workqueue users
2025-09-17 15:38 [PATCH v2 0/3] s390: replace wq users and add WQ_PERCPU to alloc_workqueue() users Marco Crivellari
@ 2025-09-17 15:38 ` Marco Crivellari
2025-09-17 15:38 ` [PATCH v2 2/3] s390/diag324: replace use of system_wq with system_percpu_wq Marco Crivellari
` (2 subsequent siblings)
3 siblings, 0 replies; 8+ messages in thread
From: Marco Crivellari @ 2025-09-17 15:38 UTC (permalink / raw)
To: linux-kernel, linux-s390
Cc: Tejun Heo, Lai Jiangshan, Frederic Weisbecker,
Sebastian Andrzej Siewior, Marco Crivellari, Michal Hocko,
Alexander Gordeev, Vasily Gorbik, Heiko Carstens
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 patch adds a new WQ_PERCPU flag to explicitly request the use of
the per-CPU behavior. Both flags coexist for one release cycle to allow
callers to transition their calls.
Once migration is complete, WQ_UNBOUND can be removed and unbound will
become the implicit 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.
All existing users have been updated accordingly.
Suggested-by: Tejun Heo <tj@kernel.org>
Signed-off-by: Marco Crivellari <marco.crivellari@suse.com>
Acked-by: Alexander Gordeev <agordeev@linux.ibm.com>
---
drivers/s390/char/tape_3590.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/s390/char/tape_3590.c b/drivers/s390/char/tape_3590.c
index a1bafaf73f87..2a2931d303cb 100644
--- a/drivers/s390/char/tape_3590.c
+++ b/drivers/s390/char/tape_3590.c
@@ -1671,7 +1671,7 @@ tape_3590_init(void)
DBF_EVENT(3, "3590 init\n");
- tape_3590_wq = alloc_workqueue("tape_3590", 0, 0);
+ tape_3590_wq = alloc_workqueue("tape_3590", WQ_PERCPU, 0);
if (!tape_3590_wq)
return -ENOMEM;
--
2.51.0
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [PATCH v2 2/3] s390/diag324: replace use of system_wq with system_percpu_wq
2025-09-17 15:38 [PATCH v2 0/3] s390: replace wq users and add WQ_PERCPU to alloc_workqueue() users Marco Crivellari
2025-09-17 15:38 ` [PATCH v2 1/3] drivers/s390: WQ_PERCPU added to alloc_workqueue users Marco Crivellari
@ 2025-09-17 15:38 ` Marco Crivellari
2025-09-17 15:38 ` [PATCH v2 3/3] s390: replace use of system_wq with system_dfl_wq Marco Crivellari
2025-09-24 9:03 ` [PATCH v2 0/3] s390: replace wq users and add WQ_PERCPU to alloc_workqueue() users Heiko Carstens
3 siblings, 0 replies; 8+ messages in thread
From: Marco Crivellari @ 2025-09-17 15:38 UTC (permalink / raw)
To: linux-kernel, linux-s390
Cc: Tejun Heo, Lai Jiangshan, Frederic Weisbecker,
Sebastian Andrzej Siewior, Marco Crivellari, Michal Hocko,
Alexander Gordeev, Vasily Gorbik, Heiko Carstens
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.
system_wq is a per-CPU worqueue, yet nothing in its name tells about that
CPU affinity constraint, which is very often not required by users. Make
it clear by renaming system_wq to system_percpu_wq.
queue_work() / queue_delayed_work() mod_delayed_work() will now use the
new per-cpu wq.
The old wq will be kept for a few release cylces.
Suggested-by: Tejun Heo <tj@kernel.org>
Signed-off-by: Marco Crivellari <marco.crivellari@suse.com>
---
arch/s390/kernel/diag/diag324.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/arch/s390/kernel/diag/diag324.c b/arch/s390/kernel/diag/diag324.c
index 7fa4c0b7eb6c..f0a8b4841fb9 100644
--- a/arch/s390/kernel/diag/diag324.c
+++ b/arch/s390/kernel/diag/diag324.c
@@ -116,7 +116,7 @@ static void pibwork_handler(struct work_struct *work)
mutex_lock(&pibmutex);
timedout = ktime_add_ns(data->expire, PIBWORK_DELAY);
if (ktime_before(ktime_get(), timedout)) {
- mod_delayed_work(system_wq, &pibwork, nsecs_to_jiffies(PIBWORK_DELAY));
+ mod_delayed_work(system_percpu_wq, &pibwork, nsecs_to_jiffies(PIBWORK_DELAY));
goto out;
}
vfree(data->pib);
@@ -174,7 +174,7 @@ long diag324_pibbuf(unsigned long arg)
pib_update(data);
data->sequence++;
data->expire = ktime_add_ns(ktime_get(), tod_to_ns(data->pib->intv));
- mod_delayed_work(system_wq, &pibwork, nsecs_to_jiffies(PIBWORK_DELAY));
+ mod_delayed_work(system_percpu_wq, &pibwork, nsecs_to_jiffies(PIBWORK_DELAY));
first = false;
}
rc = data->rc;
--
2.51.0
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [PATCH v2 3/3] s390: replace use of system_wq with system_dfl_wq
2025-09-17 15:38 [PATCH v2 0/3] s390: replace wq users and add WQ_PERCPU to alloc_workqueue() users Marco Crivellari
2025-09-17 15:38 ` [PATCH v2 1/3] drivers/s390: WQ_PERCPU added to alloc_workqueue users Marco Crivellari
2025-09-17 15:38 ` [PATCH v2 2/3] s390/diag324: replace use of system_wq with system_percpu_wq Marco Crivellari
@ 2025-09-17 15:38 ` Marco Crivellari
2025-09-24 8:05 ` Mete Durlu
2025-09-24 9:03 ` [PATCH v2 0/3] s390: replace wq users and add WQ_PERCPU to alloc_workqueue() users Heiko Carstens
3 siblings, 1 reply; 8+ messages in thread
From: Marco Crivellari @ 2025-09-17 15:38 UTC (permalink / raw)
To: linux-kernel, linux-s390
Cc: Tejun Heo, Lai Jiangshan, Frederic Weisbecker,
Sebastian Andrzej Siewior, Marco Crivellari, Michal Hocko,
Alexander Gordeev, Vasily Gorbik, Heiko Carstens
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.
system_wq is a per-CPU worqueue (replaced by system_percpu_wq), but the
current code does not benefit from it. Because of that, system_wq has been
replaced by system_dfl_wq, the new unbound workqueue.
The old wq will be kept for a few release cylces.
Suggested-by: Tejun Heo <tj@kernel.org>
Signed-off-by: Marco Crivellari <marco.crivellari@suse.com>
---
arch/s390/kernel/hiperdispatch.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/arch/s390/kernel/hiperdispatch.c b/arch/s390/kernel/hiperdispatch.c
index e7b66d046e8d..2507bc3f7757 100644
--- a/arch/s390/kernel/hiperdispatch.c
+++ b/arch/s390/kernel/hiperdispatch.c
@@ -191,7 +191,7 @@ int hd_enable_hiperdispatch(void)
return 0;
if (hd_online_cores <= hd_entitled_cores)
return 0;
- mod_delayed_work(system_wq, &hd_capacity_work, HD_DELAY_INTERVAL * hd_delay_factor);
+ mod_delayed_work(system_dfl_wq, &hd_capacity_work, HD_DELAY_INTERVAL * hd_delay_factor);
hd_update_capacities();
return 1;
}
--
2.51.0
^ permalink raw reply related [flat|nested] 8+ messages in thread
* Re: [PATCH v2 3/3] s390: replace use of system_wq with system_dfl_wq
2025-09-17 15:38 ` [PATCH v2 3/3] s390: replace use of system_wq with system_dfl_wq Marco Crivellari
@ 2025-09-24 8:05 ` Mete Durlu
2025-09-24 8:11 ` Marco Crivellari
0 siblings, 1 reply; 8+ messages in thread
From: Mete Durlu @ 2025-09-24 8:05 UTC (permalink / raw)
To: Marco Crivellari, linux-kernel, linux-s390
Cc: Tejun Heo, Lai Jiangshan, Frederic Weisbecker,
Sebastian Andrzej Siewior, Michal Hocko, Alexander Gordeev,
Vasily Gorbik, Heiko Carstens
On 9/17/25 5:38 PM, Marco Crivellari wrote:
> 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.
>
> system_wq is a per-CPU worqueue (replaced by system_percpu_wq), but the
> current code does not benefit from it. Because of that, system_wq has been
> replaced by system_dfl_wq, the new unbound workqueue.
That sounds right. Thanks!
> The old wq will be kept for a few release cylces.
>
> Suggested-by: Tejun Heo <tj@kernel.org>
> Signed-off-by: Marco Crivellari <marco.crivellari@suse.com>
> ---
> arch/s390/kernel/hiperdispatch.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/arch/s390/kernel/hiperdispatch.c b/arch/s390/kernel/hiperdispatch.c
> index e7b66d046e8d..2507bc3f7757 100644
> --- a/arch/s390/kernel/hiperdispatch.c
> +++ b/arch/s390/kernel/hiperdispatch.c
> @@ -191,7 +191,7 @@ int hd_enable_hiperdispatch(void)
> return 0;
> if (hd_online_cores <= hd_entitled_cores)
> return 0;
> - mod_delayed_work(system_wq, &hd_capacity_work, HD_DELAY_INTERVAL * hd_delay_factor);
> + mod_delayed_work(system_dfl_wq, &hd_capacity_work, HD_DELAY_INTERVAL * hd_delay_factor);
> hd_update_capacities();
> return 1;
> }
Thank you for making the change from *_percpu_wq to *_dfl_wq.
I am not sure if its too late but you can have my r-b
Reviewed-by: Mete Durlu <meted@linux.ibm.com>
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH v2 3/3] s390: replace use of system_wq with system_dfl_wq
2025-09-24 8:05 ` Mete Durlu
@ 2025-09-24 8:11 ` Marco Crivellari
0 siblings, 0 replies; 8+ messages in thread
From: Marco Crivellari @ 2025-09-24 8:11 UTC (permalink / raw)
To: Mete Durlu
Cc: linux-kernel, linux-s390, Tejun Heo, Lai Jiangshan,
Frederic Weisbecker, Sebastian Andrzej Siewior, Michal Hocko,
Alexander Gordeev, Vasily Gorbik, Heiko Carstens
On Wed, Sep 24, 2025 at 10:05 AM Mete Durlu <meted@linux.ibm.com> wrote:
> [...]
> Thank you for making the change from *_percpu_wq to *_dfl_wq.
> I am not sure if its too late but you can have my r-b
>
> Reviewed-by: Mete Durlu <meted@linux.ibm.com>
Many thanks, Mete! :-)
--
Marco Crivellari
L3 Support Engineer, Technology & Product
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH v2 0/3] s390: replace wq users and add WQ_PERCPU to alloc_workqueue() users
2025-09-17 15:38 [PATCH v2 0/3] s390: replace wq users and add WQ_PERCPU to alloc_workqueue() users Marco Crivellari
` (2 preceding siblings ...)
2025-09-17 15:38 ` [PATCH v2 3/3] s390: replace use of system_wq with system_dfl_wq Marco Crivellari
@ 2025-09-24 9:03 ` Heiko Carstens
2025-09-24 9:05 ` Marco Crivellari
3 siblings, 1 reply; 8+ messages in thread
From: Heiko Carstens @ 2025-09-24 9:03 UTC (permalink / raw)
To: Marco Crivellari
Cc: linux-kernel, linux-s390, Tejun Heo, Lai Jiangshan,
Frederic Weisbecker, Sebastian Andrzej Siewior, Michal Hocko,
Alexander Gordeev, Vasily Gorbik
On Wed, Sep 17, 2025 at 05:38:56PM +0200, Marco Crivellari wrote:
> This patchset is the first stone on a refactoring needed in order to
> address the points aforementioned; it will have a positive impact also
> on the cpu isolation, in the long term, moving away percpu workqueue in
> favor to an unbound model.
...
> ---
> Changes in v2:
> - New in the series, 2/3: arch/s390/kernel/hiperdispatch.c does not benefit from
> system_wq: this has been converted directly to system_unbound_wq.
> - the others system_wq users are converted to system_percpu_wq in patch 3/3
>
>
> Marco Crivellari (3):
> drivers/s390: WQ_PERCPU added to alloc_workqueue users
> s390/diag324: replace use of system_wq with system_percpu_wq
> s390: replace use of system_wq with system_dfl_wq
>
> arch/s390/kernel/diag/diag324.c | 4 ++--
> arch/s390/kernel/hiperdispatch.c | 2 +-
> drivers/s390/char/tape_3590.c | 2 +-
> 3 files changed, 4 insertions(+), 4 deletions(-)
Series applied, thanks!
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH v2 0/3] s390: replace wq users and add WQ_PERCPU to alloc_workqueue() users
2025-09-24 9:03 ` [PATCH v2 0/3] s390: replace wq users and add WQ_PERCPU to alloc_workqueue() users Heiko Carstens
@ 2025-09-24 9:05 ` Marco Crivellari
0 siblings, 0 replies; 8+ messages in thread
From: Marco Crivellari @ 2025-09-24 9:05 UTC (permalink / raw)
To: Heiko Carstens
Cc: linux-kernel, linux-s390, Tejun Heo, Lai Jiangshan,
Frederic Weisbecker, Sebastian Andrzej Siewior, Michal Hocko,
Alexander Gordeev, Vasily Gorbik
On Wed, Sep 24, 2025 at 11:03 AM Heiko Carstens <hca@linux.ibm.com> wrote:
> > Marco Crivellari (3):
> > drivers/s390: WQ_PERCPU added to alloc_workqueue users
> > s390/diag324: replace use of system_wq with system_percpu_wq
> > s390: replace use of system_wq with system_dfl_wq
> >
> > arch/s390/kernel/diag/diag324.c | 4 ++--
> > arch/s390/kernel/hiperdispatch.c | 2 +-
> > drivers/s390/char/tape_3590.c | 2 +-
> > 3 files changed, 4 insertions(+), 4 deletions(-)
>
> Series applied, thanks!
Many thanks, Heiko!
--
Marco Crivellari
L3 Support Engineer, Technology & Product
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2025-09-24 9:06 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-09-17 15:38 [PATCH v2 0/3] s390: replace wq users and add WQ_PERCPU to alloc_workqueue() users Marco Crivellari
2025-09-17 15:38 ` [PATCH v2 1/3] drivers/s390: WQ_PERCPU added to alloc_workqueue users Marco Crivellari
2025-09-17 15:38 ` [PATCH v2 2/3] s390/diag324: replace use of system_wq with system_percpu_wq Marco Crivellari
2025-09-17 15:38 ` [PATCH v2 3/3] s390: replace use of system_wq with system_dfl_wq Marco Crivellari
2025-09-24 8:05 ` Mete Durlu
2025-09-24 8:11 ` Marco Crivellari
2025-09-24 9:03 ` [PATCH v2 0/3] s390: replace wq users and add WQ_PERCPU to alloc_workqueue() users Heiko Carstens
2025-09-24 9:05 ` Marco Crivellari
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.