From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796473862; b=ZfMrvraGzRydhLDZFNQMqiA2kzeA8f44eR/ravbXDuMFDLv3VA8D6kEVoyThDmt+9Xen fBBqaKNAlcL0jpnh/sxiZdNeYOtB/6mX/1HW8Aoe6aHNCHy1493r3LcmSIXD/6l2GWtWn +4T/DLO1Z/uerMFM9EriNuipKk/++L6QmaFUHTneyhgdzb+LnXbE4WXcKlKEGNJ7gEW4t V+z9mi9JbE1ZRorWwOIAprV/IG/BzMiOyGUPmBhrc88RLJgyfcmbQdxk1lavFr9Qxir/D s/jk9HKbuH4tf4TSSSXAQ5XPuJL6UANF4aRuLv5ioayOLXGnS+qWYt6RYzQ1u+UzBfw== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796473862; h=Received:DKIM-Signature:Subject:From:To:Cc:Date:Message-ID: In-Reply-To:References:X-sashiko-severity:Content-Type: Content-Transfer-Encoding:MIME-Version; bh=r4pEDHcT+jXvHMJb6t95YG0AuEb4Mqdq3HJS8eujI8c=; b=QDX7FSSOB7LlkR82b5+5/IzZqyIFU/r3eKfrtje37nWc1GGQAuxIPlyVqketqX+QVgXR SLJFI1GWDIfZCLWXeMcla39Ejdhfo1yt9owcOHIDYMda6SROg1+KTgFHpKMFdHt4rGlf3 zlnb7w2A9Mr7NCEXyw1/WZWciESn1VxY/N/3SSORTdwheVWRUJAhAOXIN31JglZm2kzlZ QGvKQC/o5H1xvw4z5sJM0dcPFjF/nuxJ5hPZPpdc6WiiBMXUA1f20qJDAE7XZQxeK7BiK Lr6JSbQ70JNP9OhHeJScnYiW394ACcCGdJBu0X5DoMYB8fwfpd4uWIEUfMlGr9pfsXA== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=ZqMtGs7w; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 59D49606A322; Sat, 5 Dec 2026 12:31:02 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=ZqMtGs7w Received: by smtp.kernel.org (Postfix) with ESMTPSA id 499711F0092B; Sat, 5 Dec 2026 12:31:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796473862; bh=r4pEDHcT+jXvHMJb6t95YG0AuEb4Mqdq3HJS8eujI8c=; h=Subject:From:To:Cc:Date:In-Reply-To:References; b=ZqMtGs7wHZ8tem+emn05HcXZzPgUex5DkyOW5o5Rik9Y+rhtdaGSzpf/QoprwLhDn qrKlvKsrCjoqazFNANN6uq6mBFfG3Igdw3UcRDAGOuA/R9KKOyFahKJY0UuzeKsAVT vVG3wrXltkqotgP9dZyCZ7ytEkE1N6B4XHFbJqaZoB8M77nGxFPK0iOcYgSPLFUYLg 3rNUK1fOJpg2yQ8jj4J47P5U6RbuMOFX7siVlkFbbsvdpGYXtP/fXWpRKB4EY6rF9y AWZczjY3XsdKNfnjacGgPK8o2efKTpfxY7m3w0d110lrGa3Ik+j9C7VK50EANFWYqQ EVKs3xjzeFX9A== Subject: Re: [PATCH net-next 1/2] ipv6: base dst ownership on RT6_LOOKUP_F_DST_NOREF only 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 Date: Sat, 05 Dec 2026 12:31:00 +0000 Message-ID: <179647386079.3146.11342277645201573853@kernel.org> In-Reply-To: <4ce33518174bd6b736b3535b3e3ede02c6d23184.1796382820.git.ralf@mandelbit.com> References: <4ce33518174bd6b736b3535b3e3ede02c6d23184.1796382820.git.ralf@mandelbit.com> X-sashiko-severity: Medium Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 8bit X-Mailing-List: netdev@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 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