]> www.infradead.org Git - users/hch/misc.git/commitdiff
net: replace use of system_wq with system_percpu_wq
authorMarco Crivellari <marco.crivellari@suse.com>
Thu, 18 Sep 2025 14:24:26 +0000 (16:24 +0200)
committerJakub Kicinski <kuba@kernel.org>
Tue, 23 Sep 2025 00:40:30 +0000 (17:40 -0700)
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.

system_unbound_wq should be the default workqueue so as not to enforce
locality constraints for random work whenever it's not required.

Adding system_dfl_wq to encourage its use when unbound work should be used.

The old system_unbound_wq will be kept for a few release cycles.

Suggested-by: Tejun Heo <tj@kernel.org>
Signed-off-by: Marco Crivellari <marco.crivellari@suse.com>
Link: https://patch.msgid.link/20250918142427.309519-3-marco.crivellari@suse.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
14 files changed:
drivers/net/ethernet/sfc/efx_channels.c
drivers/net/ethernet/sfc/siena/efx_channels.c
drivers/net/phy/sfp.c
net/bridge/br_cfm.c
net/bridge/br_mrp.c
net/ceph/mon_client.c
net/core/skmsg.c
net/devlink/core.c
net/ipv4/inet_fragment.c
net/netfilter/nf_conntrack_ecache.c
net/openvswitch/dp_notify.c
net/rfkill/input.c
net/smc/smc_core.c
net/vmw_vsock/af_vsock.c

index 0f66324ed3510503142db0e5b770bd53eb2ef7f7..ed3a96ebc7f31e9b0d11f50bfbf5c9e7c789e851 100644 (file)
@@ -1281,7 +1281,7 @@ static int efx_poll(struct napi_struct *napi, int budget)
                time = jiffies - channel->rfs_last_expiry;
                /* Would our quota be >= 20? */
                if (channel->rfs_filter_count * time >= 600 * HZ)
-                       mod_delayed_work(system_wq, &channel->filter_work, 0);
+                       mod_delayed_work(system_percpu_wq, &channel->filter_work, 0);
 #endif
 
                /* There is no race here; although napi_disable() will
index 703419866d18311db66b5b24fa5fab35de3e0267..fc075ab6b7b5adfce88ca3ea11804cd8483a698e 100644 (file)
@@ -1300,7 +1300,7 @@ static int efx_poll(struct napi_struct *napi, int budget)
                time = jiffies - channel->rfs_last_expiry;
                /* Would our quota be >= 20? */
                if (channel->rfs_filter_count * time >= 600 * HZ)
-                       mod_delayed_work(system_wq, &channel->filter_work, 0);
+                       mod_delayed_work(system_percpu_wq, &channel->filter_work, 0);
 #endif
 
                /* There is no race here; although napi_disable() will
index d49f91ac2e50ad11180cae056f0b5cd41698ac16..dfea675281fd1ed0e51d9aa2760e6115f6fb28f5 100644 (file)
@@ -911,7 +911,7 @@ static void sfp_soft_start_poll(struct sfp *sfp)
 
        if (sfp->state_soft_mask & (SFP_F_LOS | SFP_F_TX_FAULT) &&
            !sfp->need_poll)
-               mod_delayed_work(system_wq, &sfp->poll, poll_jiffies);
+               mod_delayed_work(system_percpu_wq, &sfp->poll, poll_jiffies);
        mutex_unlock(&sfp->st_mutex);
 }
 
@@ -1682,7 +1682,7 @@ static void sfp_hwmon_probe(struct work_struct *work)
        err = sfp_read(sfp, true, 0, &sfp->diag, sizeof(sfp->diag));
        if (err < 0) {
                if (sfp->hwmon_tries--) {
-                       mod_delayed_work(system_wq, &sfp->hwmon_probe,
+                       mod_delayed_work(system_percpu_wq, &sfp->hwmon_probe,
                                         T_PROBE_RETRY_SLOW);
                } else {
                        dev_warn(sfp->dev, "hwmon probe failed: %pe\n",
@@ -1709,7 +1709,7 @@ static void sfp_hwmon_probe(struct work_struct *work)
 static int sfp_hwmon_insert(struct sfp *sfp)
 {
        if (sfp->have_a2 && sfp->id.ext.diagmon & SFP_DIAGMON_DDM) {
-               mod_delayed_work(system_wq, &sfp->hwmon_probe, 1);
+               mod_delayed_work(system_percpu_wq, &sfp->hwmon_probe, 1);
                sfp->hwmon_tries = R_PROBE_RETRY_SLOW;
        }
 
@@ -2563,7 +2563,7 @@ static void sfp_sm_module(struct sfp *sfp, unsigned int event)
                /* Force a poll to re-read the hardware signal state after
                 * sfp_sm_mod_probe() changed state_hw_mask.
                 */
-               mod_delayed_work(system_wq, &sfp->poll, 1);
+               mod_delayed_work(system_percpu_wq, &sfp->poll, 1);
 
                err = sfp_hwmon_insert(sfp);
                if (err)
@@ -3008,7 +3008,7 @@ static void sfp_poll(struct work_struct *work)
        // it's unimportant if we race while reading this.
        if (sfp->state_soft_mask & (SFP_F_LOS | SFP_F_TX_FAULT) ||
            sfp->need_poll)
-               mod_delayed_work(system_wq, &sfp->poll, poll_jiffies);
+               mod_delayed_work(system_percpu_wq, &sfp->poll, poll_jiffies);
 }
 
 static struct sfp *sfp_alloc(struct device *dev)
@@ -3178,7 +3178,7 @@ static int sfp_probe(struct platform_device *pdev)
        }
 
        if (sfp->need_poll)
-               mod_delayed_work(system_wq, &sfp->poll, poll_jiffies);
+               mod_delayed_work(system_percpu_wq, &sfp->poll, poll_jiffies);
 
        /* We could have an issue in cases no Tx disable pin is available or
         * wired as modules using a laser as their light source will continue to
index a3c755d0a09de9248c9f467f21bb1342c4524735..c2c1c7d44c615fe5b6c3802c352a0b28c77e26ec 100644 (file)
@@ -134,7 +134,7 @@ static void ccm_rx_timer_start(struct br_cfm_peer_mep *peer_mep)
         * of the configured CC 'expected_interval'
         * in order to detect CCM defect after 3.25 interval.
         */
-       queue_delayed_work(system_wq, &peer_mep->ccm_rx_dwork,
+       queue_delayed_work(system_percpu_wq, &peer_mep->ccm_rx_dwork,
                           usecs_to_jiffies(interval_us / 4));
 }
 
@@ -285,7 +285,7 @@ static void ccm_tx_work_expired(struct work_struct *work)
                ccm_frame_tx(skb);
 
        interval_us = interval_to_us(mep->cc_config.exp_interval);
-       queue_delayed_work(system_wq, &mep->ccm_tx_dwork,
+       queue_delayed_work(system_percpu_wq, &mep->ccm_tx_dwork,
                           usecs_to_jiffies(interval_us));
 }
 
