Skip to content

Commit e036dad

Browse files
DispatchCodemartinkpetersen
authored andcommitted
scsi: qedf: Add WQ_PERCPU to alloc_workqueue() users
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 128ea9f ("workqueue: Add system_percpu_wq and system_dfl_wq") commit 930c2ea ("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> Link: https://patch.msgid.link/20251107150155.267651-3-marco.crivellari@suse.com Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
1 parent a43a2e4 commit e036dad

1 file changed

Lines changed: 10 additions & 5 deletions

File tree

drivers/scsi/qedf/qedf_main.c

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3374,7 +3374,8 @@ static int __qedf_probe(struct pci_dev *pdev, int mode)
33743374
QEDF_INFO(&(qedf->dbg_ctx), QEDF_LOG_INFO, "qedf->io_mempool=%p.\n",
33753375
qedf->io_mempool);
33763376

3377-
qedf->link_update_wq = alloc_workqueue("qedf_%u_link", WQ_MEM_RECLAIM,
3377+
qedf->link_update_wq = alloc_workqueue("qedf_%u_link",
3378+
WQ_MEM_RECLAIM | WQ_PERCPU,
33783379
1, qedf->lport->host->host_no);
33793380
INIT_DELAYED_WORK(&qedf->link_update, qedf_handle_link_update);
33803381
INIT_DELAYED_WORK(&qedf->link_recovery, qedf_link_recovery);
@@ -3585,7 +3586,8 @@ static int __qedf_probe(struct pci_dev *pdev, int mode)
35853586
ether_addr_copy(params.ll2_mac_address, qedf->mac);
35863587

35873588
/* Start LL2 processing thread */
3588-
qedf->ll2_recv_wq = alloc_workqueue("qedf_%d_ll2", WQ_MEM_RECLAIM, 1,
3589+
qedf->ll2_recv_wq = alloc_workqueue("qedf_%d_ll2",
3590+
WQ_MEM_RECLAIM | WQ_PERCPU, 1,
35893591
host->host_no);
35903592
if (!qedf->ll2_recv_wq) {
35913593
QEDF_ERR(&(qedf->dbg_ctx), "Failed to LL2 workqueue.\n");
@@ -3628,7 +3630,8 @@ static int __qedf_probe(struct pci_dev *pdev, int mode)
36283630
}
36293631

36303632
qedf->timer_work_queue = alloc_workqueue("qedf_%u_timer",
3631-
WQ_MEM_RECLAIM, 1, qedf->lport->host->host_no);
3633+
WQ_MEM_RECLAIM | WQ_PERCPU, 1,
3634+
qedf->lport->host->host_no);
36323635
if (!qedf->timer_work_queue) {
36333636
QEDF_ERR(&(qedf->dbg_ctx), "Failed to start timer "
36343637
"workqueue.\n");
@@ -3641,7 +3644,8 @@ static int __qedf_probe(struct pci_dev *pdev, int mode)
36413644
sprintf(host_buf, "qedf_%u_dpc",
36423645
qedf->lport->host->host_no);
36433646
qedf->dpc_wq =
3644-
alloc_workqueue("%s", WQ_MEM_RECLAIM, 1, host_buf);
3647+
alloc_workqueue("%s", WQ_MEM_RECLAIM | WQ_PERCPU, 1,
3648+
host_buf);
36453649
}
36463650
INIT_DELAYED_WORK(&qedf->recovery_work, qedf_recovery_handler);
36473651

@@ -4177,7 +4181,8 @@ static int __init qedf_init(void)
41774181
goto err3;
41784182
}
41794183

4180-
qedf_io_wq = alloc_workqueue("%s", WQ_MEM_RECLAIM, 1, "qedf_io_wq");
4184+
qedf_io_wq = alloc_workqueue("%s", WQ_MEM_RECLAIM | WQ_PERCPU, 1,
4185+
"qedf_io_wq");
41814186
if (!qedf_io_wq) {
41824187
QEDF_ERR(NULL, "Could not create qedf_io_wq.\n");
41834188
goto err4;

0 commit comments

Comments
 (0)