* [PATCH net-next 0/3] mlxsw: Make the driver ops-locked
@ 2026-07-08 12:39 Ido Schimmel
2026-07-08 12:39 ` [PATCH net-next 1/3] mlxsw: Convert to async version of ndo_set_rx_mode Ido Schimmel
` (3 more replies)
0 siblings, 4 replies; 5+ messages in thread
From: Ido Schimmel @ 2026-07-08 12:39 UTC (permalink / raw)
To: netdev; +Cc: davem, kuba, pabeni, edumazet, petrm, andrew+netdev, Ido Schimmel
Make the driver ops-locked in order to allow ethtool operations to be
invoked without RTNL being held.
An ops-locked driver has most of its NDOs, all of its ethtool operations
and some net device notifications run with the netdev instance lock
held.
In the specific case of mlxsw, the driver is not using any functions
that acquire this lock nor functions that expect the lock to be held for
an ops-locked driver. Therefore, converting its NDOs to run with the
lock being held is trivial except for a small quirk which is handled in
patch #1.
The driver does not generate any net device notifications, so there is
no risk of nested notifications of the ops-locked types. For the
notifications that run under the instance lock, RTNL is also held, and
the driver does not acquire the instance lock itself, so no changes are
required in its notifier handling.
Ethtool operations can be invoked without RTNL except for two operations
that are annotated in patch #2.
Lastly, patch #3 converts the driver to be ops-locked.
A probe on rtnl_lock() shows it is no longer taken when dumping
statistics:
# perf probe --add rtnl_lock
Before:
# perf stat -e probe:rtnl_lock -- ethtool -S swp1 --all-groups
[...]
1 probe:rtnl_lock
After:
# perf stat -e probe:rtnl_lock -- ethtool -S swp1 --all-groups
[...]
0 probe:rtnl_lock
No issues were reported after running a full regression with a debug
config that has lockdep enabled.
Ido Schimmel (3):
mlxsw: Convert to async version of ndo_set_rx_mode
mlxsw: ethtool: Prepare for RTNL-less ethtool operations
mlxsw: Tell the core to use the netdev instance lock
drivers/net/ethernet/mellanox/mlxsw/spectrum.c | 8 ++++++--
drivers/net/ethernet/mellanox/mlxsw/spectrum_ethtool.c | 2 ++
2 files changed, 8 insertions(+), 2 deletions(-)
--
2.54.0
^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH net-next 1/3] mlxsw: Convert to async version of ndo_set_rx_mode
2026-07-08 12:39 [PATCH net-next 0/3] mlxsw: Make the driver ops-locked Ido Schimmel
@ 2026-07-08 12:39 ` Ido Schimmel
2026-07-08 12:39 ` [PATCH net-next 2/3] mlxsw: ethtool: Prepare for RTNL-less ethtool operations Ido Schimmel
` (2 subsequent siblings)
3 siblings, 0 replies; 5+ messages in thread
From: Ido Schimmel @ 2026-07-08 12:39 UTC (permalink / raw)
To: netdev; +Cc: davem, kuba, pabeni, edumazet, petrm, andrew+netdev, Ido Schimmel
Commit c5b9b518adab ("mlxsw: spectrum: Add set_rx_mode ndo stub") added
a stub for ndo_set_rx_mode to prevent dev_ifsioc() from returning an
error for the SIOCADDMULTI and SIOCDELMULTI cases.
Since then dev_ifsioc() was taught to also accept ndo_set_rx_mode_async
and commit 3cbd22938877 ("net: warn ops-locked drivers still using
ndo_set_rx_mode") modified register_netdevice() to warn when registering
an ops-locked net device that still uses ndo_set_rx_mode instead of
ndo_set_rx_mode_async.
In preparation for converting the driver to be ops-locked, convert the
ndo_set_rx_mode stub to a ndo_set_rx_mode_async stub.
Reviewed-by: Danielle Ratson <danieller@nvidia.com>
Signed-off-by: Ido Schimmel <idosch@nvidia.com>
---
drivers/net/ethernet/mellanox/mlxsw/spectrum.c | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)
diff --git a/drivers/net/ethernet/mellanox/mlxsw/spectrum.c b/drivers/net/ethernet/mellanox/mlxsw/spectrum.c
index 82569162d2e5..3ee1272dcf0e 100644
--- a/drivers/net/ethernet/mellanox/mlxsw/spectrum.c
+++ b/drivers/net/ethernet/mellanox/mlxsw/spectrum.c
@@ -663,8 +663,11 @@ static netdev_tx_t mlxsw_sp_port_xmit(struct sk_buff *skb,
return NETDEV_TX_OK;
}
-static void mlxsw_sp_set_rx_mode(struct net_device *dev)
+static int mlxsw_sp_set_rx_mode_async(struct net_device *dev,
+ struct netdev_hw_addr_list *uc,
+ struct netdev_hw_addr_list *mc)
{
+ return 0;
}
static int mlxsw_sp_port_set_mac_address(struct net_device *dev, void *p)
@@ -1191,7 +1194,7 @@ static const struct net_device_ops mlxsw_sp_port_netdev_ops = {
.ndo_stop = mlxsw_sp_port_stop,
.ndo_start_xmit = mlxsw_sp_port_xmit,
.ndo_setup_tc = mlxsw_sp_setup_tc,
- .ndo_set_rx_mode = mlxsw_sp_set_rx_mode,
+ .ndo_set_rx_mode_async = mlxsw_sp_set_rx_mode_async,
.ndo_set_mac_address = mlxsw_sp_port_set_mac_address,
.ndo_change_mtu = mlxsw_sp_port_change_mtu,
.ndo_get_stats64 = mlxsw_sp_port_get_stats64,
--
2.54.0
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH net-next 2/3] mlxsw: ethtool: Prepare for RTNL-less ethtool operations
2026-07-08 12:39 [PATCH net-next 0/3] mlxsw: Make the driver ops-locked Ido Schimmel
2026-07-08 12:39 ` [PATCH net-next 1/3] mlxsw: Convert to async version of ndo_set_rx_mode Ido Schimmel
@ 2026-07-08 12:39 ` Ido Schimmel
2026-07-08 12:39 ` [PATCH net-next 3/3] mlxsw: Tell the core to use the netdev instance lock Ido Schimmel
2026-07-08 13:24 ` [PATCH net-next 0/3] mlxsw: Make the driver ops-locked Eric Dumazet
3 siblings, 0 replies; 5+ messages in thread
From: Ido Schimmel @ 2026-07-08 12:39 UTC (permalink / raw)
To: netdev; +Cc: davem, kuba, pabeni, edumazet, petrm, andrew+netdev, Ido Schimmel
A subsequent patch is going to make the driver ops-locked and allow
ethtool operations to run without RTNL. In preparation for this change,
tell the core about a couple of ethtool operations that should remain
under RTNL:
1. Set pause parameters: Configures the port's headroom buffer which is
also configured by RTNL-only paths such as DCB and qdisc. These paths
can probably be converted to acquire the netdev instance lock, but this
operation in not frequently called (unlike stats query), so avoid the
added complexity for now.
2. Get link state: Calls ethtool_op_get_link() which requires RTNL. See
commit 1105ef941c1a ("net: ethtool: keep rtnl_lock for ops using
ethtool_op_get_link()").
All the other operations do not access shared resources, do not invoke
helpers that require RTNL or already have the appropriate locking in
place.
Reviewed-by: Danielle Ratson <danieller@nvidia.com>
Signed-off-by: Ido Schimmel <idosch@nvidia.com>
---
drivers/net/ethernet/mellanox/mlxsw/spectrum_ethtool.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/drivers/net/ethernet/mellanox/mlxsw/spectrum_ethtool.c b/drivers/net/ethernet/mellanox/mlxsw/spectrum_ethtool.c
index 7f78b1ef61cc..3bdb532d833b 100644
--- a/drivers/net/ethernet/mellanox/mlxsw/spectrum_ethtool.c
+++ b/drivers/net/ethernet/mellanox/mlxsw/spectrum_ethtool.c
@@ -1262,6 +1262,8 @@ mlxsw_sp_set_module_power_mode(struct net_device *dev,
const struct ethtool_ops mlxsw_sp_port_ethtool_ops = {
.cap_link_lanes_supported = true,
+ .op_needs_rtnl = ETHTOOL_OP_NEEDS_RTNL_SPAUSEPARAM |
+ ETHTOOL_OP_NEEDS_RTNL_GLINK,
.get_drvinfo = mlxsw_sp_port_get_drvinfo,
.get_link = ethtool_op_get_link,
.get_link_ext_state = mlxsw_sp_port_get_link_ext_state,
--
2.54.0
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH net-next 3/3] mlxsw: Tell the core to use the netdev instance lock
2026-07-08 12:39 [PATCH net-next 0/3] mlxsw: Make the driver ops-locked Ido Schimmel
2026-07-08 12:39 ` [PATCH net-next 1/3] mlxsw: Convert to async version of ndo_set_rx_mode Ido Schimmel
2026-07-08 12:39 ` [PATCH net-next 2/3] mlxsw: ethtool: Prepare for RTNL-less ethtool operations Ido Schimmel
@ 2026-07-08 12:39 ` Ido Schimmel
2026-07-08 13:24 ` [PATCH net-next 0/3] mlxsw: Make the driver ops-locked Eric Dumazet
3 siblings, 0 replies; 5+ messages in thread
From: Ido Schimmel @ 2026-07-08 12:39 UTC (permalink / raw)
To: netdev; +Cc: davem, kuba, pabeni, edumazet, petrm, andrew+netdev, Ido Schimmel
After the previous changes the driver is now ready to have its net
device and ethtool operations invoked with the netdev instance lock
held.
Tell the core about it by setting request_ops_lock to true.
Reviewed-by: Danielle Ratson <danieller@nvidia.com>
Signed-off-by: Ido Schimmel <idosch@nvidia.com>
---
drivers/net/ethernet/mellanox/mlxsw/spectrum.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/drivers/net/ethernet/mellanox/mlxsw/spectrum.c b/drivers/net/ethernet/mellanox/mlxsw/spectrum.c
index 3ee1272dcf0e..815e8d8e3185 100644
--- a/drivers/net/ethernet/mellanox/mlxsw/spectrum.c
+++ b/drivers/net/ethernet/mellanox/mlxsw/spectrum.c
@@ -1552,6 +1552,7 @@ static int mlxsw_sp_port_create(struct mlxsw_sp *mlxsw_sp, u16 local_port,
dev->vlan_features |= NETIF_F_IP_CSUM | NETIF_F_IPV6_CSUM;
dev->lltx = true;
dev->netns_immutable = true;
+ dev->request_ops_lock = true;
dev->min_mtu = ETH_MIN_MTU;
dev->max_mtu = MLXSW_PORT_MAX_MTU - MLXSW_PORT_ETH_FRAME_HDR;
--
2.54.0
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH net-next 0/3] mlxsw: Make the driver ops-locked
2026-07-08 12:39 [PATCH net-next 0/3] mlxsw: Make the driver ops-locked Ido Schimmel
` (2 preceding siblings ...)
2026-07-08 12:39 ` [PATCH net-next 3/3] mlxsw: Tell the core to use the netdev instance lock Ido Schimmel
@ 2026-07-08 13:24 ` Eric Dumazet
3 siblings, 0 replies; 5+ messages in thread
From: Eric Dumazet @ 2026-07-08 13:24 UTC (permalink / raw)
To: Ido Schimmel; +Cc: netdev, davem, kuba, pabeni, petrm, andrew+netdev
On Wed, Jul 8, 2026 at 2:41 PM Ido Schimmel <idosch@nvidia.com> wrote:
>
> Make the driver ops-locked in order to allow ethtool operations to be
> invoked without RTNL being held.
>
> An ops-locked driver has most of its NDOs, all of its ethtool operations
> and some net device notifications run with the netdev instance lock
> held.
>
> In the specific case of mlxsw, the driver is not using any functions
> that acquire this lock nor functions that expect the lock to be held for
> an ops-locked driver. Therefore, converting its NDOs to run with the
> lock being held is trivial except for a small quirk which is handled in
> patch #1.
>
> The driver does not generate any net device notifications, so there is
> no risk of nested notifications of the ops-locked types. For the
> notifications that run under the instance lock, RTNL is also held, and
> the driver does not acquire the instance lock itself, so no changes are
> required in its notifier handling.
>
> Ethtool operations can be invoked without RTNL except for two operations
> that are annotated in patch #2.
>
> Lastly, patch #3 converts the driver to be ops-locked.
>
> A probe on rtnl_lock() shows it is no longer taken when dumping
> statistics:
>
> # perf probe --add rtnl_lock
>
> Before:
>
> # perf stat -e probe:rtnl_lock -- ethtool -S swp1 --all-groups
> [...]
> 1 probe:rtnl_lock
>
> After:
>
> # perf stat -e probe:rtnl_lock -- ethtool -S swp1 --all-groups
> [...]
> 0 probe:rtnl_lock
>
We probably want to add noinline_for_tracing to rtnl_lock() and friends...
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2026-07-08 13:25 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-07-08 12:39 [PATCH net-next 0/3] mlxsw: Make the driver ops-locked Ido Schimmel
2026-07-08 12:39 ` [PATCH net-next 1/3] mlxsw: Convert to async version of ndo_set_rx_mode Ido Schimmel
2026-07-08 12:39 ` [PATCH net-next 2/3] mlxsw: ethtool: Prepare for RTNL-less ethtool operations Ido Schimmel
2026-07-08 12:39 ` [PATCH net-next 3/3] mlxsw: Tell the core to use the netdev instance lock Ido Schimmel
2026-07-08 13:24 ` [PATCH net-next 0/3] mlxsw: Make the driver ops-locked Eric Dumazet
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox