From: netdev-bot+sashiko@kernel.org
To: ralf@mandelbit.com
Cc: netdev@vger.kernel.org, dsahern@kernel.org, idosch@nvidia.com,
davem@davemloft.net, edumazet@kernel.org, kuba@kernel.org,
pabeni@redhat.com, willemb@google.com, horms@kernel.org,
linux-kernel@vger.kernel.org, dahern@nvidia.com,
andrea.mayer@uniroma2.it, antonio@mandelbit.com
Subject: Re: [PATCH net-next 1/2] ipv6: base dst ownership on RT6_LOOKUP_F_DST_NOREF only
Date: Sat, 05 Dec 2026 12:31:00 +0000 [thread overview]
Message-ID: <179647386079.3146.11342277645201573853@kernel.org> (raw)
In-Reply-To: <4ce33518174bd6b736b3535b3e3ede02c6d23184.1796382820.git.ralf@mandelbit.com>
Thank you for your contribution! Sashiko AI review found 1 potential
issue(s) to consider.
Critical: 0 · High: 0 · Medium: 1 · Low: 0
If you believe none of the issues are legitimate, please reply to each
issue of Medium severity or higher and explain why the AI is wrong.
If any of them are legitimate and you plan to respin, please let patchwork
know by including "pw-bot: cr" as a separate line at the end of your reply
(one such reply per series is enough).
- [Medium] rt6_dst_release_deferred() in net/ipv6/route.c (line 162)
drops the allocation reference of the uncached FLOWI_FLAG_KNOWN_NH…
--
ipv6: base dst ownership on RT6_LOOKUP_F_DST_NOREF only
This commit makes RT6_LOOKUP_F_DST_NOREF the only signal for dst
ownership, instead of membership in the uncached list. For the uncached
FLOWI_FLAG_KNOWN_NH RTF_CACHE clone, ip6_pol_route() no longer hands
the allocation reference to a NOREF caller. That reference is now
dropped after an RCU grace period by a new helper,
rt6_dst_release_deferred().
Link: https://lore.kernel.org/netdev/20261202161942.GA2800642@shredder/
> diff --git a/net/ipv6/route.c b/net/ipv6/route.c
> index d3c77941d2cf8..39bcfa1ce01b1 100644
> --- a/net/ipv6/route.c
> +++ b/net/ipv6/route.c
> @@ -147,6 +147,21 @@ void rt6_uncached_list_add(struct rt6_info *rt)
> spin_unlock_bh(&ul->lock);
> }
>
> +static void rt6_dst_release_rcu(struct rcu_head *head)
> +{
> + struct dst_entry *dst = container_of(head, struct dst_entry, rcu_head);
> +
> + dst_release(dst);
> +}
> +
> +/* Drop a reference after a grace period, so that RCU readers that found the
> + * dst without one can still use it and take their own.
> + */
> +static void rt6_dst_release_deferred(struct rt6_info *rt)
> +{
> + call_rcu(&rt->dst.rcu_head, rt6_dst_release_rcu);
[Severity: Medium]
Should this be call_rcu_hurry() rather than call_rcu()?
With CONFIG_RCU_LAZY=y on offloaded (rcu_nocbs) CPUs, plain call_rcu()
can leave the callback in the lazy bypass for up to the lazy flush
interval, which is about 10 seconds. The existing last-reference path for
the same object deliberately avoids that:
net/core/dst.c:dst_release() {
...
dst_count_dec(dst);
call_rcu_hurry(&dst->rcu_head, dst_destroy_rcu);
...
}
dst_destroy_rcu can only be queued once the deferred put has run. Every
uncached clone therefore lives for at least two grace periods, and the
first one may be lazy. During that window it still pins rt->from (the
fib6_info and its nexthop), rt6i_idev, the dst->dev reference and the
lwtstate.
> +}
> +
[ ... ]
> @@ -2310,12 +2325,14 @@ struct rt6_info *ip6_pol_route(struct net *net, struct fib6_table *table,
> rt = ip6_rt_cache_alloc(&res, &fl6->daddr, NULL);
>
> if (rt) {
> - /* 1 refcnt is taken during ip6_rt_cache_alloc().
> - * As rt6_uncached_list_add() does not consume refcnt,
> - * this refcnt is always returned to the caller even
> - * if caller sets RT6_LOOKUP_F_DST_NOREF flag.
> - */
> rt6_uncached_list_add(rt);
> + /* A RT6_LOOKUP_F_DST_NOREF caller does not inherit the
> + * reference ip6_rt_cache_alloc returned. Dropping it
> + * after a grace period keeps the dst alive for the
> + * caller's RCU section.
> + */
> + if (flags & RT6_LOOKUP_F_DST_NOREF)
> + rt6_dst_release_deferred(rt);
This path runs on every KNOWN_NH lookup that allocates a clone. It is
not limited to explicit NOREF callers, because
ip6_route_output_flags_noref() always sets the flag:
flags |= RT6_LOOKUP_F_DST_NOREF;
That means users of the refcounting ip6_route_output() API reach it once
per packet too, through:
ip6_route_output()->ip6_route_output_flags()->
ip6_route_output_flags_noref()->fib6_rule_lookup()->ip6_pol_route()
Those users include raw hdrincl sends, nf_dup_ipv6 (TEE/dup), IPVS
xmit, and seg6local End.X with nh6. Remote traffic can drive several of
them.
> rcu_read_unlock();
>
> return rt;
> @@ -2715,13 +2732,10 @@ struct dst_entry *ip6_route_output_flags(struct net *net,
> int flags)
> {
> struct dst_entry *dst;
> - struct rt6_info *rt6;
>
> rcu_read_lock();
> dst = ip6_route_output_flags_noref(net, sk, fl6, flags);
> - rt6 = dst_rt6_info(dst);
> - /* For an uncached dst, refcnt is already taken. */
> - if (!rt6->dst.rt_uncached_list && !dst_hold_safe(dst)) {
> + if (!dst_hold_safe(dst)) {
Before this patch, these callers inherited the allocation reference. They
paid one dst_release() and one hurried grace period per clone.
They now pay an extra refcount increment and decrement here, plus one
extra RCU callback per packet on top of the final dst_destroy_rcu.
The commit message only says the reference "is dropped after a grace
period instead". Could it also mention this extra per-packet cost for
ip6_route_output() users and explain the choice of call_rcu() over
call_rcu_hurry()?
The later patch in the series, "ipv6: keep a superseded pcpu dst working
until its holders notice", reuses rt6_dst_release_deferred() for replaced
per-CPU dsts and keeps call_rcu(). The issue is therefore still present
at the end of the series.
> dst = &net->ipv6.ip6_null_entry->dst;
> dst_hold(dst);
> }
--
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/cover.1796382820.git.ralf%40mandelbit.com
next prev parent reply other threads:[~2026-12-05 12:31 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-12-04 11:29 [PATCH net-next 0/2] ipv6: move superseded pcpu dsts to the uncached list Ralf Lici
2026-12-04 11:29 ` [PATCH net-next 1/2] ipv6: base dst ownership on RT6_LOOKUP_F_DST_NOREF only Ralf Lici
2026-12-05 12:31 ` netdev-bot+sashiko [this message]
2026-12-04 11:29 ` [PATCH net-next 2/2] ipv6: keep a superseded pcpu dst working until its holders notice Ralf Lici
2026-12-05 12:31 ` netdev-bot+sashiko
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=179647386079.3146.11342277645201573853@kernel.org \
--to=netdev-bot+sashiko@kernel.org \
--cc=andrea.mayer@uniroma2.it \
--cc=antonio@mandelbit.com \
--cc=dahern@nvidia.com \
--cc=davem@davemloft.net \
--cc=dsahern@kernel.org \
--cc=edumazet@kernel.org \
--cc=horms@kernel.org \
--cc=idosch@nvidia.com \
--cc=kuba@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=ralf@mandelbit.com \
--cc=willemb@google.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