mirror of
https://github.com/linux-msm/laptops-kernel.git
synced 2026-08-13 14:19:53 -07:00
net: WQ_PERCPU added to alloc_workqueue users
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 change adds a new WQ_PERCPU flag at the network subsystem, 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> Link: https://patch.msgid.link/20250918142427.309519-4-marco.crivellari@suse.com Signed-off-by: Jakub Kicinski <kuba@kernel.org>
This commit is contained in:
committed by
Jakub Kicinski
parent
5fd8bb982e
commit
27ce71e1ce
@@ -770,7 +770,8 @@ static int hi3110_open(struct net_device *net)
|
||||
goto out_close;
|
||||
}
|
||||
|
||||
priv->wq = alloc_workqueue("hi3110_wq", WQ_FREEZABLE | WQ_MEM_RECLAIM,
|
||||
priv->wq = alloc_workqueue("hi3110_wq",
|
||||
WQ_FREEZABLE | WQ_MEM_RECLAIM | WQ_PERCPU,
|
||||
0);
|
||||
if (!priv->wq) {
|
||||
ret = -ENOMEM;
|
||||
|
||||
@@ -1378,7 +1378,8 @@ static int mcp251x_can_probe(struct spi_device *spi)
|
||||
if (ret)
|
||||
goto out_clk;
|
||||
|
||||
priv->wq = alloc_workqueue("mcp251x_wq", WQ_FREEZABLE | WQ_MEM_RECLAIM,
|
||||
priv->wq = alloc_workqueue("mcp251x_wq",
|
||||
WQ_FREEZABLE | WQ_MEM_RECLAIM | WQ_PERCPU,
|
||||
0);
|
||||
if (!priv->wq) {
|
||||
ret = -ENOMEM;
|
||||
|
||||
@@ -472,7 +472,7 @@ int setup_rx_oom_poll_fn(struct net_device *netdev)
|
||||
q_no = lio->linfo.rxpciq[q].s.q_no;
|
||||
wq = &lio->rxq_status_wq[q_no];
|
||||
wq->wq = alloc_workqueue("rxq-oom-status",
|
||||
WQ_MEM_RECLAIM, 0);
|
||||
WQ_MEM_RECLAIM | WQ_PERCPU, 0);
|
||||
if (!wq->wq) {
|
||||
dev_err(&oct->pci_dev->dev, "unable to create cavium rxq oom status wq\n");
|
||||
return -ENOMEM;
|
||||
|
||||
@@ -526,7 +526,8 @@ static inline int setup_link_status_change_wq(struct net_device *netdev)
|
||||
struct octeon_device *oct = lio->oct_dev;
|
||||
|
||||
lio->link_status_wq.wq = alloc_workqueue("link-status",
|
||||
WQ_MEM_RECLAIM, 0);
|
||||
WQ_MEM_RECLAIM | WQ_PERCPU,
|
||||
0);
|
||||
if (!lio->link_status_wq.wq) {
|
||||
dev_err(&oct->pci_dev->dev, "unable to create cavium link status wq\n");
|
||||
return -1;
|
||||
@@ -659,7 +660,8 @@ static inline int setup_sync_octeon_time_wq(struct net_device *netdev)
|
||||
struct octeon_device *oct = lio->oct_dev;
|
||||
|
||||
lio->sync_octeon_time_wq.wq =
|
||||
alloc_workqueue("update-octeon-time", WQ_MEM_RECLAIM, 0);
|
||||
alloc_workqueue("update-octeon-time",
|
||||
WQ_MEM_RECLAIM | WQ_PERCPU, 0);
|
||||
if (!lio->sync_octeon_time_wq.wq) {
|
||||
dev_err(&oct->pci_dev->dev, "Unable to create wq to update octeon time\n");
|
||||
return -1;
|
||||
@@ -1734,7 +1736,7 @@ static inline int setup_tx_poll_fn(struct net_device *netdev)
|
||||
struct octeon_device *oct = lio->oct_dev;
|
||||
|
||||
lio->txq_status_wq.wq = alloc_workqueue("txq-status",
|
||||
WQ_MEM_RECLAIM, 0);
|
||||
WQ_MEM_RECLAIM | WQ_PERCPU, 0);
|
||||
if (!lio->txq_status_wq.wq) {
|
||||
dev_err(&oct->pci_dev->dev, "unable to create cavium txq status wq\n");
|
||||
return -1;
|
||||
|
||||
@@ -304,7 +304,8 @@ static int setup_link_status_change_wq(struct net_device *netdev)
|
||||
struct octeon_device *oct = lio->oct_dev;
|
||||
|
||||
lio->link_status_wq.wq = alloc_workqueue("link-status",
|
||||
WQ_MEM_RECLAIM, 0);
|
||||
WQ_MEM_RECLAIM | WQ_PERCPU,
|
||||
0);
|
||||
if (!lio->link_status_wq.wq) {
|
||||
dev_err(&oct->pci_dev->dev, "unable to create cavium link status wq\n");
|
||||
return -1;
|
||||
|
||||
@@ -132,7 +132,7 @@ int octeon_init_instr_queue(struct octeon_device *oct,
|
||||
oct->fn_list.setup_iq_regs(oct, iq_no);
|
||||
|
||||
oct->check_db_wq[iq_no].wq = alloc_workqueue("check_iq_db",
|
||||
WQ_MEM_RECLAIM,
|
||||
WQ_MEM_RECLAIM | WQ_PERCPU,
|
||||
0);
|
||||
if (!oct->check_db_wq[iq_no].wq) {
|
||||
vfree(iq->request_list);
|
||||
|
||||
@@ -39,7 +39,8 @@ int octeon_setup_response_list(struct octeon_device *oct)
|
||||
}
|
||||
spin_lock_init(&oct->cmd_resp_wqlock);
|
||||
|
||||
oct->dma_comp_wq.wq = alloc_workqueue("dma-comp", WQ_MEM_RECLAIM, 0);
|
||||
oct->dma_comp_wq.wq = alloc_workqueue("dma-comp",
|
||||
WQ_MEM_RECLAIM | WQ_PERCPU, 0);
|
||||
if (!oct->dma_comp_wq.wq) {
|
||||
dev_err(&oct->pci_dev->dev, "failed to create wq thread\n");
|
||||
return -ENOMEM;
|
||||
|
||||
@@ -4884,7 +4884,7 @@ static int dpaa2_eth_probe(struct fsl_mc_device *dpni_dev)
|
||||
priv->tx_tstamp_type = HWTSTAMP_TX_OFF;
|
||||
priv->rx_tstamp = false;
|
||||
|
||||
priv->dpaa2_ptp_wq = alloc_workqueue("dpaa2_ptp_wq", 0, 0);
|
||||
priv->dpaa2_ptp_wq = alloc_workqueue("dpaa2_ptp_wq", WQ_PERCPU, 0);
|
||||
if (!priv->dpaa2_ptp_wq) {
|
||||
err = -ENOMEM;
|
||||
goto err_wq_alloc;
|
||||
|
||||
@@ -12912,7 +12912,8 @@ static int __init hclge_init(void)
|
||||
{
|
||||
pr_debug("%s is initializing\n", HCLGE_NAME);
|
||||
|
||||
hclge_wq = alloc_workqueue("%s", WQ_UNBOUND, 0, HCLGE_NAME);
|
||||
hclge_wq = alloc_workqueue("%s", WQ_UNBOUND, 0,
|
||||
HCLGE_NAME);
|
||||
if (!hclge_wq) {
|
||||
pr_err("%s: failed to create workqueue\n", HCLGE_NAME);
|
||||
return -ENOMEM;
|
||||
|
||||
@@ -37,7 +37,7 @@ static int __init fm10k_init_module(void)
|
||||
pr_info("%s\n", fm10k_copyright);
|
||||
|
||||
/* create driver workqueue */
|
||||
fm10k_workqueue = alloc_workqueue("%s", WQ_MEM_RECLAIM, 0,
|
||||
fm10k_workqueue = alloc_workqueue("%s", WQ_MEM_RECLAIM | WQ_PERCPU, 0,
|
||||
fm10k_driver_name);
|
||||
if (!fm10k_workqueue)
|
||||
return -ENOMEM;
|
||||
|
||||
@@ -16617,7 +16617,7 @@ static int __init i40e_init_module(void)
|
||||
* since we need to be able to guarantee forward progress even under
|
||||
* memory pressure.
|
||||
*/
|
||||
i40e_wq = alloc_workqueue("%s", 0, 0, i40e_driver_name);
|
||||
i40e_wq = alloc_workqueue("%s", WQ_PERCPU, 0, i40e_driver_name);
|
||||
if (!i40e_wq) {
|
||||
pr_err("%s: Failed to create workqueue\n", i40e_driver_name);
|
||||
return -ENOMEM;
|
||||
|
||||
@@ -2005,7 +2005,7 @@ static int cgx_probe(struct pci_dev *pdev, const struct pci_device_id *id)
|
||||
|
||||
/* init wq for processing linkup requests */
|
||||
INIT_WORK(&cgx->cgx_cmd_work, cgx_lmac_linkup_work);
|
||||
cgx->cgx_cmd_workq = alloc_workqueue("cgx_cmd_workq", 0, 0);
|
||||
cgx->cgx_cmd_workq = alloc_workqueue("cgx_cmd_workq", WQ_PERCPU, 0);
|
||||
if (!cgx->cgx_cmd_workq) {
|
||||
dev_err(dev, "alloc workqueue failed for cgx cmd");
|
||||
err = -ENOMEM;
|
||||
|
||||
@@ -913,7 +913,7 @@ int rvu_mcs_init(struct rvu *rvu)
|
||||
/* Initialize the wq for handling mcs interrupts */
|
||||
INIT_LIST_HEAD(&rvu->mcs_intrq_head);
|
||||
INIT_WORK(&rvu->mcs_intr_work, mcs_intr_handler_task);
|
||||
rvu->mcs_intr_wq = alloc_workqueue("mcs_intr_wq", 0, 0);
|
||||
rvu->mcs_intr_wq = alloc_workqueue("mcs_intr_wq", WQ_PERCPU, 0);
|
||||
if (!rvu->mcs_intr_wq) {
|
||||
dev_err(rvu->dev, "mcs alloc workqueue failed\n");
|
||||
return -ENOMEM;
|
||||
|
||||
@@ -315,7 +315,7 @@ static int cgx_lmac_event_handler_init(struct rvu *rvu)
|
||||
spin_lock_init(&rvu->cgx_evq_lock);
|
||||
INIT_LIST_HEAD(&rvu->cgx_evq_head);
|
||||
INIT_WORK(&rvu->cgx_evh_work, cgx_evhandler_task);
|
||||
rvu->cgx_evh_wq = alloc_workqueue("rvu_evh_wq", 0, 0);
|
||||
rvu->cgx_evh_wq = alloc_workqueue("rvu_evh_wq", WQ_PERCPU, 0);
|
||||
if (!rvu->cgx_evh_wq) {
|
||||
dev_err(rvu->dev, "alloc workqueue failed");
|
||||
return -ENOMEM;
|
||||
|
||||
@@ -376,7 +376,7 @@ int rvu_rep_install_mcam_rules(struct rvu *rvu)
|
||||
spin_lock_init(&rvu->rep_evtq_lock);
|
||||
INIT_LIST_HEAD(&rvu->rep_evtq_head);
|
||||
INIT_WORK(&rvu->rep_evt_work, rvu_rep_wq_handler);
|
||||
rvu->rep_evt_wq = alloc_workqueue("rep_evt_wq", 0, 0);
|
||||
rvu->rep_evt_wq = alloc_workqueue("rep_evt_wq", WQ_PERCPU, 0);
|
||||
if (!rvu->rep_evt_wq) {
|
||||
dev_err(rvu->dev, "REP workqueue allocation failed\n");
|
||||
return -ENOMEM;
|
||||
|
||||
@@ -798,7 +798,8 @@ int cn10k_ipsec_init(struct net_device *netdev)
|
||||
pf->ipsec.sa_size = sa_size;
|
||||
|
||||
INIT_WORK(&pf->ipsec.sa_work, cn10k_ipsec_sa_wq_handler);
|
||||
pf->ipsec.sa_workq = alloc_workqueue("cn10k_ipsec_sa_workq", 0, 0);
|
||||
pf->ipsec.sa_workq = alloc_workqueue("cn10k_ipsec_sa_workq",
|
||||
WQ_PERCPU, 0);
|
||||
if (!pf->ipsec.sa_workq) {
|
||||
netdev_err(pf->netdev, "SA alloc workqueue failed\n");
|
||||
return -ENOMEM;
|
||||
|
||||
@@ -1500,7 +1500,7 @@ EXPORT_SYMBOL(prestera_device_unregister);
|
||||
|
||||
static int __init prestera_module_init(void)
|
||||
{
|
||||
prestera_wq = alloc_workqueue("prestera", 0, 0);
|
||||
prestera_wq = alloc_workqueue("prestera", WQ_PERCPU, 0);
|
||||
if (!prestera_wq)
|
||||
return -ENOMEM;
|
||||
|
||||
|
||||
@@ -898,7 +898,7 @@ static int prestera_pci_probe(struct pci_dev *pdev,
|
||||
|
||||
dev_info(fw->dev.dev, "Prestera FW is ready\n");
|
||||
|
||||
fw->wq = alloc_workqueue("prestera_fw_wq", WQ_HIGHPRI, 1);
|
||||
fw->wq = alloc_workqueue("prestera_fw_wq", WQ_HIGHPRI | WQ_PERCPU, 1);
|
||||
if (!fw->wq) {
|
||||
err = -ENOMEM;
|
||||
goto err_wq_alloc;
|
||||
|
||||
@@ -886,7 +886,7 @@ static int mlxsw_emad_init(struct mlxsw_core *mlxsw_core)
|
||||
if (!(mlxsw_core->bus->features & MLXSW_BUS_F_TXRX))
|
||||
return 0;
|
||||
|
||||
emad_wq = alloc_workqueue("mlxsw_core_emad", 0, 0);
|
||||
emad_wq = alloc_workqueue("mlxsw_core_emad", WQ_PERCPU, 0);
|
||||
if (!emad_wq)
|
||||
return -ENOMEM;
|
||||
mlxsw_core->emad_wq = emad_wq;
|
||||
@@ -3381,7 +3381,7 @@ static int __init mlxsw_core_module_init(void)
|
||||
if (err)
|
||||
return err;
|
||||
|
||||
mlxsw_wq = alloc_workqueue(mlxsw_core_driver_name, 0, 0);
|
||||
mlxsw_wq = alloc_workqueue(mlxsw_core_driver_name, WQ_PERCPU, 0);
|
||||
if (!mlxsw_wq) {
|
||||
err = -ENOMEM;
|
||||
goto err_alloc_workqueue;
|
||||
|
||||
@@ -797,7 +797,7 @@ static int nfp_pci_probe(struct pci_dev *pdev,
|
||||
pf->pdev = pdev;
|
||||
pf->dev_info = dev_info;
|
||||
|
||||
pf->wq = alloc_workqueue("nfp-%s", 0, 2, pci_name(pdev));
|
||||
pf->wq = alloc_workqueue("nfp-%s", WQ_PERCPU, 2, pci_name(pdev));
|
||||
if (!pf->wq) {
|
||||
err = -ENOMEM;
|
||||
goto err_pci_priv_unset;
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user