Re: [PATCH net-next v1 4/4] net: drop rtnl_lock for queue_mgmt operations

Jakub Kicinski
2025-03-07T23:39:23Z

On Fri, 7 Mar 2025 07:57:25 -0800 Stanislav Fomichev wrote:
> All drivers that use queue API are already converted to use
> netdev instance lock. Move netdev instance lock management to
> the netlink layer and drop rtnl_lock.

> @@ -860,12 +854,11 @@ int netdev_nl_bind_rx_doit(struct sk_buff *skb, struct genl_info *info)
> }
>
> mutex_lock(&priv->lock);
> - rtnl_lock();
>
> - netdev = __dev_get_by_index(genl_info_net(info), ifindex);
> + netdev = netdev_get_by_index_lock(genl_info_net(info), ifindex);
> if (!netdev || !netif_device_present(netdev)) {
> err = -ENODEV;
> - goto err_unlock;
> + goto err_unlock_sock;
> }
>
> if (dev_xdp_prog_count(netdev)) {
> @@ -918,14 +911,15 @@ int netdev_nl_bind_rx_doit(struct sk_buff *skb, struct genl_info *info)
> if (err)
> goto err_unbind;
>
> - rtnl_unlock();
> + netdev_unlock(netdev);

Ah, here's the unlock :)

Looks good for the devmem binding, I think, the other functions will
need a bit more careful handling. So perhaps drop the queue get changes?
I'm cooking some patches for the queue get and queue stats.
AFAIU we need helpers which will go over netdevs and either take rtnl
lock or instance lock, depending on whether the driver is "ops locked"