summaryrefslogtreecommitdiff
path: root/include/net
diff options
context:
space:
mode:
authorJakub Kicinski <kuba@kernel.org>2026-06-09 10:13:08 -0700
committerJakub Kicinski <kuba@kernel.org>2026-06-09 10:13:08 -0700
commit3abbe30231441f1fbb3305e9854c56a34650af53 (patch)
tree28e37f85137ae408657f4edf4fc0cd81cfef2692 /include/net
parent9415471e01c1aaac43daa6af3a261dc0c6c3a47c (diff)
parentb5125db8d0205048a3b9dafec7f8e2b0a702101f (diff)
Merge branch 'net-ethtool-let-ops-locked-drivers-run-without-rtnl_lock'
Jakub Kicinski says: ==================== net: ethtool: let ops locked drivers run without rtnl_lock With the ethtool_get_link_ksettings() situation hopefully ironed out the previous series (commit 6a5d837f0ce2) let's return to the main part of the series. We have been slowly moving towards removing the rtnl_lock dependency in driver ops since the concept of "ops-locked" drivers have been introduced last year. Since last year will take the netdev instance lock before invoking any ndo or ethtool op of "ops-locked" drivers. We dipped our toes into rtnl_lock-less ops with the queue binding API. Queue stats, NAPI, and other netdev-netlink objects are also queried without holding rtnl_lock already. It's time to take the next logical step and lift the requirement from ethtool ops. The direct motivation for this patchset is that ethtool ops often involve communicating with device FW, and may take a long time to complete. Aggressive polling of device state on machines with 10+ NICs have been shown to significantly increase rtnl_lock pressure. There's a handful of areas which still need rtnl_lock (see below). I decided to convert everything to rtnl_lock-less by default, and add a set of flags which let the drivers request rtnl_lock to still be taken. I don't love this, but I'm worried that opt-in would be even more confusing. Known issues / exclusions: - qdiscs - qdisc configuration currently assumes rtnl_lock, this is mostly impacting set_channels callback. qdisc config is probably the easiest one of the exclusions to tackle, it's fairly self-contained. - features - even tho feature changes are (correctly) plumbed to the driver thru ndos they are part of ethtool uAPI. ethtool itself calls netdev_features_change() if it has spotted device feature change before vs after to the callback. Some drivers also call netdev_features_change() directly in response to various changes, e.g. setting priv flags. Since features have to propagate to upper and lower devices anything that touches features is quite hard to move from under rtnl_lock. - phylink - phylink and SFP depend on rtnl_lock today, I suspect that this is purely for historic reasons. I started poking at it and don't really see a need for a global lock. But accessing the netdev instance lock from the SFP entry points will require some attention from the phylink folks. - phydev - similar to phylink, looks quite doable. But no ops-locked driver currently has a phydev (fbnic only uses phylink) so phydev related paths retain a ASSERT_RTNL() for now. Tested on mlx5, bnxt and fbnic. ==================== Link: https://patch.msgid.link/20260605002912.3456868-1-kuba@kernel.org Signed-off-by: Jakub Kicinski <kuba@kernel.org>
Diffstat (limited to 'include/net')
-rw-r--r--include/net/netdev_lock.h11
1 files changed, 11 insertions, 0 deletions
diff --git a/include/net/netdev_lock.h b/include/net/netdev_lock.h
index d3daec4e93f3..9fb3e93857c3 100644
--- a/include/net/netdev_lock.h
+++ b/include/net/netdev_lock.h
@@ -102,6 +102,14 @@ static inline void netdev_unlock_ops_compat(struct net_device *dev)
rtnl_unlock();
}
+/* Matching "ops protected" category from netdevice.h */
+static inline int netdev_is_locked_ops_compat(const struct net_device *dev)
+{
+ if (netdev_need_ops_lock(dev))
+ return lockdep_is_held(&dev->lock);
+ return lockdep_rtnl_is_held();
+}
+
static inline int netdev_lock_cmp_fn(const struct lockdep_map *a,
const struct lockdep_map *b)
{
@@ -138,6 +146,9 @@ static inline int netdev_lock_cmp_fn(const struct lockdep_map *a,
#define netdev_lock_dereference(p, dev) \
rcu_dereference_protected(p, lockdep_is_held(&(dev)->lock))
+#define netdev_ops_lock_dereference(p, dev) \
+ rcu_dereference_protected(p, netdev_is_locked_ops_compat(dev))
+
int netdev_debug_event(struct notifier_block *nb, unsigned long event,
void *ptr);