mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Pengcheng Yang <yangpc@wangsu.com>
To: edumazet@google.com, davem@davemloft.net, ncardwell@google.com
Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org,
	Pengcheng Yang <yangpc@wangsu.com>
Subject: [PATCH RFC net-next] tcp: make cwnd-limited not affected by tcp internal pacing
Date: Thu, 19 Mar 2020 14:32:29 +0800	[thread overview]
Message-ID: <1584599549-6793-1-git-send-email-yangpc@wangsu.com> (raw)

The current cwnd-limited is set when cwnd is fully used
(inflight >= cwnd), which allows the congestion algorithm
to accurately determine whether cwnd needs to be added.

However, there may be a problem when using tcp internal pacing:
In congestion avoidance phase, when a burst of packets are
acked by a stretched ACK or a burst of ACKs, this makes a large
reduction in inflight in a short time. At this time, the sender
sends data according to the pacing rate cannot fill CWND and
cwnd-limited is not set. The worst case is that cwnd-limited
is set only after the last packet in a window is sent. This causes
the congestion algorithm to be too conservative to increase CWND.

The idea is that once cwnd-limited is set, it maintains a window period.
In this period, it is considered that the CWND is limited. This makes
the congestion algorithm unaffected by tcp internal pacing.

Signed-off-by: Pengcheng Yang <yangpc@wangsu.com>
---
 include/linux/tcp.h   |  2 +-
 net/ipv4/tcp_output.c | 14 ++++++++------
 2 files changed, 9 insertions(+), 7 deletions(-)

diff --git a/include/linux/tcp.h b/include/linux/tcp.h
index 3dc9640..3b3329f 100644
--- a/include/linux/tcp.h
+++ b/include/linux/tcp.h
@@ -286,7 +286,7 @@ struct tcp_sock {
 	u32	packets_out;	/* Packets which are "in flight"	*/
 	u32	retrans_out;	/* Retransmitted packets out		*/
 	u32	max_packets_out;  /* max packets_out in last window */
-	u32	max_packets_seq;  /* right edge of max_packets_out flight */
+	u32	cwnd_limited_seq; /* snd_nxt at cwnd limited */
 
 	u16	urg_data;	/* Saved octet of OOB data and control flags */
 	u8	ecn_flags;	/* ECN status bits.			*/
diff --git a/net/ipv4/tcp_output.c b/net/ipv4/tcp_output.c
index 306e25d..31dd6dc 100644
--- a/net/ipv4/tcp_output.c
+++ b/net/ipv4/tcp_output.c
@@ -1705,14 +1705,16 @@ static void tcp_cwnd_validate(struct sock *sk, bool is_cwnd_limited)
 	const struct tcp_congestion_ops *ca_ops = inet_csk(sk)->icsk_ca_ops;
 	struct tcp_sock *tp = tcp_sk(sk);
 
-	/* Track the maximum number of outstanding packets in each
-	 * window, and remember whether we were cwnd-limited then.
+	/* Remember whether we were cwnd-limited in last window,
+	 * and track the maximum number of outstanding packets in each window.
 	 */
-	if (!before(tp->snd_una, tp->max_packets_seq) ||
-	    tp->packets_out > tp->max_packets_out) {
-		tp->max_packets_out = tp->packets_out;
-		tp->max_packets_seq = tp->snd_nxt;
+	if (is_cwnd_limited ||
+	    !before(tp->snd_una, tp->cwnd_limited_seq)) {
 		tp->is_cwnd_limited = is_cwnd_limited;
+		tp->cwnd_limited_seq = tp->snd_nxt;
+		tp->max_packets_out = tp->packets_out;
+	} else if (tp->packets_out > tp->max_packets_out) {
+		tp->max_packets_out = tp->packets_out;
 	}
 
 	if (tcp_is_cwnd_limited(sk)) {
-- 
1.8.3.1


             reply	other threads:[~2020-03-19  6:38 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-03-19  6:32 Pengcheng Yang [this message]
2020-03-19 18:49 ` Neal Cardwell

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=1584599549-6793-1-git-send-email-yangpc@wangsu.com \
    --to=yangpc@wangsu.com \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=ncardwell@google.com \
    --cc=netdev@vger.kernel.org \
    /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

all inboxes | Powered by JetHome®