Skip to content

Commit e360bb6

Browse files
Merge patch series "replace old wq(s), added WQ_PERCPU to alloc_workqueue"
Marco Crivellari <marco.crivellari@suse.com> says: 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 128ea9f ("workqueue: Add system_percpu_wq and system_dfl_wq") - commit 930c2ea ("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 and system_unbound_wq system_unbound_wq is to be used when locality is not required. Because of that, system_unbound_wq has been replaced with system_dfl_wq, to make clear it should be used when locality is not required. 2) [P 2-3-4] WQ_PERCPU added to alloc_workqueue() 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! Link: https://patch.msgid.link/20251031095643.74246-1-marco.crivellari@suse.com Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
2 parents 3813d28 + 8d5cad3 commit e360bb6

16 files changed

Lines changed: 38 additions & 27 deletions

File tree

drivers/message/fusion/mptbase.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1857,7 +1857,8 @@ mpt_attach(struct pci_dev *pdev, const struct pci_device_id *id)
18571857
INIT_DELAYED_WORK(&ioc->fault_reset_work, mpt_fault_reset_work);
18581858

18591859
ioc->reset_work_q =
1860-
alloc_workqueue("mpt_poll_%d", WQ_MEM_RECLAIM, 0, ioc->id);
1860+
alloc_workqueue("mpt_poll_%d", WQ_MEM_RECLAIM | WQ_PERCPU, 0,
1861+
ioc->id);
18611862
if (!ioc->reset_work_q) {
18621863
printk(MYIOC_s_ERR_FMT "Insufficient memory to add adapter!\n",
18631864
ioc->name);
@@ -1984,7 +1985,9 @@ mpt_attach(struct pci_dev *pdev, const struct pci_device_id *id)
19841985

19851986
INIT_LIST_HEAD(&ioc->fw_event_list);
19861987
spin_lock_init(&ioc->fw_event_lock);
1987-
ioc->fw_event_q = alloc_workqueue("mpt/%d", WQ_MEM_RECLAIM, 0, ioc->id);
1988+
ioc->fw_event_q = alloc_workqueue("mpt/%d",
1989+
WQ_MEM_RECLAIM | WQ_PERCPU, 0,
1990+
ioc->id);
19881991
if (!ioc->fw_event_q) {
19891992
printk(MYIOC_s_ERR_FMT "Insufficient memory to add adapter!\n",
19901993
ioc->name);

drivers/scsi/be2iscsi/be_main.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5633,7 +5633,8 @@ static int beiscsi_dev_probe(struct pci_dev *pcidev,
56335633

56345634
phba->ctrl.mcc_alloc_index = phba->ctrl.mcc_free_index = 0;
56355635

5636-
phba->wq = alloc_workqueue("beiscsi_%02x_wq", WQ_MEM_RECLAIM, 1,
5636+
phba->wq = alloc_workqueue("beiscsi_%02x_wq",
5637+
WQ_MEM_RECLAIM | WQ_PERCPU, 1,
56375638
phba->shost->host_no);
56385639
if (!phba->wq) {
56395640
beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_INIT,

drivers/scsi/bnx2fc/bnx2fc_fcoe.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2695,7 +2695,7 @@ static int __init bnx2fc_mod_init(void)
26952695
if (rc)
26962696
goto detach_ft;
26972697

2698-
bnx2fc_wq = alloc_workqueue("bnx2fc", 0, 0);
2698+
bnx2fc_wq = alloc_workqueue("bnx2fc", WQ_PERCPU, 0);
26992699
if (!bnx2fc_wq) {
27002700
rc = -ENOMEM;
27012701
goto release_bt;

drivers/scsi/device_handler/scsi_dh_alua.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1300,7 +1300,7 @@ static int __init alua_init(void)
13001300
{
13011301
int r;
13021302

1303-
kaluad_wq = alloc_workqueue("kaluad", WQ_MEM_RECLAIM, 0);
1303+
kaluad_wq = alloc_workqueue("kaluad", WQ_MEM_RECLAIM | WQ_PERCPU, 0);
13041304
if (!kaluad_wq)
13051305
return -ENOMEM;
13061306

drivers/scsi/ibmvscsi_tgt/ibmvscsi_tgt.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3533,7 +3533,8 @@ static int ibmvscsis_probe(struct vio_dev *vdev,
35333533
init_completion(&vscsi->wait_idle);
35343534
init_completion(&vscsi->unconfig);
35353535

3536-
vscsi->work_q = alloc_workqueue("ibmvscsis%s", WQ_MEM_RECLAIM, 1,
3536+
vscsi->work_q = alloc_workqueue("ibmvscsis%s",
3537+
WQ_MEM_RECLAIM | WQ_PERCPU, 1,
35373538
dev_name(&vdev->dev));
35383539
if (!vscsi->work_q) {
35393540
rc = -ENOMEM;

drivers/scsi/lpfc/lpfc_init.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7944,7 +7944,7 @@ lpfc_sli4_driver_resource_setup(struct lpfc_hba *phba)
79447944
/* Allocate all driver workqueues here */
79457945

79467946
/* The lpfc_wq workqueue for deferred irq use */
7947-
phba->wq = alloc_workqueue("lpfc_wq", WQ_MEM_RECLAIM, 0);
7947+
phba->wq = alloc_workqueue("lpfc_wq", WQ_MEM_RECLAIM | WQ_PERCPU, 0);
79487948
if (!phba->wq)
79497949
return -ENOMEM;
79507950

drivers/scsi/pm8001/pm8001_init.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1534,7 +1534,7 @@ static int __init pm8001_init(void)
15341534
if (pm8001_use_tasklet && !pm8001_use_msix)
15351535
pm8001_use_tasklet = false;
15361536

1537-
pm8001_wq = alloc_workqueue("pm80xx", 0, 0);
1537+
pm8001_wq = alloc_workqueue("pm80xx", WQ_PERCPU, 0);
15381538
if (!pm8001_wq)
15391539
goto err;
15401540

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;

drivers/scsi/qedi/qedi_main.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2768,7 +2768,7 @@ static int __qedi_probe(struct pci_dev *pdev, int mode)
27682768
}
27692769

27702770
qedi->offload_thread = alloc_workqueue("qedi_ofld%d",
2771-
WQ_MEM_RECLAIM,
2771+
WQ_MEM_RECLAIM | WQ_PERCPU,
27722772
1, qedi->shost->host_no);
27732773
if (!qedi->offload_thread) {
27742774
QEDI_ERR(&qedi->dbg_ctx,

drivers/scsi/qla2xxx/qla_os.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3407,7 +3407,7 @@ qla2x00_probe_one(struct pci_dev *pdev, const struct pci_device_id *id)
34073407
"req->req_q_in=%p req->req_q_out=%p rsp->rsp_q_in=%p rsp->rsp_q_out=%p.\n",
34083408
req->req_q_in, req->req_q_out, rsp->rsp_q_in, rsp->rsp_q_out);
34093409

3410-
ha->wq = alloc_workqueue("qla2xxx_wq", WQ_MEM_RECLAIM, 0);
3410+
ha->wq = alloc_workqueue("qla2xxx_wq", WQ_MEM_RECLAIM | WQ_PERCPU, 0);
34113411
if (unlikely(!ha->wq)) {
34123412
ret = -ENOMEM;
34133413
goto probe_failed;
@@ -5284,7 +5284,7 @@ void qla24xx_sched_upd_fcport(fc_port_t *fcport)
52845284
qla2x00_set_fcport_disc_state(fcport, DSC_UPD_FCPORT);
52855285
spin_unlock_irqrestore(&fcport->vha->work_lock, flags);
52865286

5287-
queue_work(system_unbound_wq, &fcport->reg_work);
5287+
queue_work(system_dfl_wq, &fcport->reg_work);
52885288
}
52895289

52905290
static

0 commit comments

Comments
 (0)