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=1796462276; b=vX/BB9F/1XwW/w74z8x8zEh364QozVSyEcYBIbStc7swA0ziRBct4fdzQv/fWLPEPm0M OqPU/Xxo1AfKSMThRsEH6my22yqgAmXMSp4VsgHPkqmjYFyuNV+LFomTv4J6injnWJ12j +itBbmrG5GY91GjiRweb+l/tlfJqq2FAYsv1dRmlh0VtO9XdbI41/Zu2rpS347WAxlYik 1KeVZFLHIR7kkmE52B8ZjcjKkljkLZDIFawISoX+KKmfvDKpehNpi7toShKYZvgkE0CSq dh8ZEVGSp24wuQhb4Q7NvlmzufguVGn+s5nmmL4jM+0ouImqg4TiFj0n2VFt5+F17pQ== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796462276; 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=WSxDI6PrYKmcQ4EyzGUmmysGC1KcJayo9oDiYm83Erg=; b=W8oJez9+F9K7SKzlEYoAoiucTVm44rbdUG8f2nYYoLGF5sNIYwDSLkMFqh5hsak2fn2X yMXXl3E9XHs8DlfzIb9KcsBdL5cwk0XOq+IApbxBHfVkFyvbXuR4c+B//mvwA7qugFFiu IaHZ+aHM11T4EeQUI4d1bP6nZHS3joMh76+QRgOKpoAFGlSXLqJqwXaosa18m+9nhcKm2 OsLsLjC1lodAN/idm2pm91je+p/f/ZSkyYW7fqeyDF6gCrEWsPluWZ9caR200hgIFP8sS mU07lwvDy6rG0TnNXBbUkC3Rj4hcK1z18HKaMLbOoQkMwXtNEH5+/Uc2NVSHcuoNtpg== 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="JApTb77/"; 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 472C7606A683 for ; Sat, 5 Dec 2026 09:17:56 +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=JApTb77/ Received: by smtp.kernel.org (Postfix) with ESMTPSA id 5AE941F0092B; Sat, 5 Dec 2026 09:17:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796462276; bh=WSxDI6PrYKmcQ4EyzGUmmysGC1KcJayo9oDiYm83Erg=; h=Subject:From:To:Cc:Date:In-Reply-To:References; b=JApTb77/1HU1zFC47Sr4+VPLkkkgmiL74lQuK/MKv45g7C8Ab7NtpVDdvM/8wJWBd p21/i8797h/yVBYXY1J4oUhHJrV1EYCmTmX/ODHUfVwietWVvTAdZYVxs+AtbofSuw Bx27+N+vSCji3E5fMZdwLTq6eVfu2G27se93N4AuWZ1luRWyoPkv5qISOKb/FpHnLX 69Ee0D0vWerK5c6SqAJjtjJ+PSkMlIgdozmcK407XM4UK50NXuMaHWByEQqZ12pAku /x/z0I3aZYQw2aARKSRESbxfcWIGnq7UZs9lB+yfSc568Lwwu0aRenCfv7q4rqgdsR yRQivkcyBW1eQ== Subject: Re: [PATCH v1 net-next 08/10] tcp: Introduce Generic PLB. From: netdev-bot+sashiko@kernel.org To: kuniyu@google.com Cc: edumazet@kernel.org, ncardwell@google.com, davem@davemloft.net, kuba@kernel.org, pabeni@redhat.com, willemb@google.com, horms@kernel.org, ycheng@google.com, kuni1840@gmail.com, netdev@vger.kernel.org Date: Sat, 05 Dec 2026 09:17:54 +0000 Message-ID: <179646227492.3146.3358157554448761176@kernel.org> In-Reply-To: <20261204085551.1518105-9-kuniyu@google.com> References: <20261204085551.1518105-9-kuniyu@google.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 6 potential issue(s) to consider. Critical: 0 · High: 0 · Medium: 2 · Low: 4 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] Generic PLB is on by default (net->ipv4.sysctl_tcp_plb_loss_rehash_prob = 128 in tcp_sk_init()) for… - [Medium] The stale-hop decay in tcp_plb_check_rehash_loss() starts one hop earlier than the commit message describes. - [Low] The commit message ('Every 5th Fast Recovery'), the sysctl docs and the field comment on struct tcp_sock::plb_loss_recoveries ('fast… - [Low] The new tcp_plb_loss_rehash_prob documentation describes Generic PLB as generally applicable. - [Low] ip-sysctl.rst describes tcp_plb_loss_rehash_prob as the 'Base probability for Generic PLB repathing, mapped from [0, 1] to [0, 255]… - [Low] The comment in tcp_plb_check_rehash_loss() says 'self-normalise MSS-per-sec rate', but the struct tcp_sock::plb_max_rate definition… -- tcp: Introduce Generic PLB. This commit adds Generic PLB. It is a variant of Protective Load Balancing that does not depend on the congestion control, and it rehashes the txhash based on packet loss and delivery rate regression. A new per-netns sysctl, net.ipv4.tcp_plb_loss_rehash_prob (default 128), sets the base probability, which is evaluated on every 5th loss recovery. A per-flow peak delivery rate is tracked in tcp_rate_gen() and decayed after repeated stale rehashes. Link: https://gist.github.com/q2ven/c04b56477dea4d1a58f5eadc4b07f9e0 > diff --git a/Documentation/networking/ip-sysctl.rst b/Documentation/networking/ip-sysctl.rst > index dffcec335a779..3046f6725b218 100644 > --- a/Documentation/networking/ip-sysctl.rst > +++ b/Documentation/networking/ip-sysctl.rst [ ... ] > @@ -1437,6 +1437,21 @@ tcp_plb_cong_thresh - INTEGER > > Default: 128 > > +tcp_plb_loss_rehash_prob - INTEGER > + Base probability for Generic PLB repathing, mapped from [0, 1] > + to [0, 255] (e.g., 128 means 50%). Setting this to 0 disables > + Generic PLB. [Severity: Low] Is "128 means 50%" accurate for how the value is used? tcp_plb_check_rehash_loss() never uses base_prob directly as the repath probability: rate_prob = (4 * base_prob * deficit * deficit) >> 16; ... prob = max(rate_prob, floor); Here floor is base_prob >> 1 while plb_rehash < 2, and base_prob >> 3 after that. The check also only runs on every 5th loss event. base_prob is the real probability only when the delivery rate has dropped by exactly 50%. Could this entry describe the floor, the deficit scaling and the 5-event cadence, so admins can predict what a given value does? > + > + Unlike tcp_plb_enabled which relies on ECN signals, Generic PLB > + is congestion-control-agnostic and triggers repathing based on > + packet loss and delivery rate regression relative to the flow's > + recent peak delivery rate. Larger tcp_plb_loss_rehash_prob > + values make repathing more aggressive. [Severity: Low] Should this entry say that the repath only changes the IPv6 flow label? The tcp_plb_enabled text above says so explicitly: PLB changes socket txhash which results in a change in IPv6 Flow Label field, and currently no-op for IPv4 headers. tcp_plb_rehash() calls __sk_rethink_txhash_reset_dst(). That function only resets the dst for AF_INET6, and its comment says "IPv4 ECMP path selection does not use sk_txhash". Generic PLB is still enabled by default for IPv4 sockets. For plain IPv4 traffic it bumps LINUX_MIB_TCPPLBREHASH and tp->plb_rehash, and applies the stale-hop decay to plb_max_rate, but nothing changes on the wire. The exception is when the host does its own encapsulation based on skb->hash. The commit message cites cloud VM environments as the motivation, but it does not mention the IPv6-only scope, and all the benchmarks are IPv6. > + > + Possible Values: 0 - 255 > + > + Default: 128 > + [ ... ] > diff --git a/net/ipv4/tcp_input.c b/net/ipv4/tcp_input.c > index d2445dc259324..ab524990b8786 100644 > --- a/net/ipv4/tcp_input.c > +++ b/net/ipv4/tcp_input.c [ ... ] > @@ -4201,6 +4215,7 @@ static void tcp_process_tlp_ack(struct sock *sk, u32 ack, int flag) > tcp_try_keep_open(sk); > NET_INC_STATS(sock_net(sk), > LINUX_MIB_TCPLOSSPROBERECOVERY); > + tcp_plb_check_rehash_loss(sk); [Severity: Low] The commit message says "Every 5th Fast Recovery", and the new field comment in include/linux/tcp.h says: u8 plb_loss_recoveries; /* fast recoveries since last PLB check */ This branch of tcp_process_tlp_ack() goes through tcp_init_cwnd_reduction(), TCP_CA_CWR, tcp_end_cwnd_reduction() and tcp_try_keep_open(). It never enters TCP_CA_Recovery, but it still increments plb_loss_recoveries. The counter is also reset outside the 5-event check. tcp_plb_rehash() resets it, and that function is shared with the ECN PLB path. tcp_plb_update_state_upon_rto() resets it too. So it really counts loss events since the last rehash, RTO or evaluation. The real cadence is therefore faster than the "~68% by the 20th Fast Recovery" model. The TLP hook looks intentional, since the packetdrill test later in the series exercises it. Could the commit message, the ip-sysctl.rst entry and the tcp.h comment be updated to cover it? > } else if (!(flag & (FLAG_SND_UNA_ADVANCED | > FLAG_NOT_DUP | FLAG_DATA_SACKED))) { > /* Pure dupack: original and TLP probe arrived; no loss */ > diff --git a/net/ipv4/tcp_ipv4.c b/net/ipv4/tcp_ipv4.c > index c1d2acb8b7b4e..85abbf6d58b93 100644 > --- a/net/ipv4/tcp_ipv4.c > +++ b/net/ipv4/tcp_ipv4.c > @@ -3534,6 +3534,7 @@ static int __net_init tcp_sk_init(struct net *net) > net->ipv4.sysctl_tcp_plb_suspend_rto_sec = 5; > /* Default congestion threshold for PLB to mark a round is 50% */ > net->ipv4.sysctl_tcp_plb_cong_thresh = (1 << TCP_PLB_SCALE) / 2; > + net->ipv4.sysctl_tcp_plb_loss_rehash_prob = 128; [Severity: Medium] Is it intended to turn Generic PLB on by default for every TCP socket in every netns, whatever the congestion control? The ECN-based tcp_plb_enabled defaults to off. With this default, tcp_plb_check_rehash_loss() runs on every tcp_enter_recovery(), which is reached from tcp_fastretrans_alert() and from the timer-driven tcp_rack_reo_timeout(). It also runs on the TLP loss branch of tcp_process_tlp_ack(). Every 5th such event it rehashes with probability max(rate_prob, floor). The floor applies even when the delivery rate has not dropped at all: if (tp->plb_rehash < 2) floor = base_prob >> 1; else floor = base_prob >> 3; prob = max(rate_prob, floor); Wouldn't a long-lived IPv6 flow on a single path with steady random loss then keep changing its flow label and resetting its dst for the life of the connection, with nothing to gain? plb_max_rate only ever rises in tcp_rate_gen(). The only decay is the stale-hop path. Consider a flow whose fair share drops because more flows join a shared bottleneck, which is not an ECMP problem. It would see a large deficit and a high rate_prob, and keep rehashing until the stale-hop decay catches up. sk_txrehash defaults to SOCK_TXREHASH_ENABLED, so nothing else gates this. tcp_plb_update_state_upon_rto() also now runs its pause and reset logic by default. The commit message gives the default of 128, and the selftests later in the series rely on it. The benchmarks, though, only cover a controlled 4-way IPv6 ECMP setup. Would it be better to default to 0, or to explain in the commit message why this new rehash trigger is safe for all existing TCP traffic? > > /* Reno is always built in */ > if (!net_eq(net, &init_net) && > diff --git a/net/ipv4/tcp_plb.c b/net/ipv4/tcp_plb.c > index 794bddc4dc2d2..324bcb27f540a 100644 > --- a/net/ipv4/tcp_plb.c > +++ b/net/ipv4/tcp_plb.c [ ... ] > @@ -96,6 +98,63 @@ void tcp_plb_check_rehash_ecn(struct sock *sk) > } > EXPORT_SYMBOL_GPL(tcp_plb_check_rehash_ecn); > > +void tcp_plb_check_rehash_loss(struct sock *sk) > +{ [ ... ] > + /* self-normalise MSS-per-sec rate, using the highest > + * observed rate. More regression, more rehash. > + */ [Severity: Low] This isn't a bug, but the comment says MSS-per-sec. The plb_max_rate field in include/linux/tcp.h is documented as ((MSS packets / us) << 20), and tcp_rate_gen() computes it as ((u64)rs->delivered << 20) / rs->interval_us. Should the comment say packets per microsecond scaled by 2^20? > + rate_prob = 0; > + cur_rate = (u64)tp->rate_delivered << 20; > + max_rate = tp->plb_max_rate * tp->rate_interval_us; > + if (max_rate > cur_rate) { > + u64 deficit; > + > + deficit = mul_u64_u64_div_u64(max_rate - cur_rate, > + 1 << 8, max_rate); > + rate_prob = (4 * base_prob * deficit * deficit) >> 16; > + rate_prob = min_t(u32, rate_prob, 255); > + > + /* Don't decay plb_max_rate if the regression is > + * under 15% (38/256). > + */ > + if (deficit < 38) > + tp->plb_stale_hops = 0; > + } else { > + tp->plb_stale_hops = 0; > + } [ ... ] > + if (!tcp_plb_rehash(sk)) > + return; > + > + if (tp->plb_stale_hops < 3) > + tp->plb_stale_hops++; > + if (tp->plb_stale_hops == 3) > + tp->plb_max_rate -= tp->plb_max_rate >> 3; > +} [Severity: Medium] Does this match the commit message? Therefore, tp->plb_stale_hops counts consecutive rehashes without recovery within ~15% of the peak (deficit < 38). Once three consecutive rehashes stay >= ~15% below tp->plb_max_rate, each subsequent stale rehash decays tp->plb_max_rate by 1/8 (to 7/8) so the flow adapts to the new paths. plb_stale_hops is reset only when the current evaluation looks healthy, and that happens before the rehash decision. It is then incremented on every successful rehash, including an exploratory floor-probability hop away from a healthy path. The decay also runs on the same rehash that brings the counter to 3: E1: healthy -> stale = 0, floor rehash -> stale = 1 E2: degraded -> rehash -> stale = 2 E3: degraded -> rehash -> stale = 3 -> plb_max_rate decayed At that point only two hops are known to have landed on degraded paths, and the third hop's result has not been seen yet. Would this erode the good-path memory one hop earlier than described? Should the increment depend on the path just left being degraded? Or should the decay apply only when the counter was already 3 before this rehash? -- Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261204085551.1518105-1-kuniyu%40google.com