Netdev List
 help / color / mirror / Atom feed
From: Kuniyuki Iwashima <kuniyu@google.com>
To: Eric Dumazet <edumazet@kernel.org>,
	Neal Cardwell <ncardwell@google.com>,
	 "David S . Miller" <davem@davemloft.net>,
	Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
	 Willem de Bruijn <willemb@google.com>
Cc: Simon Horman <horms@kernel.org>,
	Yuchung Cheng <ycheng@google.com>,
	 Kuniyuki Iwashima <kuniyu@google.com>,
	Kuniyuki Iwashima <kuni1840@gmail.com>,
	netdev@vger.kernel.org
Subject: [PATCH v1 net-next 04/10] tcp: Call tcp_plb_update_state_upon_rto() after rehash in tcp_write_timeout().
Date: Fri,  4 Dec 2026 17:54:34 +0900	[thread overview]
Message-ID: <20261204085551.1518105-5-kuniyu@google.com> (raw)
In-Reply-To: <20261204085551.1518105-1-kuniyu@google.com>

dctcp_cwnd_event() calls tcp_plb_update_state_upon_rto() upon
CA_EVENT_LOSS in tcp_enter_loss() to reset plb_consec_cong_rounds
and pause PLB after an RTO triggers a path rehash.

However, tcp_enter_loss() does not always correspond to an RTO
rehash:

  1. tcp_enter_loss() is called from 3 paths but the first two
     do not rehash the flow:

     - tcp_fastopen_synack_timer()
     - tcp_retransmit_timer() when !tp->snd_wnd
     - tcp_retransmit_timer() when tcp_write_timeout() returns 0

  2. Even on the last path, tcp_enter_loss() skips CA_EVENT_LOSS
     if after(tp->high_seq, tp->snd_una) is true and the socket
     is in TCP_CA_CWR (e.g. after receiving ECN CE in DCTCP),
     TCP_CA_Recovery, or TCP_CA_Loss with icsk_retransmits > 0.

In the second case, even when tcp_write_timeout() rehashes the
flow, tcp_plb_update_state_upon_rto() is missed.

Then, a subsequent tcp_plb_check_rehash() in dctcp_update_alpha()
or dctcp_cwnd_event_tx_start() can immediately rehash the flow
again, potentially back to the previous bad path.

Let's move tcp_plb_update_state_upon_rto() just after
__sk_rethink_txhash_reset_dst() in tcp_write_timeout().

Signed-off-by: Kuniyuki Iwashima <kuniyu@google.com>
---
 net/ipv4/tcp_dctcp.c | 1 -
 net/ipv4/tcp_plb.c   | 1 -
 net/ipv4/tcp_timer.c | 1 +
 3 files changed, 1 insertion(+), 2 deletions(-)

diff --git a/net/ipv4/tcp_dctcp.c b/net/ipv4/tcp_dctcp.c
index bc3724d1da90..bbfff24ed5f0 100644
--- a/net/ipv4/tcp_dctcp.c
+++ b/net/ipv4/tcp_dctcp.c
@@ -198,7 +198,6 @@ __bpf_kfunc static void dctcp_cwnd_event(struct sock *sk, enum tcp_ca_event ev)
 		dctcp_ece_ack_update(sk, ev, &ca->prior_rcv_nxt, &ca->ce_state);
 		break;
 	case CA_EVENT_LOSS:
-		tcp_plb_update_state_upon_rto(sk);
 		dctcp_react_to_loss(sk);
 		break;
 	default:
diff --git a/net/ipv4/tcp_plb.c b/net/ipv4/tcp_plb.c
index 26ca53d6fb9d..c21fcb7945c0 100644
--- a/net/ipv4/tcp_plb.c
+++ b/net/ipv4/tcp_plb.c
@@ -113,4 +113,3 @@ void tcp_plb_update_state_upon_rto(struct sock *sk)
 	 */
 	tp->plb_consec_cong_rounds = 0;
 }
-EXPORT_SYMBOL_GPL(tcp_plb_update_state_upon_rto);
diff --git a/net/ipv4/tcp_timer.c b/net/ipv4/tcp_timer.c
index 814fadb30749..a3210cda2515 100644
--- a/net/ipv4/tcp_timer.c
+++ b/net/ipv4/tcp_timer.c
@@ -297,6 +297,7 @@ static int tcp_write_timeout(struct sock *sk)
 	}
 
 	if (__sk_rethink_txhash_reset_dst(sk)) {
+		tcp_plb_update_state_upon_rto(sk);
 		WRITE_ONCE(tp->timeout_rehash, tp->timeout_rehash + 1);
 		__NET_INC_STATS(sock_net(sk), LINUX_MIB_TCPTIMEOUTREHASH);
 	}
-- 
2.56.1.915.g69d5ec7298-goog


  parent reply	other threads:[~2026-12-04  8:56 UTC|newest]

Thread overview: 12+ 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  8:54 ` Kuniyuki Iwashima [this message]
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-04  8:54 ` [PATCH v1 net-next 09/10] selftest: packetdrill: Add tests for " Kuniyuki Iwashima
2026-12-04  8:54 ` [PATCH v1 net-next 10/10] selftest: net: Disable Generic PLB in ecmp_rehash.sh Kuniyuki Iwashima
2026-12-04  9:03 ` [PATCH v1 net-next 00/10] tcp: Introduce Generic PLB netdev-bot+sinfo

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=20261204085551.1518105-5-kuniyu@google.com \
    --to=kuniyu@google.com \
    --cc=davem@davemloft.net \
    --cc=edumazet@kernel.org \
    --cc=horms@kernel.org \
    --cc=kuba@kernel.org \
    --cc=kuni1840@gmail.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