Re: [PATCH net-next v2 2/3] net: add granular lock for the netdev netlink socket
From: Mina Almasry
Date: Tue Mar 11 2025 - 11:35:03 EST
On Tue, Mar 11, 2025 at 7:40 AM Stanislav Fomichev <sdf@xxxxxxxxxxx> wrote:
>
> As we move away from rtnl_lock for queue ops, introduce
> per-netdev_nl_sock lock.
>
> Cc: Mina Almasry <almasrymina@xxxxxxxxxx>
> Signed-off-by: Stanislav Fomichev <sdf@xxxxxxxxxxx>
> ---
> include/net/netdev_netlink.h | 1 +
> net/core/netdev-genl.c | 6 ++++++
> 2 files changed, 7 insertions(+)
>
> diff --git a/include/net/netdev_netlink.h b/include/net/netdev_netlink.h
> index 1599573d35c9..075962dbe743 100644
> --- a/include/net/netdev_netlink.h
> +++ b/include/net/netdev_netlink.h
> @@ -5,6 +5,7 @@
> #include <linux/list.h>
>
> struct netdev_nl_sock {
> + struct mutex lock;
> struct list_head bindings;
> };
>
> diff --git a/net/core/netdev-genl.c b/net/core/netdev-genl.c
> index a219be90c739..63e10717efc5 100644
> --- a/net/core/netdev-genl.c
> +++ b/net/core/netdev-genl.c
> @@ -859,6 +859,7 @@ int netdev_nl_bind_rx_doit(struct sk_buff *skb, struct genl_info *info)
> goto err_genlmsg_free;
> }
>
> + mutex_lock(&priv->lock);
You do not need to acquire this lock so early, no? AFAICT you only
need to lock around:
list_add(&binding->list, sock_binding_list);
Or is this to establish a locking order (sock_binding_list lock before
the netdev lock)?
--
Thanks,
Mina