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=1796175635; b=kSxzxpTiVEnA7Fi7ofvMfDPG/GsweLZZc3sIJRIlCc1iy8/mLXHqcYe9PA4yr02Qn01r J5ndl6g1XdwRspHfbU+VqlOH4kj9oy+8DXn9Q2sdxtLH2lJK1ozqDMa+ny0TZEB9uXMvh Jatao/3qDg5WwSBHycIgRuBUoJuTByzW0C0Sx2jyoO9v8JI6NGo42qD5difHacBtqMqU3 i2cfaDPCfPe6ShB+iLlcP4EDkbOsaAS1yYTRn3m93gOjae6irL1JCjU+STUL3HlvAel+z A8FcuFOBUGRL83dYGu+/8GGxIBPHpJhKpRuQ4iyCIEhQ1hvLeaY0YWrqBzLJfubdzNA== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796175635; h=Received:DKIM-Signature:Message-ID:Date:MIME-Version:User-Agent: Subject:Content-Language:To:Cc:References:From:In-Reply-To: Content-Type:Content-Transfer-Encoding; bh=kPRupaD33W4qRSQ8sT40Wv46/ED0OIz38gj0qIydZiU=; b=zCDNLLyqst/G+sZYM44p0Mh4szyZ8qRin21f5QpOup0aNKhQF+fV3y0/6iSNp3GXSgMQ VV3bu4T4y/LioBrkjOX2vw69ksuVp0uQSz05o7XN3qeHvX4iuqk3L0vMz+V67XGWL16rj lgqFkp46L/6/35S6fBIlvVnQNQMPyzo/uKI8Z/mpgi8RfwFzsJkbG3ZL1NjZx3GRHfrZf R1O2carrJWOtvzRWpJjwag/Ew7Hds75jn9x9dAQdcjJV4BFP+0gbjt3cPnK8nnr78wnHD fBSYxq/9+ikJNxuznaO35wOlF1tJQvQZamHHQItlE0m4loA+yLXqYV0rVHU3BF82K7A== 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=lhVWQVFn; 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)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 90D75606A32A; Wed, 2 Dec 2026 01:40:35 +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=lhVWQVFn Received: by smtp.kernel.org (Postfix) with ESMTPSA id D7A9B1F00931; Wed, 2 Dec 2026 01:40:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796175635; bh=kPRupaD33W4qRSQ8sT40Wv46/ED0OIz38gj0qIydZiU=; h=Date:Subject:To:Cc:References:From:In-Reply-To; b=lhVWQVFnDG9i5GTNZbnbbsUSszJtY9gbmLau5ZsxZSKk6m8xLpxz81nV6oOIW8m2C 6CV36YG6OiVVCdum0VP8G7YCnrLzQyuH2XEzppjoLSqfpbzHkZCRrSXpbK0ovNMoF8 HRsumac5HDcDtoy0svorYiGPJSzNxRicl8LXFKVk7tsojJRYQOuLKOKXBfEtM557cd /0wahE4gaGzSy6eTmkvvh4q59Wy+pkD+QXbyIgttPfe06aMew8KV0br/mcqSJxn1FC dwmL1lqikFACDCWGxG1dwIZ51Nh07EPkw+rE6Hs22RF2MrtZqAWm4f4kxxRqCPlzMm d6H4RHVy5YufA== Message-ID: <2bbaa7c4-0772-4ad1-b09b-b4958e301856@kernel.org> Date: Tue, 1 Dec 2026 18:40:34 -0700 X-Mailing-List: stable@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH net] ipv6: do not wait for a running gc in ip6_dst_gc() Content-Language: en-US To: Willem de Bruijn , netdev@vger.kernel.org Cc: Ido Schimmel , "David S . Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Simon Horman , Chris Mason , stable@vger.kernel.org References: <20261201015652.38202-1-willemb@google.com> From: David Ahern In-Reply-To: <20261201015652.38202-1-willemb@google.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit On 11/30/26 6:55 PM, Willem de Bruijn wrote: > From: Chris Mason > > 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: # 6.18.x: 12eddc685744: ipv6: annotate data-races around sysctl.ip6_rt_gc_interval > Cc: # 6.18.x > Signed-off-by: Chris Mason > [willemb: add lockdep_assert_held() and WRITE_ONCE() on ip6_rt_last_gc, > expand commit message] > Signed-off-by: Willem de Bruijn > --- > 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 Local sashiko instance back by gpt-6.1-sol found no issues.