@@ -809,7 +809,7 @@ int br_cfm_cc_ccm_tx(struct net_bridge *br, const u32 instance,
         * to send first frame immediately
         */
        mep->ccm_tx_end = jiffies + usecs_to_jiffies(tx_info->period * 1000000);
-       queue_delayed_work(system_wq, &mep->ccm_tx_dwork, 0);
+       queue_delayed_work(system_percpu_wq, &mep->ccm_tx_dwork, 0);
 
 save:
        mep->cc_ccm_tx_info = *tx_info;
index fd2de35ffb3cf86062122bb8f5866d290b1a7be7..3c36fa24bc05a5c20166eaaf2d193b221820ad3e 100644 (file)
@@ -341,7 +341,7 @@ static void br_mrp_test_work_expired(struct work_struct *work)
 out:
        rcu_read_unlock();
 
-       queue_delayed_work(system_wq, &mrp->test_work,
+       queue_delayed_work(system_percpu_wq, &mrp->test_work,
                           usecs_to_jiffies(mrp->test_interval));
 }
 
@@ -418,7 +418,7 @@ static void br_mrp_in_test_work_expired(struct work_struct *work)
 out:
        rcu_read_unlock();
 
-       queue_delayed_work(system_wq, &mrp->in_test_work,
+       queue_delayed_work(system_percpu_wq, &mrp->in_test_work,
                           usecs_to_jiffies(mrp->in_test_interval));
 }
 
@@ -725,7 +725,7 @@ int br_mrp_start_test(struct net_bridge *br,
        mrp->test_max_miss = test->max_miss;
        mrp->test_monitor = test->monitor;
        mrp->test_count_miss = 0;
-       queue_delayed_work(system_wq, &mrp->test_work,
+       queue_delayed_work(system_percpu_wq, &mrp->test_work,
                           usecs_to_jiffies(test->interval));
 
        return 0;
@@ -865,7 +865,7 @@ int br_mrp_start_in_test(struct net_bridge *br,
        mrp->in_test_end = jiffies + usecs_to_jiffies(in_test->period);
        mrp->in_test_max_miss = in_test->max_miss;
        mrp->in_test_count_miss = 0;
-       queue_delayed_work(system_wq, &mrp->in_test_work,
+       queue_delayed_work(system_percpu_wq, &mrp->in_test_work,
                           usecs_to_jiffies(in_test->interval));
 
        return 0;
index ab66b599ac4792d600f16eb8f22b128848d6105f..c227ececa9254c631432a3c0e00e3bb4c311b8f2 100644 (file)
@@ -314,7 +314,7 @@ static void __schedule_delayed(struct ceph_mon_client *monc)
                delay = CEPH_MONC_PING_INTERVAL;
 
        dout("__schedule_delayed after %lu\n", delay);
-       mod_delayed_work(system_wq, &monc->delayed_work,
+       mod_delayed_work(system_percpu_wq, &monc->delayed_work,
                         round_jiffies_relative(delay));
 }
 
index 83c78379932e233c4a76775d3e87a7275f008e48..2ac7731e1e0a74c276a50cd6a47bd830545fcf8e 100644 (file)
@@ -876,7 +876,7 @@ void sk_psock_drop(struct sock *sk, struct sk_psock *psock)
        sk_psock_stop(psock);
 
        INIT_RCU_WORK(&psock->rwork, sk_psock_destroy);
-       queue_rcu_work(system_wq, &psock->rwork);
+       queue_rcu_work(system_percpu_wq, &psock->rwork);
 }
 EXPORT_SYMBOL_GPL(sk_psock_drop);
 
index 7203c39532fcc3a7260edb139d7c8c257e6847f7..58093f49c0905e04e06d76ceb41c337b4c4955b3 100644 (file)
@@ -320,7 +320,7 @@ static void devlink_release(struct work_struct *work)
 void devlink_put(struct devlink *devlink)
 {
        if (refcount_dec_and_test(&devlink->refcount))
-               queue_rcu_work(system_wq, &devlink->rwork);
+               queue_rcu_work(system_percpu_wq, &devlink->rwork);
 }
 
 struct devlink *devlinks_xa_find_get(struct net *net, unsigned long *indexp)
index 470ab17ceb51bea6e2589ed15c42f4759a512170..025895eb6ec5978b9a4cade35b3893dfda6b603d 100644 (file)
@@ -183,7 +183,7 @@ static void fqdir_work_fn(struct work_struct *work)
        rhashtable_free_and_destroy(&fqdir->rhashtable, inet_frags_free_cb, NULL);
 
        if (llist_add(&fqdir->free_list, &fqdir_free_list))
-               queue_delayed_work(system_wq, &fqdir_free_work, HZ);
+               queue_delayed_work(system_percpu_wq, &fqdir_free_work, HZ);
 }
 
 int fqdir_init(struct fqdir **fqdirp, struct inet_frags *f, struct net *net)
index af68c64acaab7085997845b0b43de78d8c53ae50..81baf20826046e2b27d153c985df9bc7a20fddfd 100644 (file)
@@ -301,7 +301,7 @@ void nf_conntrack_ecache_work(struct net *net, enum nf_ct_ecache_state state)
                net->ct.ecache_dwork_pending = true;
        } else if (state == NFCT_ECACHE_DESTROY_SENT) {
                if (!hlist_nulls_empty(&cnet->ecache.dying_list))
-                       mod_delayed_work(system_wq, &cnet->ecache.dwork, 0);
+                       mod_delayed_work(system_percpu_wq, &cnet->ecache.dwork, 0);
                else
                        net->ct.ecache_dwork_pending = false;
        }
index 7af0cde8b293c84b98ad1929b9031306b7b03cbe..a2af90ee99af68ec32c357f07253394ddc317431 100644 (file)
@@ -75,7 +75,7 @@ static int dp_device_event(struct notifier_block *unused, unsigned long event,
 
                /* schedule vport destroy, dev_put and genl notification */
                ovs_net = net_generic(dev_net(dev), ovs_net_id);
-               queue_work(system_wq, &ovs_net->dp_notify_work);
+               queue_work(system_percpu_wq, &ovs_net->dp_notify_work);
        }
 
        return NOTIFY_DONE;
index 598d0a61bda7751b02c3cb45d6fcecaf2c4317fb..53d286b108439e5c06ad3f79e6b9758c2e283abf 100644 (file)
@@ -159,7 +159,7 @@ static void rfkill_schedule_global_op(enum rfkill_sched_op op)
        rfkill_op_pending = true;
        if (op == RFKILL_GLOBAL_OP_EPO && !rfkill_is_epo_lock_active()) {
                /* bypass the limiter for EPO */
-               mod_delayed_work(system_wq, &rfkill_op_work, 0);
+               mod_delayed_work(system_percpu_wq, &rfkill_op_work, 0);
                rfkill_last_scheduled = jiffies;
        } else
                rfkill_schedule_ratelimited();
index 2a559a98541c7587475bc4deae33614ce4eab3c6..e216d237865b036fef7314e95883ab000e65c8de 100644 (file)
@@ -85,7 +85,7 @@ static void smc_lgr_schedule_free_work(struct smc_link_group *lgr)
         * otherwise there is a risk of out-of-sync link groups.
         */
        if (!lgr->freeing) {
-               mod_delayed_work(system_wq, &lgr->free_work,
+               mod_delayed_work(system_percpu_wq, &lgr->free_work,
                                 (!lgr->is_smcd && lgr->role == SMC_CLNT) ?
                                                SMC_LGR_FREE_DELAY_CLNT :
                                                SMC_LGR_FREE_DELAY_SERV);
index 0538948d5fd90baefead2ceae6ada00020873b40..4c2db6cca5579b47e270798a0f3148ab25ee44b4 100644 (file)
@@ -1649,7 +1649,7 @@ static int vsock_connect(struct socket *sock, struct sockaddr *addr,
                         * reschedule it, then ungrab the socket refcount to
                         * keep it balanced.
                         */
-                       if (mod_delayed_work(system_wq, &vsk->connect_work,
+                       if (mod_delayed_work(system_percpu_wq, &vsk->connect_work,
                                             timeout))
                                sock_put(sk);