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
Subject: Re: [PATCH v1 net-next 08/10] tcp: Introduce Generic PLB.
Date: Sat, 05 Dec 2026 09:17:54 +0000 [thread overview]
Message-ID: <179646227492.3146.3358157554448761176@kernel.org> (raw)
In-Reply-To: <20261204085551.1518105-9-kuniyu@google.com>
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
next prev parent reply other threads:[~2026-12-05 9:17 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-12-04 8:54 [PATCH v1 net-next 00/10] tcp: Introduce Generic PLB Kuniyuki Iwashima
2026-12-04 8:54 ` [PATCH v1 net-next 01/10] tcp: Return early when tcp_plb_check_rehash() does not rehash a flow Kuniyuki Iwashima
2026-12-04 8:54 ` [PATCH v1 net-next 02/10] tcp: Don't call get_random_u32_below(0) in tcp_plb_update_state_upon_rto() Kuniyuki Iwashima
2026-12-04 8:54 ` [PATCH v1 net-next 03/10] tcp: Move struct tcp_plb_state to struct tcp_sock Kuniyuki Iwashima
2026-12-04 10:34 ` David Laight
2026-12-04 12:33 ` Kuniyuki Iwashima
2026-12-05 9:17 ` netdev-bot+sashiko
2026-12-04 8:54 ` [PATCH v1 net-next 04/10] tcp: Call tcp_plb_update_state_upon_rto() after rehash in tcp_write_timeout() Kuniyuki Iwashima
2026-12-05 9:17 ` netdev-bot+sashiko
2026-12-04 8:54 ` [PATCH v1 net-next 05/10] tcp: Rename tcp_plb_check_rehash() to tcp_plb_check_rehash_ecn() Kuniyuki Iwashima
2026-12-04 8:54 ` [PATCH v1 net-next 06/10] tcp: Factorise tcp_plb_rehash() Kuniyuki Iwashima
2026-12-04 8:54 ` [PATCH v1 net-next 07/10] tcp: Lower tcp_plb_suspend_rto_sec default Kuniyuki Iwashima
2026-12-04 8:54 ` [PATCH v1 net-next 08/10] tcp: Introduce Generic PLB Kuniyuki Iwashima
2026-12-05 9:17 ` netdev-bot+sashiko [this message]
2026-12-04 8:54 ` [PATCH v1 net-next 09/10] selftest: packetdrill: Add tests for " Kuniyuki Iwashima
2026-12-05 9:17 ` netdev-bot+sashiko
2026-12-04 8:54 ` [PATCH v1 net-next 10/10] selftest: net: Disable Generic PLB in ecmp_rehash.sh Kuniyuki Iwashima
2026-12-05 9:17 ` netdev-bot+sashiko
2026-12-04 9:03 ` [PATCH v1 net-next 00/10] tcp: Introduce Generic PLB netdev-bot+sinfo
2026-12-04 9:29 ` Kuniyuki Iwashima
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=179646227492.3146.3358157554448761176@kernel.org \
--to=netdev-bot+sashiko@kernel.org \
--cc=davem@davemloft.net \
--cc=edumazet@kernel.org \
--cc=horms@kernel.org \
--cc=kuba@kernel.org \
--cc=kuni1840@gmail.com \
--cc=kuniyu@google.com \
--cc=ncardwell@google.com \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=willemb@google.com \
--cc=ycheng@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