From: Stanislav Fomichev <stfomichev@gmail.com>
To: Mina Almasry <almasrymina@google.com>
Cc: Stanislav Fomichev <sdf@fomichev.me>,
netdev@vger.kernel.org, davem@davemloft.net, edumazet@google.com,
kuba@kernel.org, pabeni@redhat.com, linux-kernel@vger.kernel.org,
donald.hunter@gmail.com, horms@kernel.org,
michael.chan@broadcom.com, pavan.chebbi@broadcom.com,
andrew+netdev@lunn.ch, jdamato@fastly.com,
xuanzhuo@linux.alibaba.com, asml.silence@gmail.com,
dw@davidwei.uk
Subject: Re: [PATCH net-next v2 2/3] net: add granular lock for the netdev netlink socket
Date: Tue, 11 Mar 2025 13:03:24 -0700 [thread overview]
Message-ID: <Z9CXDDrruPmTjdW5@mini-arch> (raw)
In-Reply-To: <CAHS8izNVZ0RqccDKGiL2h+MesCrvza_kwck0RmsrTNAcTkcmjA@mail.gmail.com>
On 03/11, Mina Almasry wrote:
> On Tue, Mar 11, 2025 at 7:40 AM Stanislav Fomichev <sdf@fomichev.me> wrote:
> >
> > As we move away from rtnl_lock for queue ops, introduce
> > per-netdev_nl_sock lock.
> >
> > Cc: Mina Almasry <almasrymina@google.com>
> > Signed-off-by: Stanislav Fomichev <sdf@fomichev.me>
> > ---
> > 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)?
Right, if I acquire it later, I'd have to do the same order
in netdev_nl_sock_priv_destroy and it seems to be a bit more complicated
to do (since we go over the list of bindings over there).
next prev parent reply other threads:[~2025-03-11 20:03 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-03-11 14:40 [PATCH net-next v2 0/3] net: remove rtnl_lock from the callers of queue APIs Stanislav Fomichev
2025-03-11 14:40 ` [PATCH net-next v2 1/3] net: create netdev_nl_sock to wrap bindings list Stanislav Fomichev
2025-03-11 15:24 ` Mina Almasry
2025-03-11 14:40 ` [PATCH net-next v2 2/3] net: add granular lock for the netdev netlink socket Stanislav Fomichev
2025-03-11 15:30 ` Mina Almasry
2025-03-11 20:03 ` Stanislav Fomichev [this message]
2025-03-11 23:43 ` Mina Almasry
2025-03-11 14:40 ` [PATCH net-next v2 3/3] net: drop rtnl_lock for queue_mgmt operations Stanislav Fomichev
2025-03-11 15:52 ` Mina Almasry
2025-03-12 20:50 ` [PATCH net-next v2 0/3] net: remove rtnl_lock from the callers of queue APIs patchwork-bot+netdevbpf
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=Z9CXDDrruPmTjdW5@mini-arch \
--to=stfomichev@gmail.com \
--cc=almasrymina@google.com \
--cc=andrew+netdev@lunn.ch \
--cc=asml.silence@gmail.com \
--cc=davem@davemloft.net \
--cc=donald.hunter@gmail.com \
--cc=dw@davidwei.uk \
--cc=edumazet@google.com \
--cc=horms@kernel.org \
--cc=jdamato@fastly.com \
--cc=kuba@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=michael.chan@broadcom.com \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=pavan.chebbi@broadcom.com \
--cc=sdf@fomichev.me \
--cc=xuanzhuo@linux.alibaba.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).