Skip to contentSkip to conversation

tcp: add NV congestion control

RFC PATCH Superseded Lawrence Brakmo 2 participants 8 messages Aug 5, 2015 – Aug 26, 2015

Subsystems (4)

v5 of 6 Superseded Latest is v6 →

lore
Share & tools
lore
#0 lore raw

v5 cover tcp: add NV congestion control

This patchset adds support for NV congestion control.

Changes from v4: passing structure as constant in pkts_acked()

Consists of the following patches:

[RFC PATCH v5 net-next 1/4] tcp: replace cnt & rtt with struct in [RFC PATCH v5 net-next 2/4] tcp: refactor struct tcp_skb_cb [RFC PATCH v5 net-next 3/4] tcp: add in_flight to tcp_skb_cb [RFC PATCH v5 net-next 4/4] tcp: add NV congestion control

include/net/tcp.h       |  20 ++-
net/ipv4/Kconfig        |  16 ++
net/ipv4/Makefile       |   1 +
net/ipv4/tcp_bic.c      |   6 +-
net/ipv4/tcp_cdg.c      |  14 +-
net/ipv4/tcp_cubic.c    |   6 +-
net/ipv4/tcp_htcp.c     |  10 +-
net/ipv4/tcp_illinois.c |  20 +--
net/ipv4/tcp_input.c    |  10 +-
net/ipv4/tcp_lp.c       |   6 +-
net/ipv4/tcp_nv.c       | 479 ++++++++++++++++++++++++++++++++++++++++++++++++++++
net/ipv4/tcp_output.c   |   4 +-
net/ipv4/tcp_vegas.c    |   6 +-
net/ipv4/tcp_vegas.h    |   2 +-
net/ipv4/tcp_veno.c     |   7 +-
net/ipv4/tcp_westwood.c |   7 +-
net/ipv4/tcp_yeah.c     |   7 +-
17 files changed, 570 insertions(+), 51 deletions(-)
#1 lore raw

RFC PATCH v5 1/4 tcp: replace cnt & rtt with struct in pkts_acked()

Replace 2 arguments (cnt and rtt) in the congestion control modules' pkts_acked() function with a struct. This will allow adding more information without having to modify existing congestion control modules (tcp_nv in particular needs bytes in flight when packet was sent).

As proposed by Neal Cardwell in his comments to the tcp_nv patch.

---
 include/net/tcp.h       |  7 ++++++-
 net/ipv4/tcp_bic.c      |  6 +++---
 net/ipv4/tcp_cdg.c      | 14 +++++++-------
 net/ipv4/tcp_cubic.c    |  6 +++---
 net/ipv4/tcp_htcp.c     | 10 +++++-----
 net/ipv4/tcp_illinois.c | 20 ++++++++++----------
 net/ipv4/tcp_input.c    |  7 +++++--
 net/ipv4/tcp_lp.c       |  6 +++---
 net/ipv4/tcp_vegas.c    |  6 +++---
 net/ipv4/tcp_vegas.h    |  2 +-
 net/ipv4/tcp_veno.c     |  7 ++++---
 net/ipv4/tcp_westwood.c |  7 ++++---
 net/ipv4/tcp_yeah.c     |  7 ++++---
 13 files changed, 58 insertions(+), 47 deletions(-)
