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=1795059171; b=YGSrg5IBo6zPPMpIhKPadJfRMawFyfG8d8p8y28K6zjo1RpG3PKR4Gk0CRgWfXNR2hRj FGd8SAWQb1HsOT9VjxOmIIOS1icdvnz86Mutfz3zGK45nQ1jd8jal+XElwRWTEJus6V5l CMnCSWdo75866K84iy+yKmKqTs9WzHwgconIL1/42mWjVT80xecJsYx3IukhpDsbOAW/d Vc94yGlbpMP8d1KKpkwJFVMLocr44+G1UxMMY09JHC7OOsSPBmvPblJvT5TGHYFO6h+Ob nyatyk5/nr90fNEJ0RHMAJx1W/i72qzZKnPAxaNz7+jkKw08gjXYPDfdOcfyDmEafUQ== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795059171; h=Received:DKIM-Signature:From:To:Cc:Subject:Date:Message-ID:X-Mailer: In-Reply-To:References:User-Agent:X-stable:X-Patchwork-Hint: MIME-Version:Content-Transfer-Encoding; bh=5RGZO4X0R1yxd8/WyJc3IR5a9AYBIAB4WaBtgiSRYOs=; b=GYxz9Yr8Xj/lRVyAyBgrhtKk4rgDktPHCVoKDshp2y1dF6qYoCCaJc6fYNUFxaPqEJ48 VsATYfWnmR7BHtLX6J7+Gm+zVIa30squ+IV21i96I3Gy8vWOamJIgBUjzh2jQ0cj+RGbG 9vZtWpaO3h64FuKWtTpkHRMdj0ztxyThf/yEqZRReYGlsDcSBUOfy8VAB4/5mbs0LGZ4y EPHZGzV4xqlP1Q82PCgOBc9RXbYLmbhyNWGvP59RkNBOqJsnkOZmjDLCZOGRvkGJ9HSgB pjaz9Sm9GX8bYEyO8zSpYhZsivsI+aR4FZG38BnAy+Ze7zanQMt+bp/n0HTv4HIVs7A== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=linuxfoundation.org header.i=@linuxfoundation.org header.a=rsa-sha256 header.s=korg header.b=2BkRLLhH; 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 AC25B606A31C; Thu, 19 Nov 2026 03:32:51 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.a=rsa-sha256 header.s=korg header.b=2BkRLLhH Received: by smtp.kernel.org (Postfix) with ESMTPSA id 05E4F1F000C4; Thu, 19 Nov 2026 03:32:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1795059171; bh=5RGZO4X0R1yxd8/WyJc3IR5a9AYBIAB4WaBtgiSRYOs=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=2BkRLLhHaBAT+PrhHG6fRmD3OGiTQ16i4IkwXmWWgqCYSzJ6kJzn+t2allyEMFLW2 JJ3qIEr9UjzCEQveezyfQzRmAMj+5zBnwZjTKF1yEc7oaMfIZt9EjTURuTcyoVJv5Q botEmLDvYP4KktUSsS6wZbVGfX0rYZIb/jnvEMiY= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Ray Zhang , Kuniyuki Iwashima , Eric Dumazet , Paolo Abeni , Sasha Levin Subject: [PATCH 5.10 0746/1848] net: count last skb of each sk_backlog pass in __release_sock() Date: Wed, 18 Nov 2026 15:46:24 +0100 Message-ID: <20261118145947.712749558@linuxfoundation.org> X-Mailer: git-send-email 2.56.0 In-Reply-To: <20261118145911.150052362@linuxfoundation.org> References: <20261118145911.150052362@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore X-Mailing-List: patches@lists.linux.dev List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 5.10-stable review patch. If anyone has any objections, please let me know. ------------------ From: Ray Zhang [ Upstream commit c4e4056b21355356f6a95bcdf03a850edd9f49e7 ] Running 500 concurrent TCPv6 streams (neper "tcp_stream -6 -T 1 -F 500") on a 2-core Cortex-A53 (CONFIG_PREEMPT_NONE=y, HZ=1000, LATENCY_WARN) triggers resched_latency_warn() in __release_sock(): [ 3655.311821] sched: CPU 0 need_resched set for > 100006892 ns (100 ticks) without schedule [ 3655.311889] Call trace: ... [ 3655.311944] resched_latency_warn+0x7c/0x88 [ 3655.311958] sched_tick+0x1c0/0x418 ... [ 3655.312578] net_rx_action+0x238/0x438 ... [ 3655.312641] do_softirq+0x4c/0x90 [ 3655.312651] __local_bh_enable_ip+0x84/0x90 [ 3655.312663] local_bh_enable+0x1c/0x28 [ 3655.312674] __dev_queue_xmit+0x4a8/0xb00 ... [ 3655.312782] tcp_v6_do_rcv+0x240/0x5f8 [ 3655.312793] __release_sock+0x9c/0x188 [ 3655.312806] release_sock+0x150/0x168 [ 3655.312817] tcp_sendmsg+0x4c/0x70 __release_sock() can loop past 100 ms without calling cond_resched(): - Each outer-loop pass drains sk_backlog, but "if (!skb) break;" runs before "++nb", so a pass of B skbs only adds B - 1 to nb (0 for 1 skb). - With 500 TCPv6 streams and NAPI sharing two Cortex-A53 cores, runnable tasks keep TIF_NEED_RESCHED set on CPU 0. - During spin_unlock_bh() and TX softirqs (__dev_queue_xmit() -> local_bh_enable()), tcp_add_backlog() coalesces arriving pure ACKs into a single tail skb. - Repeated 1-skb passes never advance nb or call cond_resched(), triggering resched_latency_warn() after 100 ticks. Restore the do-while loop and drop "if (!skb) break;" so every skb increments nb across passes and calls cond_resched() every 16 skbs. Reproduced the issue and verified the fix on two 2-core Cortex-A53 hosts (CONFIG_PREEMPT_NONE=y, HZ=1000, LATENCY_WARN, latency_warn_once=0) with a userspace reproducer over /dev/net/tun: - CPU 0 runs a TCPv6 sender and a second runnable task while CPU 1 writes pure ACKs to /dev/net/tun (~30k TCPBacklogCoalesce/run), sustaining 1-skb sk_backlog refills in __release_sock() for ~400 ms (ftrace). - Before: CPU 0 stayed unscheduled in __release_sock(), hitting resched_latency_warn() 293 and 275 times on the two hosts (> 100.9 ms). - After: cond_resched() yielded CPU 0 inside __release_sock(), with 0 resched_latency_warn() hits on both hosts. - Also observed no regression with the workload from commit 16c610162d1f ("net: call cond_resched() less often in __release_sock()"), "super_netperf 4 -H srv -T,10 -l 3000 &". Fixes: 16c610162d1f ("net: call cond_resched() less often in __release_sock()") Cc: stable@vger.kernel.org Signed-off-by: Ray Zhang Reviewed-by: Kuniyuki Iwashima Reviewed-by: Eric Dumazet Link: https://patch.msgid.link/20261101075145.698399-1-sgzhang@google.com Signed-off-by: Paolo Abeni Signed-off-by: Sasha Levin --- net/core/sock.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/net/core/sock.c b/net/core/sock.c index 7d645d85da9fd..6cf0b1a7c2a74 100644 --- a/net/core/sock.c +++ b/net/core/sock.c @@ -2570,7 +2570,7 @@ void __release_sock(struct sock *sk) spin_unlock_bh(&sk->sk_lock.slock); - while (1) { + do { next = skb->next; prefetch(next); WARN_ON_ONCE(skb_dst_is_noref(skb)); @@ -2578,12 +2578,10 @@ void __release_sock(struct sock *sk) sk_backlog_rcv(sk, skb); skb = next; - if (!skb) - break; if (!(++nb & 15)) cond_resched(); - } + } while (skb); spin_lock_bh(&sk->sk_lock.slock); } -- 2.53.0