netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Mubashir Adnan Qureshi <mubashirmaq@gmail.com>
To: David Miller <davem@davemloft.net>
Cc: netdev@vger.kernel.org, kuba@kernel.org,
	Mubashir Adnan Qureshi <mubashirq@google.com>,
	Yuchung Cheng <ycheng@google.com>,
	Neal Cardwell <ncardwell@google.com>,
	Eric Dumazet <edumazet@google.com>
Subject: [PATCH net-next v2 3/5] tcp: add support for PLB in DCTCP
Date: Fri, 30 Sep 2022 04:53:18 +0000	[thread overview]
Message-ID: <20220930045320.5252-4-mubashirmaq@gmail.com> (raw)
In-Reply-To: <20220930045320.5252-1-mubashirmaq@gmail.com>

From: Mubashir Adnan Qureshi <mubashirq@google.com>

PLB support is added to TCP DCTCP code. As DCTCP uses ECN as the
congestion signal, PLB also uses ECN to make decisions whether to change
the path or not upon sustained congestion.

Signed-off-by: Mubashir Adnan Qureshi <mubashirq@google.com>
Signed-off-by: Yuchung Cheng <ycheng@google.com>
Signed-off-by: Neal Cardwell <ncardwell@google.com>
Reviewed-by: Eric Dumazet <edumazet@google.com>
---
 net/ipv4/tcp_dctcp.c | 23 ++++++++++++++++++++++-
 1 file changed, 22 insertions(+), 1 deletion(-)

diff --git a/net/ipv4/tcp_dctcp.c b/net/ipv4/tcp_dctcp.c
index 2a6c0dd665a4..e0a2ca7456ff 100644
--- a/net/ipv4/tcp_dctcp.c
+++ b/net/ipv4/tcp_dctcp.c
@@ -54,6 +54,7 @@ struct dctcp {
 	u32 next_seq;
 	u32 ce_state;
 	u32 loss_cwnd;
+	struct tcp_plb_state plb;
 };
 
 static unsigned int dctcp_shift_g __read_mostly = 4; /* g = 1/2^4 */
@@ -91,6 +92,8 @@ static void dctcp_init(struct sock *sk)
 		ca->ce_state = 0;
 
 		dctcp_reset(tp, ca);
+		tcp_plb_init(sk, &ca->plb);
+
 		return;
 	}
 
@@ -117,14 +120,28 @@ static void dctcp_update_alpha(struct sock *sk, u32 flags)
 
 	/* Expired RTT */
 	if (!before(tp->snd_una, ca->next_seq)) {
+		u32 delivered = tp->delivered - ca->old_delivered;
 		u32 delivered_ce = tp->delivered_ce - ca->old_delivered_ce;
 		u32 alpha = ca->dctcp_alpha;
+		u32 ce_ratio = 0;
+
+		if (delivered > 0) {
+			/* dctcp_alpha keeps EWMA of fraction of ECN marked
+			 * packets. Because of EWMA smoothing, PLB reaction can
+			 * be slow so we use ce_ratio which is an instantaneous
+			 * measure of congestion. ce_ratio is the fraction of
+			 * ECN marked packets in the previous RTT.
+			 */
+			if (delivered_ce > 0)
+				ce_ratio = (delivered_ce << TCP_PLB_SCALE) / delivered;
+			tcp_plb_update_state(sk, &ca->plb, (int)ce_ratio);
+			tcp_plb_check_rehash(sk, &ca->plb);
+		}
 
 		/* alpha = (1 - g) * alpha + g * F */
 
 		alpha -= min_not_zero(alpha, alpha >> dctcp_shift_g);
 		if (delivered_ce) {
-			u32 delivered = tp->delivered - ca->old_delivered;
 
 			/* If dctcp_shift_g == 1, a 32bit value would overflow
 			 * after 8 M packets.
@@ -172,8 +189,12 @@ 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, &ca->plb);
 		dctcp_react_to_loss(sk);
 		break;
+	case CA_EVENT_TX_START:
+		tcp_plb_check_rehash(sk, &ca->plb); /* Maybe rehash when inflight is 0 */
+		break;
 	default:
 		/* Don't care for the rest. */
 		break;
-- 
2.38.0.rc1.362.ged0d419d3c-goog


  parent reply	other threads:[~2022-09-30  4:55 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-09-29 14:24 [PATCH net-next 0/5] Add PLB functionality to TCP Mubashir Adnan Qureshi
2022-09-29 14:24 ` [PATCH net-next 1/5] tcp: add sysctls for TCP PLB parameters Mubashir Adnan Qureshi
2022-09-30  2:37   ` Jakub Kicinski
2022-09-29 14:24 ` [PATCH net-next 2/5] tcp: add PLB functionality for TCP Mubashir Adnan Qureshi
2022-09-29 14:24 ` [PATCH net-next 3/5] tcp: add support for PLB in DCTCP Mubashir Adnan Qureshi
2022-09-29 14:24 ` [PATCH net-next 4/5] tcp: add u32 counter in tcp_sock and an SNMP counter for PLB Mubashir Adnan Qureshi
2022-09-29 14:24 ` [PATCH net-next 5/5] tcp: add rcv_wnd and plb_rehash to TCP_INFO Mubashir Adnan Qureshi
2022-09-30  4:53 ` [PATCH net-next v2 0/5] Add PLB functionality to TCP Mubashir Adnan Qureshi
2022-09-30  4:53   ` [PATCH net-next v2 1/5] tcp: add sysctls for TCP PLB parameters Mubashir Adnan Qureshi
2022-09-30  4:53   ` [PATCH net-next v2 2/5] tcp: add PLB functionality for TCP Mubashir Adnan Qureshi
2022-09-30  4:53   ` Mubashir Adnan Qureshi [this message]
2022-09-30  4:53   ` [PATCH net-next v2 4/5] tcp: add u32 counter in tcp_sock and an SNMP counter for PLB Mubashir Adnan Qureshi
2022-09-30  4:53   ` [PATCH net-next v2 5/5] tcp: add rcv_wnd and plb_rehash to TCP_INFO Mubashir Adnan Qureshi
2022-10-03 23:42   ` [PATCH net-next v2 0/5] Add PLB functionality to TCP Jakub Kicinski

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=20220930045320.5252-4-mubashirmaq@gmail.com \
    --to=mubashirmaq@gmail.com \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=kuba@kernel.org \
    --cc=mubashirq@google.com \
    --cc=ncardwell@google.com \
    --cc=netdev@vger.kernel.org \
    --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;
as well as URLs for NNTP newsgroup(s).