From: Ido Schimmel <idosch@nvidia.com>
To: lirongqing <lirongqing@baidu.com>
Cc: David Ahern <dsahern@kernel.org>,
Andrew Lunn <andrew+netdev@lunn.ch>,
"David S . Miller" <davem@davemloft.net>,
Eric Dumazet <edumazet@google.com>,
Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
netdev@vger.kernel.org
Subject: Re: [PATCH][net-next] net: vrf: switch to synchronize_net() when releasing routes
Date: Wed, 11 Mar 2026 15:19:35 +0200 [thread overview]
Message-ID: <20260311131935.GA2415888@shredder> (raw)
In-Reply-To: <20260310105331.2371-1-lirongqing@baidu.com>
On Tue, Mar 10, 2026 at 06:53:31AM -0400, lirongqing wrote:
> From: Li RongQing <lirongqing@baidu.com>
>
> Replace synchronize_rcu() with synchronize_net() in vrf_rtable_release()
> and vrf_rt6_release().
>
> synchronize_net() is RTNL-aware and can use the more efficient
> synchronize_rcu_expedited() when the RTNL lock is held, avoiding
> potentially long wait times for a standard RCU grace period.
>
> Since these release functions are called during device teardown where
> the RTNL lock is typically held, this change reduces the time spent
> in RTNL critical sections and speeds up VRF device deletion.
>
> Signed-off-by: Li RongQing <lirongqing@baidu.com>
> ---
> drivers/net/vrf.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/net/vrf.c b/drivers/net/vrf.c
> index 8c009bc..92a0f4b 100644
> --- a/drivers/net/vrf.c
> +++ b/drivers/net/vrf.c
> @@ -755,7 +755,7 @@ static void vrf_rt6_release(struct net_device *dev, struct net_vrf *vrf)
> struct dst_entry *dst;
>
> RCU_INIT_POINTER(vrf->rt6, NULL);
> - synchronize_rcu();
> + synchronize_net();
I might be missing something, but why do we need synchronize_rcu() here?
The code below calls dst_release() which will only free the dst entry
after an RCU grace period (assuming we dropped the last reference).
Also, I think that instead of using net->loopback_dev the code can be
converted to use dst_dev_put() before dst_release().
>
> /* move dev in dst's to loopback so this VRF device can be deleted
> * - based on dst_ifdown
> @@ -1002,7 +1002,7 @@ static void vrf_rtable_release(struct net_device *dev, struct net_vrf *vrf)
> struct dst_entry *dst;
>
> RCU_INIT_POINTER(vrf->rth, NULL);
> - synchronize_rcu();
> + synchronize_net();
>
> /* move dev in dst's to loopback so this VRF device can be deleted
> * - based on dst_ifdown
> --
> 2.9.4
>
next prev parent reply other threads:[~2026-03-11 13:19 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-03-10 10:53 [PATCH][net-next] net: vrf: switch to synchronize_net() when releasing routes lirongqing
2026-03-11 13:19 ` Ido Schimmel [this message]
2026-03-11 13:26 ` Eric Dumazet
2026-03-11 15:26 ` Ido Schimmel
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=20260311131935.GA2415888@shredder \
--to=idosch@nvidia.com \
--cc=andrew+netdev@lunn.ch \
--cc=davem@davemloft.net \
--cc=dsahern@kernel.org \
--cc=edumazet@google.com \
--cc=kuba@kernel.org \
--cc=lirongqing@baidu.com \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.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