From: David Ahern <dsahern@kernel.org>
To: Willem de Bruijn <willemb@google.com>, netdev@vger.kernel.org
Cc: Ido Schimmel <idosch@nvidia.com>,
"David S . Miller" <davem@davemloft.net>,
Eric Dumazet <edumazet@kernel.org>,
Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
Simon Horman <horms@kernel.org>, Chris Mason <mason@kernel.org>,
stable@vger.kernel.org
Subject: Re: [PATCH net] ipv6: do not wait for a running gc in ip6_dst_gc()
Date: Tue, 1 Dec 2026 18:40:34 -0700 [thread overview]
Message-ID: <2bbaa7c4-0772-4ad1-b09b-b4958e301856@kernel.org> (raw)
In-Reply-To: <20261201015652.38202-1-willemb@google.com>
On 11/30/26 6:55 PM, Willem de Bruijn wrote:
> From: Chris Mason <mason@kernel.org>
>
> With more than net.ipv6.route.gc_thresh cached routes, CPUs that
> allocate an IPv6 route while the route garbage collector runs can stall
> for as many gc runs as there are CPUs waiting, with bottom halves
> disabled.
>
> While more than net.ipv6.route.gc_thresh cached routes exist,
> dst_alloc() calls ip6_dst_gc(), which starts a gc run, fib6_run_gc(),
> unless the last one ended less than gc_min_interval ago. A gc run holds
> fib6_gc_lock with bottom halves disabled, and sets ip6_rt_last_gc, the
> time at which the last gc run ended, only at its end. But ip6_dst_gc()
> tests ip6_rt_last_gc before it takes the lock, so each CPU that passes
> the test during a gc run spins for the lock and then starts a gc run of
> its own.
>
> Commit 2ac3ac8f86f2 ("ipv6: prevent fib6_run_gc() contention") in v3.11
> fixed this contention, which it reported as soft lockups on a
> high-traffic router with many processors, by having ip6_dst_gc() only
> try the lock unless the number of entries exceeded max_size. Commit
> 14956643550f ("ipv6: slight optimization in ip6_dst_gc") in v3.16 made
> ip6_dst_gc() wait for the lock again in all cases, on the premise that
> the number of entries always exceeds max_size at that point. That does
> not hold once gc_min_interval has passed since the last gc run.
>
> The fix used here is to give ip6_dst_gc() a variant of fib6_run_gc(),
> fib6_try_run_gc(), which returns at once if another CPU holds
> fib6_gc_lock, and repeats the test of ip6_rt_last_gc under the lock.
>
> Found and fixed with an LLM; reproduced on an unmodified kernel with an
> LLM-generated reproducer in a 16-CPU KVM guest. Verified with the
> reproducer and IPv6 route selftests (fib_tests.sh, fib_nexthops.sh).
>
> Fixes: 14956643550f ("ipv6: slight optimization in ip6_dst_gc")
> Cc: <stable@vger.kernel.org> # 6.18.x: 12eddc685744: ipv6: annotate data-races around sysctl.ip6_rt_gc_interval
> Cc: <stable@vger.kernel.org> # 6.18.x
> Signed-off-by: Chris Mason <mason@kernel.org>
> [willemb: add lockdep_assert_held() and WRITE_ONCE() on ip6_rt_last_gc,
> expand commit message]
> Signed-off-by: Willem de Bruijn <willemb@google.com>
> ---
> include/net/ip6_fib.h | 1 +
> net/ipv6/ip6_fib.c | 44 +++++++++++++++++++++++++++++++++++--------
> net/ipv6/route.c | 4 +++-
> 3 files changed, 40 insertions(+), 9 deletions(-)
>
Reviewed-by: David Ahern <dsahern@kernel.org>
Local sashiko instance back by gpt-6.1-sol found no issues.
prev parent reply other threads:[~2026-12-02 1:40 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-12-01 1:55 [PATCH net] ipv6: do not wait for a running gc in ip6_dst_gc() Willem de Bruijn
2026-12-01 2:34 ` David Ahern
2026-12-01 15:41 ` willemb
2026-12-02 1:40 ` David Ahern [this message]
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=2bbaa7c4-0772-4ad1-b09b-b4958e301856@kernel.org \
--to=dsahern@kernel.org \
--cc=davem@davemloft.net \
--cc=edumazet@kernel.org \
--cc=horms@kernel.org \
--cc=idosch@nvidia.com \
--cc=kuba@kernel.org \
--cc=mason@kernel.org \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=stable@vger.kernel.org \
--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