Skip to content

Commit 78f5d0d

Browse files
DispatchCodebjorn-helgaas
authored andcommitted
PCI: Add WQ_PERCPU to alloc_workqueue() users
Currently work items enqueued by schedule_delayed_work() use "system_wq" (a per-CPU wq), while queue_delayed_work() uses 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: 128ea9f ("workqueue: Add system_percpu_wq and system_dfl_wq") 930c2ea ("workqueue: Add new WQ_PERCPU flag") Add WQ_PERCPU 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> [bhelgaas: squash similar commits] Signed-off-by: Bjorn Helgaas <bhelgaas@google.com> Link: https://patch.msgid.link/20251107142526.234685-1-marco.crivellari@suse.com Link: https://patch.msgid.link/20251107142835.237636-1-marco.crivellari@suse.com Link: https://patch.msgid.link/20251107143108.240025-1-marco.crivellari@suse.com Link: https://patch.msgid.link/20251107143335.242342-1-marco.crivellari@suse.com Link: https://patch.msgid.link/20251107143624.244978-1-marco.crivellari@suse.com
1 parent 8f0b4cc commit 78f5d0d

6 files changed

Lines changed: 9 additions & 8 deletions

File tree

drivers/pci/endpoint/functions/pci-epf-mhi.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -686,7 +686,7 @@ static int pci_epf_mhi_dma_init(struct pci_epf_mhi *epf_mhi)
686686
goto err_release_tx;
687687
}
688688

689-
epf_mhi->dma_wq = alloc_workqueue("pci_epf_mhi_dma_wq", 0, 0);
689+
epf_mhi->dma_wq = alloc_workqueue("pci_epf_mhi_dma_wq", WQ_PERCPU, 0);
690690
if (!epf_mhi->dma_wq) {
691691
ret = -ENOMEM;
692692
goto err_release_rx;

drivers/pci/endpoint/functions/pci-epf-ntb.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2124,8 +2124,8 @@ static int __init epf_ntb_init(void)
21242124
{
21252125
int ret;
21262126

2127-
kpcintb_workqueue = alloc_workqueue("kpcintb", WQ_MEM_RECLAIM |
2128-
WQ_HIGHPRI, 0);
2127+
kpcintb_workqueue = alloc_workqueue("kpcintb",
2128+
WQ_MEM_RECLAIM | WQ_HIGHPRI | WQ_PERCPU, 0);
21292129
ret = pci_epf_register_driver(&epf_ntb_driver);
21302130
if (ret) {
21312131
destroy_workqueue(kpcintb_workqueue);

drivers/pci/endpoint/functions/pci-epf-test.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1188,7 +1188,7 @@ static int __init pci_epf_test_init(void)
11881188
int ret;
11891189

11901190
kpcitest_workqueue = alloc_workqueue("kpcitest",
1191-
WQ_MEM_RECLAIM | WQ_HIGHPRI, 0);
1191+
WQ_MEM_RECLAIM | WQ_HIGHPRI | WQ_PERCPU, 0);
11921192
if (!kpcitest_workqueue) {
11931193
pr_err("Failed to allocate the kpcitest work queue\n");
11941194
return -ENOMEM;

drivers/pci/endpoint/functions/pci-epf-vntb.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1651,8 +1651,8 @@ static int __init epf_ntb_init(void)
16511651
{
16521652
int ret;
16531653

1654-
kpcintb_workqueue = alloc_workqueue("kpcintb", WQ_MEM_RECLAIM |
1655-
WQ_HIGHPRI, 0);
1654+
kpcintb_workqueue = alloc_workqueue("kpcintb",
1655+
WQ_MEM_RECLAIM | WQ_HIGHPRI | WQ_PERCPU, 0);
16561656
ret = pci_epf_register_driver(&epf_ntb_driver);
16571657
if (ret) {
16581658
destroy_workqueue(kpcintb_workqueue);

drivers/pci/hotplug/pnv_php.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -802,7 +802,7 @@ static struct pnv_php_slot *pnv_php_alloc_slot(struct device_node *dn)
802802
}
803803

804804
/* Allocate workqueue for this slot's interrupt handling */
805-
php_slot->wq = alloc_workqueue("pciehp-%s", 0, 0, php_slot->name);
805+
php_slot->wq = alloc_workqueue("pciehp-%s", WQ_PERCPU, 0, php_slot->name);
806806
if (!php_slot->wq) {
807807
SLOT_WARN(php_slot, "Cannot alloc workqueue\n");
808808
kfree(php_slot->name);

drivers/pci/hotplug/shpchp_core.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,8 @@ static int init_slots(struct controller *ctrl)
8080
slot->device = ctrl->slot_device_offset + i;
8181
slot->number = ctrl->first_slot + (ctrl->slot_num_inc * i);
8282

83-
slot->wq = alloc_workqueue("shpchp-%d", 0, 0, slot->number);
83+
slot->wq = alloc_workqueue("shpchp-%d", WQ_PERCPU, 0,
84+
slot->number);
8485
if (!slot->wq) {
8586
retval = -ENOMEM;
8687
goto error_slot;

0 commit comments

Comments
 (0)