From: Stanislav Fomichev <stfomichev@gmail.com>
To: Cosmin Ratiu <cratiu@nvidia.com>
Cc: "netdev@vger.kernel.org" <netdev@vger.kernel.org>,
"sdf@fomichev.me" <sdf@fomichev.me>,
"jhs@mojatatu.com" <jhs@mojatatu.com>,
"davem@davemloft.net" <davem@davemloft.net>,
"saeed@kernel.org" <saeed@kernel.org>,
Dragos Tatulea <dtatulea@nvidia.com>,
"xiyou.wangcong@gmail.com" <xiyou.wangcong@gmail.com>,
"jiri@resnulli.us" <jiri@resnulli.us>,
"kuba@kernel.org" <kuba@kernel.org>,
"edumazet@google.com" <edumazet@google.com>,
"pabeni@redhat.com" <pabeni@redhat.com>
Subject: Re: [PATCH net-next v10 04/14] net: hold netdev instance lock during qdisc ndo_setup_tc
Date: Mon, 5 May 2025 08:07:03 -0700 [thread overview]
Message-ID: <aBjUFyaiZ9UHpvze@mini-arch> (raw)
In-Reply-To: <eba9def750047f1789b708b97e376f453f09bfa4.camel@nvidia.com>
On 05/05, Cosmin Ratiu wrote:
> On Wed, 2025-03-05 at 08:37 -0800, Stanislav Fomichev wrote:
> > Qdisc operations that can lead to ndo_setup_tc might need
> > to have an instance lock. Add netdev_lock_ops/netdev_unlock_ops
> > invocations for all psched_rtnl_msg_handlers operations.
>
> Sorry for resurrecting this thread, but it seems like a good place to
> ask a related question.
>
> If qdisc operations that lead to .ndo_setup_tc() need to hold an
> instance lock, shouldn't all such callers acquire it?
>
> In my testing, I found out that e.g., when unloading a device, there's
> this call path which ends up calling .ndo_setup_tc() unlocked:
>
> devlink_reload -...-> device_del -...-> unregister_netdev -...->
> unregister_netdevice_many_notify -> dev_shutdown -> qdisc_put ->
> __qdisc_destroy -> mqprio_disable_offload -> .ndo_setup_tc
>
> Many other qdiscs (other than mqprio) call .ndo_setup_tc() and would be
> in a similar situation.
>
> Does it make sense to extend the netdev lock for dev_shutdown like in
> the patch below? After some basic testing, it seems safe but I haven't
> looked too deep into all possibilities.
>
> Cosmin.
>
> From e8b613dfd2b241a6c19bb89a829d598d6640b6f9 Mon Sep 17 00:00:00 2001
> From: Cosmin Ratiu <cratiu@nvidia.com>
> Date: Mon, 5 May 2025 15:34:53 +0300
> Subject: [PATCH 01/20] net/sched: Lock netdevices during dev_shutdown
>
> Various qdiscs can end up calling into .ndo_setup_tc() and as such,
> might need the netdev instance lock.
>
> Signed-off-by: Cosmin Ratiu <cratiu@nvidia.com>
> ---
> net/core/dev.c | 4 +++-
> 1 file changed, 3 insertions(+), 1 deletion(-)
>
> diff --git a/net/core/dev.c b/net/core/dev.c
> index d1a8cad0c99c..134ceddf7fa5 100644
> --- a/net/core/dev.c
> +++ b/net/core/dev.c
> @@ -12020,9 +12020,9 @@ void unregister_netdevice_many_notify(struct
> list_head *head,
> struct sk_buff *skb = NULL;
>
> /* Shutdown queueing discipline. */
> + netdev_lock_ops(dev);
> dev_shutdown(dev);
> dev_tcx_uninstall(dev);
There is a synchronize_net hidden inside of dev_tcx_uninstall, so
let's ops-lock only dev_shutdown here? Other than that, don't see
anything wrong. Can you send this separately and target net tree?
next prev parent reply other threads:[~2025-05-05 15:07 UTC|newest]
Thread overview: 34+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-03-05 16:37 [PATCH net-next v10 00/14] net: Hold netdev instance lock during ndo operations Stanislav Fomichev
2025-03-05 16:37 ` [PATCH net-next v10 01/14] net: hold netdev instance lock during ndo_open/ndo_stop Stanislav Fomichev
2025-03-05 16:37 ` [PATCH net-next v10 02/14] net: hold netdev instance lock during nft ndo_setup_tc Stanislav Fomichev
2025-03-07 19:39 ` Eric Dumazet
2025-03-07 19:57 ` Stanislav Fomichev
2025-03-05 16:37 ` [PATCH net-next v10 03/14] net: sched: wrap doit/dumpit methods Stanislav Fomichev
2025-03-05 16:37 ` [PATCH net-next v10 04/14] net: hold netdev instance lock during qdisc ndo_setup_tc Stanislav Fomichev
2025-03-13 8:51 ` Eric Dumazet
2025-03-13 9:11 ` Stanislav Fomichev
2025-05-05 13:41 ` Cosmin Ratiu
2025-05-05 15:07 ` Stanislav Fomichev [this message]
2025-05-05 15:12 ` Cosmin Ratiu
2025-05-05 18:35 ` Jakub Kicinski
2025-05-05 18:54 ` Stanislav Fomichev
2025-05-05 19:03 ` Jakub Kicinski
2025-03-05 16:37 ` [PATCH net-next v10 05/14] net: hold netdev instance lock during queue operations Stanislav Fomichev
2025-03-05 16:37 ` [PATCH net-next v10 06/14] net: hold netdev instance lock during rtnetlink operations Stanislav Fomichev
2025-03-05 16:37 ` [PATCH net-next v10 07/14] net: hold netdev instance lock during ioctl operations Stanislav Fomichev
2025-03-05 16:37 ` [PATCH net-next v10 08/14] net: hold netdev instance lock during sysfs operations Stanislav Fomichev
2025-03-24 15:34 ` Cosmin Ratiu
2025-03-24 15:56 ` Cosmin Ratiu
2025-03-24 16:06 ` Stanislav Fomichev
2025-03-24 17:06 ` Cosmin Ratiu
2025-03-24 18:18 ` Stanislav Fomichev
2025-03-05 16:37 ` [PATCH net-next v10 09/14] net: hold netdev instance lock during ndo_bpf Stanislav Fomichev
2025-03-05 16:37 ` [PATCH net-next v10 10/14] net: ethtool: try to protect all callback with netdev instance lock Stanislav Fomichev
2025-03-05 16:37 ` [PATCH net-next v10 11/14] net: replace dev_addr_sem " Stanislav Fomichev
2025-03-05 16:37 ` [PATCH net-next v10 12/14] net: add option to request " Stanislav Fomichev
2025-03-05 16:37 ` [PATCH net-next v10 13/14] docs: net: document new locking reality Stanislav Fomichev
2025-03-05 16:37 ` [PATCH net-next v10 14/14] eth: bnxt: remove most dependencies on RTNL Stanislav Fomichev
2025-03-06 21:50 ` [PATCH net-next v10 00/14] net: Hold netdev instance lock during ndo operations patchwork-bot+netdevbpf
-- strict thread matches above, loose matches on Subject: below --
2025-03-02 0:08 Stanislav Fomichev
2025-03-02 0:08 ` [PATCH net-next v10 04/14] net: hold netdev instance lock during qdisc ndo_setup_tc Stanislav Fomichev
2025-03-02 20:56 ` Jamal Hadi Salim
2025-03-03 15:35 ` Stanislav Fomichev
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=aBjUFyaiZ9UHpvze@mini-arch \
--to=stfomichev@gmail.com \
--cc=cratiu@nvidia.com \
--cc=davem@davemloft.net \
--cc=dtatulea@nvidia.com \
--cc=edumazet@google.com \
--cc=jhs@mojatatu.com \
--cc=jiri@resnulli.us \
--cc=kuba@kernel.org \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=saeed@kernel.org \
--cc=sdf@fomichev.me \
--cc=xiyou.wangcong@gmail.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.