* [PATCH] char: xillybus: add WQ_PERCPU to alloc_workqueue users
@ 2025-11-06 16:30 Marco Crivellari
2025-11-07 14:52 ` Eli Billauer
0 siblings, 1 reply; 3+ messages in thread
From: Marco Crivellari @ 2025-11-06 16:30 UTC (permalink / raw)
To: linux-kernel
Cc: Tejun Heo, Lai Jiangshan, Frederic Weisbecker,
Sebastian Andrzej Siewior, Marco Crivellari, Michal Hocko,
Eli Billauer, Arnd Bergmann, Greg Kroah-Hartman
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.
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 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")
This change adds a new WQ_PERCPU flag to explicitly request alloc_workqueue()
to be per-cpu when WQ_UNBOUND has not been specified.
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/char/xillybus/xillybus_core.c | 2 +-
drivers/char/xillybus/xillyusb.c | 4 ++--
2 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/drivers/char/xillybus/xillybus_core.c b/drivers/char/xillybus/xillybus_core.c
index efb1ae834265..5f04963482e7 100644
--- a/drivers/char/xillybus/xillybus_core.c
+++ b/drivers/char/xillybus/xillybus_core.c
@@ -1973,7 +1973,7 @@ EXPORT_SYMBOL(xillybus_endpoint_remove);
static int __init xillybus_init(void)
{
- xillybus_wq = alloc_workqueue(xillyname, 0, 0);
+ xillybus_wq = alloc_workqueue(xillyname, WQ_PERCPU, 0);
if (!xillybus_wq)
return -ENOMEM;
diff --git a/drivers/char/xillybus/xillyusb.c b/drivers/char/xillybus/xillyusb.c
index 45771b1a3716..2a29e2be0296 100644
--- a/drivers/char/xillybus/xillyusb.c
+++ b/drivers/char/xillybus/xillyusb.c
@@ -2163,7 +2163,7 @@ static int xillyusb_probe(struct usb_interface *interface,
spin_lock_init(&xdev->error_lock);
xdev->in_counter = 0;
xdev->in_bytes_left = 0;
- xdev->workq = alloc_workqueue(xillyname, WQ_HIGHPRI, 0);
+ xdev->workq = alloc_workqueue(xillyname, WQ_HIGHPRI | WQ_PERCPU, 0);
if (!xdev->workq) {
dev_err(&interface->dev, "Failed to allocate work queue\n");
@@ -2275,7 +2275,7 @@ static int __init xillyusb_init(void)
{
int rc = 0;
- wakeup_wq = alloc_workqueue(xillyname, 0, 0);
+ wakeup_wq = alloc_workqueue(xillyname, WQ_PERCPU, 0);
if (!wakeup_wq)
return -ENOMEM;
--
2.51.1
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] char: xillybus: add WQ_PERCPU to alloc_workqueue users
2025-11-06 16:30 [PATCH] char: xillybus: add WQ_PERCPU to alloc_workqueue users Marco Crivellari
@ 2025-11-07 14:52 ` Eli Billauer
2025-11-07 14:57 ` Marco Crivellari
0 siblings, 1 reply; 3+ messages in thread
From: Eli Billauer @ 2025-11-07 14:52 UTC (permalink / raw)
To: Marco Crivellari, linux-kernel
Cc: Tejun Heo, Lai Jiangshan, Frederic Weisbecker,
Sebastian Andrzej Siewior, Michal Hocko, Arnd Bergmann,
Greg Kroah-Hartman
Hello Marco,
Thanks for this heads-up. Frankly speaking, I wasn't aware that the said
calls to alloc_workqueue() implicitly bind the queue to a CPU, and this
was never my intention. I agree that the better choice is an unbound
queue, at least in this case.
This seems to be an example for why the API change of alloc_workqueue()
is a good idea.
As for the patch itself, it perpetuates the incorrect choice, so I vote
against. If anything, WQ_UNBOUND should be added, but since it's going
to be the default (soon?), maybe just let it be, and let the planned
change in the API rectify this.
Thanks,
Eli
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] char: xillybus: add WQ_PERCPU to alloc_workqueue users
2025-11-07 14:52 ` Eli Billauer
@ 2025-11-07 14:57 ` Marco Crivellari
0 siblings, 0 replies; 3+ messages in thread
From: Marco Crivellari @ 2025-11-07 14:57 UTC (permalink / raw)
To: Eli Billauer
Cc: linux-kernel, Tejun Heo, Lai Jiangshan, Frederic Weisbecker,
Sebastian Andrzej Siewior, Michal Hocko, Arnd Bergmann,
Greg Kroah-Hartman
On Fri, Nov 7, 2025 at 3:53 PM Eli Billauer <eli.billauer@gmail.com> wrote:
>
> Hello Marco,
>
> Thanks for this heads-up. Frankly speaking, I wasn't aware that the said
> calls to alloc_workqueue() implicitly bind the queue to a CPU, and this
> was never my intention. I agree that the better choice is an unbound
> queue, at least in this case.
>
> This seems to be an example for why the API change of alloc_workqueue()
> is a good idea.
>
> As for the patch itself, it perpetuates the incorrect choice, so I vote
> against. If anything, WQ_UNBOUND should be added, but since it's going
> to be the default (soon?), maybe just let it be, and let the planned
> change in the API rectify this.
>
> Thanks,
> Eli
Hello Eli,
Considering this workload has no benefit being per-cpu, it's not a problem
send a v2 converting this with WQ_UNBOUND, in the meantime.
I've done the same for other subsystems. :-)
Thanks!
--
Marco Crivellari
L3 Support Engineer, Technology & Product
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2025-11-07 14:57 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-11-06 16:30 [PATCH] char: xillybus: add WQ_PERCPU to alloc_workqueue users Marco Crivellari
2025-11-07 14:52 ` Eli Billauer
2025-11-07 14:57 ` 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®