From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=209.85.214.199 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796472801; b=uUmhL+LXBwjKZS8XQNja1DkEfBMMX8/2geUSpbVLqwAkYSsvZ465cBXTi4thMMKh9XHO D2BK9ZiviV8qbl+MmBsk/23fhG0ZaoNu9L5Dp3efDR63hVEaoRywwbcRWmc8YXLzXEEkD UPhaqcL1kkqKqeyfurua/E1G7U+J5n+sxiYpZsMQ5A/MSgInURyf7hnGlbguzcFpG2Y/T ThW2v0V2V5KuuKjHo6tq3SxRsduak9cgFnp99nXFHRvdgRbIU1ylecerqJlROFy3Gb+/t /KGyAi0oURAE5amVxsKA3N4sp1MAuCKfVdjL3iNfsU44gev9MJmXd7ecog6alJm+tfw== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796472801; h=DMARC-Filter:Received:DKIM-Signature:X-Google-DKIM-Signature: X-Forwarded-Encrypted:X-Gm-Message-State:X-Received:Date:In-Reply-To: Mime-Version:References:Message-ID:Subject:From:To:Cc:Content-Type: Content-Transfer-Encoding; bh=u3MsDjIhOgnQ9R+OQdJzayLnVncuENkmRUovz7QEZoc=; b=DWI9YeUdbnnAMmWJVBxqMKEJRFyCrZYY22aHbJ1W6MEleJm+MHDDUD8r4ISk+XJtpjAI ejTY1z7x1MVXQ0lF00ebrG4n/3dO1pf4bMnddx9NIRhA8IOVhQq6bIL7c+xeDdiRmN1a5 /3d1fXujN9gh2FNQ+AU8Ag3KnoYO+upYiRDzNdIZF1TixbqwjpNdV6yqW83aOPVKBdc14 s1oV3LDtGLB4xKw71lhyrI7s/8hPNaZlNGAEhoCRNoyWowzUAjSR+MF1efahg8UQYTE0z ttGODhnuLl+dLgU+xrA42VFqlg0hoq+MN6QKpJWdcxfcTktLsmKg7sXUV29vDGl3Drw== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=google.com; spf=pass smtp.mailfrom=flex--kuniyu.bounces.google.com; dkim=pass header.d=google.com header.i=@google.com header.a=rsa-sha256 header.s=20260707 header.b=SmWHVtMY; arc=none smtp.remote-ip=209.85.214.199 Received: from mail-pl1-f199.google.com (mail-pl1-f199.google.com [209.85.214.199]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 0136D606A322 for ; Sat, 5 Dec 2026 12:13:20 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 0136D606A322 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--kuniyu.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key, unprotected) header.d=google.com header.i=@google.com header.a=rsa-sha256 header.s=20260707 header.b=SmWHVtMY Received: by mail-pl1-f199.google.com with SMTP id d9443c01a7336-2f0e3ffabe0so22532465ad.0 for ; Sat, 05 Dec 2026 04:13:20 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20260707; t=1796472800; x=1797077600; darn=vger.kernel.org; h=content-transfer-encoding:content-type:cc:to:from:subject :message-id:references:mime-version:in-reply-to:date:from:to:cc :subject:date:message-id:reply-to:content-type; bh=u3MsDjIhOgnQ9R+OQdJzayLnVncuENkmRUovz7QEZoc=; b=SmWHVtMY89/8XG547ROaUMHbL3a7KXTNBbitSUOa/znrpcoqYNvhOHwDOLVJgCI1qd sPyYHAyj1qBQkWToZjMIPZXexBo+k1ANKKVPdjzF9s6JV0+etdkiv35PqvEvPftBls92 34KMB41TR2i2x6HR/xh726OmrkEywBeu/Ux9CGZLav2+aInG8H9mTzi2qGh83biJyW5e UxLcR2uJSCB2oruk8iN5xcKRBkPr7gbB4QJ+LROiPuaWo+Y88TGSaDM8XEpFbEqO22F6 UVKm5n8slQcf5f+QxoBc4jln+pOlogmwxxMSSpwYcWLUxgGK4nbpGFVt7VnPonMULIMA SIIA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1796472800; x=1797077600; h=content-transfer-encoding:content-type:cc:to:from:subject :message-id:references:mime-version:in-reply-to:date :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=u3MsDjIhOgnQ9R+OQdJzayLnVncuENkmRUovz7QEZoc=; b=EJW/ItMno/6wnKwUIZFn6NHi6gL2eeRCViWXKPyIgMkyC3mIaXKkXLp3gjwwXHMBvV sN/15AUGXY9ObRW2GVutprb8oLdrUnJ/ovjHrUHfCHpUZOLL+poKnwCRVZMLFv1VUXrn KT+BFyyDvbB52rZRQYZ7MtFVWuIl+oNABu6CYiVJcOvMQ+Uj4uROrw4mPr14wX5DaEAW D3brV63jgzzAp5S84Oa4W5xtbCZd5nnOoZwIgz9ol4KsNt6Rr4afvHabJe/4dP0wX3hY 7uNNOF11Sbulo9gj3oxj07S/6ccST2EnRQGkJfuK9udj0HCuUrYvkDEQbKHNSP5TcGS4 d0zA== X-Forwarded-Encrypted: i=1; AL+hErHhHfLDM2Cd3/t+92Ohaclqc4vNgOSV3QR4RTUg+nyJ9mGOlg5JpWkY04EvrmpZVkGrb80UkgE=@vger.kernel.org X-Gm-Message-State: AB4q+uECoe6iX4FEswy6s7wnCBOx+bVDYTZ2LDhRO4a6+3g/7qG9pi3j 8NevvRuvtrpkcudhbTa/qMro9KtqOsV4dSbptc7FvpRknj0PKsJB1PYZ2l0A0L0vX6VujY0QGKT FEBwEaw== X-Received: from plgl8.prod.google.com ([2002:a17:902:f688:b0:2f1:abf4:6810]) (user=kuniyu job=prod-delivery.src-stubby-dispatcher) by 2002:a17:902:f54d:b0:2f0:56b8:e75f with SMTP id d9443c01a7336-2f1ba16b219mr51478845ad.29.1796472799832; Sat, 05 Dec 2026 04:13:19 -0800 (PST) Date: Sat, 5 Dec 2026 21:13:19 +0900 In-Reply-To: <179646227492.3146.3358157554448761176@kernel.org> 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 References: <20261204085551.1518105-9-kuniyu@google.com> <179646227492.3146.3358157554448761176@kernel.org> Message-ID: Subject: Re: [PATCH v1 net-next 08/10] tcp: Introduce Generic PLB. From: Kuniyuki Iwashima To: netdev-bot+sashiko@kernel.org 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 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable On Sat, 05 Dec 2026 09:17:54 +0000, netdev-bot+sashiko@kernel.org wrote: > Thank you for your contribution! Sashiko AI review found 6 potential > issue(s) to consider. >=20 > Critical: 0 =C2=B7 High: 0 =C2=B7 Medium: 2 =C2=B7 Low: 4 >=20 > 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 patchwor= k > know by including "pw-bot: cr" as a separate line at the end of your repl= y > (one such reply per series is enough). >=20 > - [Medium] Generic PLB is on by default > (net->ipv4.sysctl_tcp_plb_loss_rehash_prob =3D 128 in tcp_sk_init()) fo= r=E2=80=A6 > - [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=E2= =80=A6 > - [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]= =E2=80=A6 > - [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=E2= =80=A6 >=20 > -- >=20 > tcp: Introduce Generic PLB. >=20 > 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. >=20 > Link: https://gist.github.com/q2ven/c04b56477dea4d1a58f5eadc4b07f9e0 >=20 > > diff --git a/Documentation/networking/ip-sysctl.rst b/Documentation/net= working/ip-sysctl.rst > > index dffcec335a779..3046f6725b218 100644 > > --- a/Documentation/networking/ip-sysctl.rst > > +++ b/Documentation/networking/ip-sysctl.rst >=20 > [ ... ] >=20 > > @@ -1437,6 +1437,21 @@ tcp_plb_cong_thresh - INTEGER > > =20 > > Default: 128 > > =20 > > +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. >=20 > [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: >=20 > rate_prob =3D (4 * base_prob * deficit * deficit) >> 16; > ... > prob =3D max(rate_prob, floor); >=20 > 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%. >=20 > Could this entry describe the floor, the deficit scaling and the 5-event > cadence, so admins can predict what a given value does? >=20 > > + > > + 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. >=20 > [Severity: Low] > Should this entry say that the repath only changes the IPv6 flow label? > The tcp_plb_enabled text above says so explicitly: >=20 > PLB changes socket txhash which results in a change in IPv6 Flow Label > field, and currently no-op for IPv4 headers. >=20 > 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". >=20 > 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. >=20 > 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. >=20 > > + > > + Possible Values: 0 - 255 > > + > > + Default: 128 > > + >=20 > [ ... ] >=20 > > 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 >=20 > [ ... ] >=20 > > @@ -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); >=20 > [Severity: Low] > The commit message says "Every 5th Fast Recovery", and the new field > comment in include/linux/tcp.h says: >=20 > u8 plb_loss_recoveries; /* fast recoveries since last PLB check */ >=20 > 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. >=20 > 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. >=20 > 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? >=20 > > } 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 =3D 5; > > /* Default congestion threshold for PLB to mark a round is 50% */ > > net->ipv4.sysctl_tcp_plb_cong_thresh =3D (1 << TCP_PLB_SCALE) / 2; > > + net->ipv4.sysctl_tcp_plb_loss_rehash_prob =3D 128; >=20 > [Severity: Medium] > Is it intended to turn Generic PLB on by default for every TCP socket in > every netns, whatever the congestion control? Yes, it's intentional. Generic PLB does not require network-side ECN deployment, so enabling it by default allows general TCP workloads (such as CUBIC/BBR in cloud VMs) to benefit automatically, just like RTO-triggered rehashing (net.core.txrehash=3D1). > The ECN-based > tcp_plb_enabled defaults to off. >=20 > 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). >=20 > The floor applies even when the delivery rate has not dropped at all: >=20 > if (tp->plb_rehash < 2) > floor =3D base_prob >> 1; > else > floor =3D base_prob >> 3; >=20 > prob =3D max(rate_prob, floor); >=20 > 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? On a single-path flow with steady random loss, floor drops to 16/255 (~6.3%) after two rehashes, and it's evaluated only on every 5th loss recovery (~1 rehash per ~80 loss events), which adds negligible overhead and is harmless when there is only one path. >=20 > 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. On a shared bottleneck where fair share drops, the plb_stale_hops decay brings plb_max_rate down to the new fair share so rehashing settles. >=20 > 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. >=20 > 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? I'll mention that in v2. >=20 > > =20 > > /* 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 >=20 > [ ... ] >=20 > > @@ -96,6 +98,63 @@ void tcp_plb_check_rehash_ecn(struct sock *sk) > > } > > EXPORT_SYMBOL_GPL(tcp_plb_check_rehash_ecn); > > =20 > > +void tcp_plb_check_rehash_loss(struct sock *sk) > > +{ >=20 > [ ... ] >=20 > > + /* self-normalise MSS-per-sec rate, using the highest > > + * observed rate. More regression, more rehash. > > + */ >=20 > [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? >=20 > > + rate_prob =3D 0; > > + cur_rate =3D (u64)tp->rate_delivered << 20; > > + max_rate =3D tp->plb_max_rate * tp->rate_interval_us; > > + if (max_rate > cur_rate) { > > + u64 deficit; > > + > > + deficit =3D mul_u64_u64_div_u64(max_rate - cur_rate, > > + 1 << 8, max_rate); > > + rate_prob =3D (4 * base_prob * deficit * deficit) >> 16; > > + rate_prob =3D 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 =3D 0; > > + } else { > > + tp->plb_stale_hops =3D 0; > > + } >=20 > [ ... ] >=20 > > + if (!tcp_plb_rehash(sk)) > > + return; > > + > > + if (tp->plb_stale_hops < 3) > > + tp->plb_stale_hops++; > > + if (tp->plb_stale_hops =3D=3D 3) > > + tp->plb_max_rate -=3D tp->plb_max_rate >> 3; > > +} >=20 > [Severity: Medium] > Does this match the commit message? >=20 > Therefore, tp->plb_stale_hops counts consecutive rehashes > without recovery within ~15% of the peak (deficit < 38). > Once three consecutive rehashes stay >=3D ~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. >=20 > 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: >=20 > E1: healthy -> stale =3D 0, floor rehash -> stale =3D 1 > E2: degraded -> rehash -> stale =3D 2 > E3: degraded -> rehash -> stale =3D 3 -> plb_max_rate decayed >=20 > 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? >=20 > Should the increment depend on the path just left being degraded? Ah, good catch. Leaving a healthy path via a floor rehash should not increment plb_stale_hops right after resetting it to 0. Decaying on the 3rd degraded rehash (after 2 un-decayed degraded hops) is the intended balance and matches the benchmarked behaviour when congestion starts, avoiding overly slow convergence on a shared bottleneck. In v2, I'll update plb_stale_hops / decay only when deficit >=3D 38: if (degraded) { if (tp->plb_stale_hops < 2) tp->plb_stale_hops++; else tp->plb_max_rate -=3D tp->plb_max_rate >> 3; } --- pw-bot: cr