include/net/tcp.h +6 -1
index 364426a..0121529 100644
@@ -834,6 +834,11 @@ enum tcp_ca_ack_event_flags {
 
 union tcp_cc_info;
 
+struct ack_sample {
+	u32 pkts_acked;
+	s32 rtt_us;
+};
+
 struct tcp_congestion_ops {
 	struct list_head	list;
 	u32 key;
@@ -857,7 +862,7 @@ struct tcp_congestion_ops {
 	/* new value of cwnd after loss (optional) */
 	u32  (*undo_cwnd)(struct sock *sk);
 	/* hook for packet ack accounting (optional) */
-	void (*pkts_acked)(struct sock *sk, u32 num_acked, s32 rtt_us);
+	void (*pkts_acked)(struct sock *sk, const struct ack_sample *sample);
 	/* get info for inet_diag (optional) */
 	size_t (*get_info)(struct sock *sk, u32 ext, int *attr,
 			   union tcp_cc_info *info);
net/ipv4/tcp_bic.c +3 -3
index fd1405d..f469f1b 100644
@@ -197,15 +197,15 @@ static void bictcp_state(struct sock *sk, u8 new_state)
 /* Track delayed acknowledgment ratio using sliding window
  * ratio = (15*ratio + sample) / 16
  */
-static void bictcp_acked(struct sock *sk, u32 cnt, s32 rtt)
+static void bictcp_acked(struct sock *sk, const struct ack_sample *sample)
 {
 	const struct inet_connection_sock *icsk = inet_csk(sk);
 
 	if (icsk->icsk_ca_state == TCP_CA_Open) {
 		struct bictcp *ca = inet_csk_ca(sk);
 
-		cnt -= ca->delayed_ack >> ACK_RATIO_SHIFT;
-		ca->delayed_ack += cnt;
+		ca->delayed_ack += sample->pkts_acked - 
+			(ca->delayed_ack >> ACK_RATIO_SHIFT);
 	}
 }
 
net/ipv4/tcp_cdg.c +7 -7
index 167b6a3..b4e5af7 100644
@@ -294,12 +294,12 @@ static void tcp_cdg_cong_avoid(struct sock *sk, u32 ack, u32 acked)
 	ca->shadow_wnd = max(ca->shadow_wnd, ca->shadow_wnd + incr);
 }
 
-static void tcp_cdg_acked(struct sock *sk, u32 num_acked, s32 rtt_us)
+static void tcp_cdg_acked(struct sock *sk, const struct ack_sample *sample)
 {
 	struct cdg *ca = inet_csk_ca(sk);
 	struct tcp_sock *tp = tcp_sk(sk);
 
-	if (rtt_us <= 0)
+	if (sample->rtt_us <= 0)
 		return;
 
 	/* A heuristic for filtering delayed ACKs, adapted from:
@@ -307,20 +307,20 @@ static void tcp_cdg_acked(struct sock *sk, u32 num_acked, s32 rtt_us)
 	 * delay and rate based TCP mechanisms." TR 100219A. CAIA, 2010.
 	 */
 	if (tp->sacked_out == 0) {
-		if (num_acked == 1 && ca->delack) {
+		if (sample->pkts_acked == 1 && ca->delack) {
 			/* A delayed ACK is only used for the minimum if it is
 			 * provenly lower than an existing non-zero minimum.
 			 */
-			ca->rtt.min = min(ca->rtt.min, rtt_us);
+			ca->rtt.min = min(ca->rtt.min, sample->rtt_us);
 			ca->delack--;
 			return;
-		} else if (num_acked > 1 && ca->delack < 5) {
+		} else if (sample->pkts_acked > 1 && ca->delack < 5) {
 			ca->delack++;
 		}
 	}
 
-	ca->rtt.min = min_not_zero(ca->rtt.min, rtt_us);
-	ca->rtt.max = max(ca->rtt.max, rtt_us);
+	ca->rtt.min = min_not_zero(ca->rtt.min, sample->rtt_us);
+	ca->rtt.max = max(ca->rtt.max, sample->rtt_us);
 }
 
 static u32 tcp_cdg_ssthresh(struct sock *sk)
net/ipv4/tcp_cubic.c +3 -3
index 28011fb..c5d0ba5 100644
@@ -416,21 +416,21 @@ static void hystart_update(struct sock *sk, u32 delay)
 /* Track delayed acknowledgment ratio using sliding window
  * ratio = (15*ratio + sample) / 16
  */
-static void bictcp_acked(struct sock *sk, u32 cnt, s32 rtt_us)
+static void bictcp_acked(struct sock *sk, const struct ack_sample *sample)
 {
 	const struct tcp_sock *tp = tcp_sk(sk);
 	struct bictcp *ca = inet_csk_ca(sk);
 	u32 delay;
 
 	/* Some calls are for duplicates without timetamps */
-	if (rtt_us < 0)
+	if (sample->rtt_us < 0)
 		return;
 
 	/* Discard delay samples right after fast recovery */
 	if (ca->epoch_start && (s32)(tcp_time_stamp - ca->epoch_start) < HZ)
 		return;
 
-	delay = (rtt_us << 3) / USEC_PER_MSEC;
+	delay = (sample->rtt_us << 3) / USEC_PER_MSEC;
 	if (delay == 0)
 		delay = 1;
 
net/ipv4/tcp_htcp.c +5 -5
index 82f0d9e..4a4d8e7 100644
@@ -99,7 +99,7 @@ static inline void measure_rtt(struct sock *sk, u32 srtt)
 }
 
 static void measure_achieved_throughput(struct sock *sk,
-					u32 pkts_acked, s32 rtt)
+					const struct ack_sample *sample)
 {
 	const struct inet_connection_sock *icsk = inet_csk(sk);
 	const struct tcp_sock *tp = tcp_sk(sk);
@@ -107,10 +107,10 @@ static void measure_achieved_throughput(struct sock *sk,
 	u32 now = tcp_time_stamp;
 
 	if (icsk->icsk_ca_state == TCP_CA_Open)
-		ca->pkts_acked = pkts_acked;
+		ca->pkts_acked = sample->pkts_acked;
 
-	if (rtt > 0)
-		measure_rtt(sk, usecs_to_jiffies(rtt));
+	if (sample->rtt_us > 0)
+		measure_rtt(sk, usecs_to_jiffies(sample->rtt_us));
 
 	if (!use_bandwidth_switch)
 		return;
@@ -122,7 +122,7 @@ static void measure_achieved_throughput(struct sock *sk,
 		return;
 	}
 
-	ca->packetcount += pkts_acked;
+	ca->packetcount += sample->pkts_acked;
 
 	if (ca->packetcount >= tp->snd_cwnd - (ca->alpha >> 7 ? : 1) &&
 	    now - ca->lasttime >= ca->minRTT &&
net/ipv4/tcp_illinois.c +10 -10
index 2ab9bbb..77ad119 100644
@@ -82,30 +82,30 @@ static void tcp_illinois_init(struct sock *sk)
 }
 
 /* Measure RTT for each ack. */
-static void tcp_illinois_acked(struct sock *sk, u32 pkts_acked, s32 rtt)
+static void tcp_illinois_acked(struct sock *sk, const struct ack_sample *sample)
 {
 	struct illinois *ca = inet_csk_ca(sk);
 
-	ca->acked = pkts_acked;
+	ca->acked = sample->pkts_acked;
 
 	/* dup ack, no rtt sample */
-	if (rtt < 0)
+	if (sample->rtt_us < 0)
 		return;
 
 	/* ignore bogus values, this prevents wraparound in alpha math */
-	if (rtt > RTT_MAX)
-		rtt = RTT_MAX;
+	if (sample->rtt_us > RTT_MAX)
+		sample->rtt_us = RTT_MAX;
 
 	/* keep track of minimum RTT seen so far */
-	if (ca->base_rtt > rtt)
-		ca->base_rtt = rtt;
+	if (ca->base_rtt > sample->rtt_us)
+		ca->base_rtt = sample->rtt_us;
 
 	/* and max */
-	if (ca->max_rtt < rtt)
-		ca->max_rtt = rtt;
+	if (ca->max_rtt < sample->rtt_us)
+		ca->max_rtt = sample->rtt_us;
 
 	++ca->cnt_rtt;
-	ca->sum_rtt += rtt;
+	ca->sum_rtt += sample->rtt_us;
 }
 
 /* Maximum queuing delay */
net/ipv4/tcp_input.c +5 -2
index 4e4d6bc..f506a0a 100644
@@ -3196,8 +3196,11 @@ static int tcp_clean_rtx_queue(struct sock *sk, int prior_fackets,
 		tcp_rearm_rto(sk);
 	}
 
-	if (icsk->icsk_ca_ops->pkts_acked)
-		icsk->icsk_ca_ops->pkts_acked(sk, pkts_acked, ca_rtt_us);
+	if (icsk->icsk_ca_ops->pkts_acked) {
+		struct ack_sample sample = {pkts_acked, ca_rtt_us};
+
+		icsk->icsk_ca_ops->pkts_acked(sk, &sample);
+	}
 
 #if FASTRETRANS_DEBUG > 0
 	WARN_ON((int)tp->sacked_out < 0);
net/ipv4/tcp_lp.c +3 -3
index 1e70fa8..c67ece1 100644
@@ -260,13 +260,13 @@ static void tcp_lp_rtt_sample(struct sock *sk, u32 rtt)
  * newReno in increase case.
  * We work it out by following the idea from TCP-LP's paper directly
  */
-static void tcp_lp_pkts_acked(struct sock *sk, u32 num_acked, s32 rtt_us)
+static void tcp_lp_pkts_acked(struct sock *sk, const struct ack_sample *sample)
 {
 	struct tcp_sock *tp = tcp_sk(sk);
 	struct lp *lp = inet_csk_ca(sk);
 
-	if (rtt_us > 0)
-		tcp_lp_rtt_sample(sk, rtt_us);
+	if (sample->rtt_us > 0)
+		tcp_lp_rtt_sample(sk, sample->rtt_us);
 
 	/* calc inference */
 	if (tcp_time_stamp > tp->rx_opt.rcv_tsecr)
net/ipv4/tcp_vegas.c +3 -3
index 13951c4..4c4bac1 100644
@@ -107,16 +107,16 @@ EXPORT_SYMBOL_GPL(tcp_vegas_init);
  *   o min-filter RTT samples from a much longer window (forever for now)
  *     to find the propagation delay (baseRTT)
  */
-void tcp_vegas_pkts_acked(struct sock *sk, u32 cnt, s32 rtt_us)
+void tcp_vegas_pkts_acked(struct sock *sk, const struct ack_sample *sample)
 {
 	struct vegas *vegas = inet_csk_ca(sk);
 	u32 vrtt;
 
-	if (rtt_us < 0)
+	if (sample->rtt_us < 0)
 		return;
 
 	/* Never allow zero rtt or baseRTT */
-	vrtt = rtt_us + 1;
+	vrtt = sample->rtt_us + 1;
 
 	/* Filter to find propagation delay: */
 	if (vrtt < vegas->baseRTT)
net/ipv4/tcp_vegas.h +1 -1
index ef9da53..248cfc0 100644
@@ -17,7 +17,7 @@ struct vegas {
 
 void tcp_vegas_init(struct sock *sk);
 void tcp_vegas_state(struct sock *sk, u8 ca_state);
-void tcp_vegas_pkts_acked(struct sock *sk, u32 cnt, s32 rtt_us);
+void tcp_vegas_pkts_acked(struct sock *sk, const struct ack_sample *sample);
 void tcp_vegas_cwnd_event(struct sock *sk, enum tcp_ca_event event);
 size_t tcp_vegas_get_info(struct sock *sk, u32 ext, int *attr,
 			  union tcp_cc_info *info);
net/ipv4/tcp_veno.c +4 -3
index 0d094b9..40171e1 100644
@@ -69,16 +69,17 @@ static void tcp_veno_init(struct sock *sk)
 }
 
 /* Do rtt sampling needed for Veno. */
-static void tcp_veno_pkts_acked(struct sock *sk, u32 cnt, s32 rtt_us)
+static void tcp_veno_pkts_acked(struct sock *sk,
+				const struct ack_sample *sample)
 {
 	struct veno *veno = inet_csk_ca(sk);
 	u32 vrtt;
 
-	if (rtt_us < 0)
+	if (sample->rtt_us < 0)
 		return;
 
 	/* Never allow zero rtt or baseRTT */
-	vrtt = rtt_us + 1;
+	vrtt = sample->rtt_us + 1;
 
 	/* Filter to find propagation delay: */
 	if (vrtt < veno->basertt)
net/ipv4/tcp_westwood.c +4 -3
index c10732e..4b03a2e 100644
@@ -99,12 +99,13 @@ static void westwood_filter(struct westwood *w, u32 delta)
  * Called after processing group of packets.
  * but all westwood needs is the last sample of srtt.
  */
-static void tcp_westwood_pkts_acked(struct sock *sk, u32 cnt, s32 rtt)
+static void tcp_westwood_pkts_acked(struct sock *sk,
+				    const struct ack_sample *sample)
 {
 	struct westwood *w = inet_csk_ca(sk);
 
-	if (rtt > 0)
-		w->rtt = usecs_to_jiffies(rtt);
+	if (sample->rtt_us > 0)
+		w->rtt = usecs_to_jiffies(sample->rtt_us);
 }
 
 /*
net/ipv4/tcp_yeah.c +4 -3
index 17d3566..1b9d013 100644
@@ -56,15 +56,16 @@ static void tcp_yeah_init(struct sock *sk)
 	tp->snd_cwnd_clamp = min_t(u32, tp->snd_cwnd_clamp, 0xffffffff/128);
 }
 
-static void tcp_yeah_pkts_acked(struct sock *sk, u32 pkts_acked, s32 rtt_us)
+static void tcp_yeah_pkts_acked(struct sock *sk,
+				const struct ack_sample *sample)
 {
 	const struct inet_connection_sock *icsk = inet_csk(sk);
 	struct yeah *yeah = inet_csk_ca(sk);
 
 	if (icsk->icsk_ca_state == TCP_CA_Open)
-		yeah->pkts_acked = pkts_acked;
+		yeah->pkts_acked = sample->pkts_acked;
 
-	tcp_vegas_pkts_acked(sk, pkts_acked, rtt_us);
+	tcp_vegas_pkts_acked(sk, sample);
 }
 
 static void tcp_yeah_cong_avoid(struct sock *sk, u32 ack, u32 acked)
Signature · 1 line
1.8.5.6
#2 lore raw

RFC PATCH v5 2/4 tcp: refactor struct tcp_skb_cb

In reply to Lawrence Brakmo

Refactor tcp_skb_cb to create two overlaping areas to store state for incoming or outgoing skbs based on comments by Neal Cardwell to tcp_nv patch:

AFAICT this patch would not require an increase in the size of sk_buff cb[] if it were to take advantage of the fact that the tcp_skb_cb header.h4 and header.h6 fields are only used in the packet reception code path, and this in_flight field is only used on the transmit side.

---
 include/net/tcp.h | 11 ++++++++---
 1 file changed, 8 insertions(+), 3 deletions(-)
include/net/tcp.h +8 -3
index 0121529..a086a98 100644
@@ -755,11 +755,16 @@ struct tcp_skb_cb {
 	/* 1 byte hole */
 	__u32		ack_seq;	/* Sequence number ACK'd	*/
 	union {
-		struct inet_skb_parm	h4;
+		struct {
+			/* There is space for up to 20 bytes */
+		} tx;   /* only used for outgoing skbs */
+		union {
+			struct inet_skb_parm	h4;
 #if IS_ENABLED(CONFIG_IPV6)
-		struct inet6_skb_parm	h6;
+			struct inet6_skb_parm	h6;
 #endif
-	} header;	/* For incoming frames		*/
+		} header;	/* For incoming skbs */
+	};
 };
 
 #define TCP_SKB_CB(__skb)	((struct tcp_skb_cb *)&((__skb)->cb[0]))
Signature · 1 line
1.8.5.6
#3 lore raw

RFC PATCH v5 3/4 tcp: add in_flight to tcp_skb_cb

In reply to Lawrence Brakmo

Add in_flight (bytes in flight when packet was sent) field to tx component of tcp_skb_cb and make it available to congestion modules' pkts_acked() function through the ack_sample function argument.

---
 include/net/tcp.h     | 2 ++
 net/ipv4/tcp_input.c  | 5 ++++-
 net/ipv4/tcp_output.c | 4 +++-
 3 files changed, 9 insertions(+), 2 deletions(-)
include/net/tcp.h +2 -0
index a086a98..cdd93e5 100644
@@ -757,6 +757,7 @@ struct tcp_skb_cb {
 	union {
 		struct {
 			/* There is space for up to 20 bytes */
+			__u32 in_flight;/* Bytes in flight when packet sent */
 		} tx;   /* only used for outgoing skbs */
 		union {
 			struct inet_skb_parm	h4;
@@ -842,6 +843,7 @@ union tcp_cc_info;
 struct ack_sample {
 	u32 pkts_acked;
 	s32 rtt_us;
+	u32 in_flight;
 };
 
 struct tcp_congestion_ops {
net/ipv4/tcp_input.c +4 -1
index f506a0a..338e6bb 100644
@@ -3069,6 +3069,7 @@ static int tcp_clean_rtx_queue(struct sock *sk, int prior_fackets,
 	long ca_rtt_us = -1L;
 	struct sk_buff *skb;
 	u32 pkts_acked = 0;
+	u32 last_in_flight = 0;
 	bool rtt_update;
 	int flag = 0;
 
@@ -3108,6 +3109,7 @@ static int tcp_clean_rtx_queue(struct sock *sk, int prior_fackets,
 			if (!first_ackt.v64)
 				first_ackt = last_ackt;
 
+			last_in_flight = TCP_SKB_CB(skb)->tx.in_flight;
 			reord = min(pkts_acked, reord);
 			if (!after(scb->end_seq, tp->high_seq))
 				flag |= FLAG_ORIG_SACK_ACKED;
@@ -3197,7 +3199,8 @@ static int tcp_clean_rtx_queue(struct sock *sk, int prior_fackets,
 	}
 
 	if (icsk->icsk_ca_ops->pkts_acked) {
-		struct ack_sample sample = {pkts_acked, ca_rtt_us};
+		struct ack_sample sample = {pkts_acked, ca_rtt_us,
+					    last_in_flight};
 
 		icsk->icsk_ca_ops->pkts_acked(sk, &sample);
 	}
net/ipv4/tcp_output.c +3 -1
index 7d1efa7..0fccd5f 100644
@@ -920,9 +920,12 @@ static int tcp_transmit_skb(struct sock *sk, struct sk_buff *skb, int clone_it,
 	int err;
 
 	BUG_ON(!skb || !tcp_skb_pcount(skb));
+	tp = tcp_sk(sk);
 
 	if (clone_it) {
 		skb_mstamp_get(&skb->skb_mstamp);
+		TCP_SKB_CB(skb)->tx.in_flight = TCP_SKB_CB(skb)->end_seq
+			- tp->snd_una;
 
 		if (unlikely(skb_cloned(skb)))
 			skb = pskb_copy(skb, gfp_mask);
@@ -933,7 +936,6 @@ static int tcp_transmit_skb(struct sock *sk, struct sk_buff *skb, int clone_it,
 	}
 
 	inet = inet_sk(sk);
-	tp = tcp_sk(sk);
 	tcb = TCP_SKB_CB(skb);
 	memset(&opts, 0, sizeof(opts));
 
Signature · 1 line
1.8.5.6
#4 lore raw

RFC PATCH v5 4/4 tcp: add NV congestion control

In reply to Lawrence Brakmo

This is a request for comments.

TCP-NV (New Vegas) is a major update to TCP-Vegas. An earlier version of NV was presented at 2010's LPC. It is a delayed based congestion avoidance for the data center. This version has been tested within a 10G rack where the HW RTTs are 20-50us.

A description of TCP-NV, including implementation details as well as experimental results, can be found at:
http://www.brakmo.org/networking/tcp-nv/TCPNV.html

The current version includes many module parameters to support experimentation with the parameters.

---
 net/ipv4/Kconfig  |  16 ++
 net/ipv4/Makefile |   1 +
 net/ipv4/tcp_nv.c | 479 ++++++++++++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 496 insertions(+)
 create mode 100644 net/ipv4/tcp_nv.c
net/ipv4/Kconfig +16 -0
index 6fb3c90..f11f2f8 100644
@@ -539,6 +539,22 @@ config TCP_CONG_VEGAS
 	window. TCP Vegas should provide less packet loss, but it is
 	not as aggressive as TCP Reno.
 
+config TCP_CONG_NV
+       tristate "TCP NV"
+       default n
+       ---help---
+       TCP NV is a follow up to TCP Vegas. It has been modified to deal with
+       10G networks, measurement noise introduced by LRO, GRO and interrupt
+       coalescence. In addition, it will decrease its cwnd multiplicatively
+       instead of linearly.
+
+       Note that in general congestion avoidance (cwnd decreased when # packets
+       queued grows) cannot coexist with congestion control (cwnd decreased only
+       when there is packet loss) due to fairness issues. One scenario when they
+       can coexist safely is when the CA flows have RTTs << CC flows RTTs.
+
+       For further details see http://www.brakmo.org/networking/tcp-nv/
+
 config TCP_CONG_SCALABLE
 	tristate "Scalable TCP"
 	default n
net/ipv4/Makefile +1 -0
index efc43f3..06f335f 100644
@@ -50,6 +50,7 @@ obj-$(CONFIG_TCP_CONG_HSTCP) += tcp_highspeed.o
 obj-$(CONFIG_TCP_CONG_HYBLA) += tcp_hybla.o
 obj-$(CONFIG_TCP_CONG_HTCP) += tcp_htcp.o
 obj-$(CONFIG_TCP_CONG_VEGAS) += tcp_vegas.o
+obj-$(CONFIG_TCP_CONG_NV) += tcp_nv.o
 obj-$(CONFIG_TCP_CONG_VENO) += tcp_veno.o
 obj-$(CONFIG_TCP_CONG_SCALABLE) += tcp_scalable.o
 obj-$(CONFIG_TCP_CONG_LP) += tcp_lp.o
net/ipv4/tcp_nv.c new file +479 -0

479 lines not on this page · raw message

Signature · 1 line
1.8.5.6
#5 lore raw
Quoted 1 line · Lawrence Brakmo

This is a request for comments.

Nice to see more development on delay-based congestion control.

It would be good to see how NV stacks up against CDG. Any chance of adding cdg as a congestion control parameter to your experiments? Experiments on NV without its temporary cwnd reductions would also be of interest -- to get a reference of how effective this mechanism is.

Quoted 1 line

+#define NV_INIT_RTT 0xffffffff

Maybe use U32_MAX?

net/ipv4/tcp_nv.c line 138

Quoted 10 lines
net/ipv4/tcp_nv.c new file +10 -0
+static void tcpnv_init(struct sock *sk)
+{
+       struct tcpnv *ca = inet_csk_ca(sk);
+
+       tcpnv_reset(ca, sk);
+
+       ca->nv_min_rtt_reset_jiffies = jiffies + 2*HZ;
+       ca->nv_min_rtt = NV_INIT_RTT;
+       ca->nv_min_rtt_new = NV_INIT_RTT;
+       ca->nv_enable = nv_enable;

Can this assignment be ca->nv_enable = 1? That would match the TCP_CA_Open case in tcpnv_state().

net/ipv4/tcp_nv.c line 143

Quoted 4 lines
net/ipv4/tcp_nv.c new file +4 -0
+       if (nv_dec_eval_min_calls > 255)
+               nv_dec_eval_min_calls = 255;
+       if (nv_rtt_min_cnt > 63)
+               nv_rtt_min_cnt = 63;

nv_dec_eval_min_calls can be clamped to 0-255 by changing its type to u8.

nv_rtt_min_cnt can also be u8? In struct tcpnv, perhaps move nv_rtt_cnt to the available byte.

net/ipv4/tcp_nv.c line 156

Quoted 11 lines
net/ipv4/tcp_nv.c new file +11 -0
+static void tcpnv_cong_avoid(struct sock *sk, u32 ack, u32 acked)
+{
+       struct tcp_sock *tp = tcp_sk(sk);
+       struct tcpnv *ca = inet_csk_ca(sk);
+
+       if (!tcp_is_cwnd_limited(sk))
+               return;
+
+       /* Only grow cwnd if NV has not detected congestion */
+       if (nv_enable && ca->nv_enable && !ca->nv_allow_cwnd_growth)
+               return;

The check for ca->nv_enable might be overly harsh on some unfortunate sockets in TCP_CA_Disorder. Is it needed here?

Quoted 1 line

+static void tcpnv_acked(struct sock *sk, struct ack_sample *sample)

Maybe move some of this function to tcpnv_cong_avoid()?

Quoted 7 lines
net/ipv4/tcp_nv.c new file +7 -0
+{
+       const struct inet_connection_sock *icsk = inet_csk(sk);
+       struct tcp_sock *tp = tcp_sk(sk);
+       struct tcpnv *ca = inet_csk_ca(sk);
+       unsigned long now = jiffies;
+       s64 rate64 = 0;
+       u32 rate, max_win, cwnd_by_slope;

net/ipv4/tcp_nv.c line 216

Quoted 10 lines
net/ipv4/tcp_nv.c new file +10 -0
+       u32 avg_rtt;
+       u32 bytes_acked = 0;
+
+       /* Some calls are for duplicates without timetamps */
+       if (sample->rtt_us < 0)
+               return;
+
+       /* If not in TCP_CA_Open state, skip. */
+       if (icsk->icsk_ca_state != TCP_CA_Open)
+               return;

Consider using samples in other states too, especially TCP_CA_Disorder. Linux 4.2 enhances RTT sampling from SACKs, so any non-negative RTT sample should be fully usable.

#6 lore raw

Kenneth, thank you for your comments, I¹ve implemented most of the improvements you've mentioned.

I¹m finishing the new patch and the updated results, they should be done by Monday (including cdg).

Quoted 4 lines · On 8/5/15, 5:51 PM, "[email protected] on behalf of Kenneth Klette Jonassen"…
Quoted 1 line · Lawrence Brakmo

This is a request for comments.

Nice to see more development on delay-based congestion control.

Thank you.

Quoted 5 lines

It would be good to see how NV stacks up against CDG. Any chance of adding cdg as a congestion control parameter to your experiments? Experiments on NV without its temporary cwnd reductions would also be of interest -- to get a reference of how effective this mechanism is.

I¹m finishing with cdg experiments, they will be up on Monday together with an update to the NV patch.
I will also have some experiments with variations in the temporary cwnd reduction. This mechanism is meant to reduce min_rtt creep, but it is now always successful. Its drawback is that it can increase high percentile latency.

Quoted 5 lines
Quoted 3 lines

+#define NV_INIT_RTT 0xffffffff

Maybe use U32_MAX?

Done

Quoted 15 lines

net/ipv4/tcp_nv.c line 138

Quoted 12 lines
net/ipv4/tcp_nv.c new file +10 -0
+static void tcpnv_init(struct sock *sk)
+{
+       struct tcpnv *ca = inet_csk_ca(sk);
+
+       tcpnv_reset(ca, sk);
+
+       ca->nv_min_rtt_reset_jiffies = jiffies + 2*HZ;
+       ca->nv_min_rtt = NV_INIT_RTT;
+       ca->nv_min_rtt_new = NV_INIT_RTT;
+       ca->nv_enable = nv_enable;

Can this assignment be ca->nv_enable = 1? That would match the TCP_CA_Open case in tcpnv_state().

Done

Quoted 11 lines

net/ipv4/tcp_nv.c line 143

Quoted 6 lines
net/ipv4/tcp_nv.c new file +4 -0
+       if (nv_dec_eval_min_calls > 255)
+               nv_dec_eval_min_calls = 255;
+       if (nv_rtt_min_cnt > 63)
+               nv_rtt_min_cnt = 63;

nv_dec_eval_min_calls can be clamped to 0-255 by changing its type to u8.

nv_rtt_min_cnt can also be u8? In struct tcpnv, perhaps move nv_rtt_cnt to the available byte.

Done

Quoted 16 lines

net/ipv4/tcp_nv.c line 156

Quoted 13 lines
net/ipv4/tcp_nv.c new file +11 -0
+static void tcpnv_cong_avoid(struct sock *sk, u32 ack, u32 acked)
+{
+       struct tcp_sock *tp = tcp_sk(sk);
+       struct tcpnv *ca = inet_csk_ca(sk);
+
+       if (!tcp_is_cwnd_limited(sk))
+               return;
+
+       /* Only grow cwnd if NV has not detected congestion */
+       if (nv_enable && ca->nv_enable && !ca->nv_allow_cwnd_growth)
+               return;

The check for ca->nv_enable might be overly harsh on some unfortunate sockets in TCP_CA_Disorder. Is it needed here?

TCP_CA_Disorder should not affect ca->nv_enable in the new patch

Quoted 5 lines
Quoted 3 lines

+static void tcpnv_acked(struct sock *sk, struct ack_sample *sample)

Maybe move some of this function to tcpnv_cong_avoid()?

It needs to be here since We need the information provided in argument sample

Quoted 15 lines
Quoted 15 lines
net/ipv4/tcp_nv.c new file +13 -0
+{
+       const struct inet_connection_sock *icsk = inet_csk(sk);
+       struct tcp_sock *tp = tcp_sk(sk);
+       struct tcpnv *ca = inet_csk_ca(sk);
+       unsigned long now = jiffies;
+       s64 rate64 = 0;
+       u32 rate, max_win, cwnd_by_slope;
+       u32 avg_rtt;
+       u32 bytes_acked = 0;
+
+       /* Some calls are for duplicates without timetamps */
+       if (sample->rtt_us < 0)
+               return;
Quoted 8 lines

net/ipv4/tcp_nv.c line 216

Quoted 4 lines
net/ipv4/tcp_nv.c new file +4 -0
+
+       /* If not in TCP_CA_Open state, skip. */
+       if (icsk->icsk_ca_state != TCP_CA_Open)
+               return;

Consider using samples in other states too, especially TCP_CA_Disorder. Linux 4.2 enhances RTT sampling from SACKs, so any non-negative RTT sample should be fully usable.

Done

Quoted 1 line
#7 lore raw
In reply to Kenneth Klette Jonassen
Quoted 7 lines · On 8/5/15, 5:51 PM, "[email protected] on behalf of Kenneth Klette Jonassen"…
Quoted 1 line · Lawrence Brakmo

This is a request for comments.

Nice to see more development on delay-based congestion control.

It would be good to see how NV stacks up against CDG. Any chance of adding cdg as a congestion control parameter to your experiments?

Done. I¹m updating the TCP-NV page with the updated results, should be done by tomorrow (8/26).

Quoted 2 lines

Experiments on NV without its temporary cwnd reductions would also be of interest -- to get a reference of how effective this mechanism is.

Done. It turns out that it only improves fairness a little but hurts P99 latencies more significantly. So it is now off by default. Thanks for making me re-examine this feature.