Skip to contentSkip to conversation

tcp: add NV congestion control

PATCH In review Lawrence Brakmo 2 participants 6 messages Jun 3, 2016 – Jun 7, 2016

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

cover tcp: add NV congestion control

This version of NV does much better than previous versions when things are very congested and also adds a couple of experimental features.

Tested in a rack using between 1 and 380 active TCP-NV flows.

Consists of the following patches:
[PATCH net-next 1/2] tcp: add in_flight to tcp_skb_cb [PATCH net-next 2/2] tcp: add NV congestion control

include/net/tcp.h     |   2 +
net/ipv4/Kconfig      |  16 ++
net/ipv4/Makefile     |   1 +
net/ipv4/tcp_input.c  |   5 +-
net/ipv4/tcp_nv.c     | 597 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++
net/ipv4/tcp_output.c |   4 +-
6 files changed, 623 insertions(+), 2 deletions(-)
#1 lore raw

PATCH 1/2 tcp: add in_flight to tcp_skb_cb

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 0bcc70f..a79894b 100644
@@ -767,6 +767,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;
@@ -859,6 +860,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 d6c8f4cd0..c7f33f0 100644
@@ -3115,6 +3115,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;
 
@@ -3154,6 +3155,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;
@@ -3250,7 +3252,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 = pkts_acked,
-					     .rtt_us = ca_rtt_us };
+					     .rtt_us = ca_rtt_us,
+					     .in_flight = last_in_flight };
 
 		icsk->icsk_ca_ops->pkts_acked(sk, &sample);
 	}
net/ipv4/tcp_output.c +3 -1
index 8bd9911..b1bcba0 100644
@@ -911,9 +911,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);
@@ -924,7 +927,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
2.8.0.rc2
#2 lore raw

PATCH 2/2 tcp: add NV congestion control

In reply to Lawrence Brakmo

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 | 597 ++++++++++++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 614 insertions(+)
 create mode 100644 net/ipv4/tcp_nv.c
net/ipv4/Kconfig +16 -0
index 238225b..50d6a9b 100644
@@ -532,6 +532,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 bfa1336..24629b6 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 +597 -0

597 lines not on this page · raw message

Signature · 1 line
2.8.0.rc2
maintainer
#3 lore raw

From: Lawrence Brakmo <[email protected]>
Date: Fri, 3 Jun 2016 13:37:58 -0700

Quoted 39 lines
net/ipv4/tcp_nv.c new file +39 -0
+module_param(nv_enable, int, 0644);
+MODULE_PARM_DESC(nv_enable, "enable NV (congestion avoidance) behavior");
+module_param(nv_pad, int, 0644);
+MODULE_PARM_DESC(nv_pad, "extra packets above congestion level");
+module_param(nv_pad_buffer, int, 0644);
+MODULE_PARM_DESC(nv_pad_buffer, "no growth buffer zone");
+module_param(nv_reset_period, int, 0644);
+MODULE_PARM_DESC(nv_reset_period, "nv_min_rtt reset period (secs)");
+module_param(nv_min_cwnd, int, 0644);
+MODULE_PARM_DESC(nv_min_cwnd, "NV will not decrease cwnd below this value"
+		 " without losses");
+module_param(nv_dec_eval_min_calls, int, 0644);
+MODULE_PARM_DESC(nv_dec_eval_min_calls, "Wait for this many data points"
+		 " before declaring congestion");
+module_param(nv_inc_eval_min_calls, int, 0644);
+MODULE_PARM_DESC(nv_inc_eval_min_calls, "Wait for this many data points"
+		 " before allowing cwnd growth");
+module_param(nv_stop_rtt_cnt, int, 0644);
+MODULE_PARM_DESC(nv_stop_rtt_cnt, "Wait for this many RTTs before stopping"
+		 " cwnd growth");
+module_param(nv_ssthresh_eval_min_calls, int, 0644);
+MODULE_PARM_DESC(nv_ssthresh_eval_min_calls, "Wait for this many data points"
+		 " before declaring congestion during initial slow-start");
+module_param(nv_rtt_min_cnt, int, 0644);
+MODULE_PARM_DESC(nv_rtt_min_cnt, "Wait for this many RTTs before declaring"
+		 " congestion");
+module_param(nv_cong_dec_mult, int, 0644);
+MODULE_PARM_DESC(nv_cong_dec_mult, "Congestion decrease factor");
+module_param(nv_ssthresh_factor, int, 0644);
+MODULE_PARM_DESC(nv_ssthresh_factor, "ssthresh factor");
+module_param(nv_rtt_factor, int, 0644);
+MODULE_PARM_DESC(nv_rtt_factor, "rtt averaging factor");
+module_param(nv_rtt_cnt_dec_delta, int, 0644);
+MODULE_PARM_DESC(nv_rtt_cnt_dec_delta, "decrease cwnd for this many RTTs"
+		 " every 100 RTTs");
+module_param(nv_dec_factor, int, 0644);
+MODULE_PARM_DESC(nv_dec_factor, "decrease cwnd every ~192 RTTS by factor/8");
+module_param(nv_loss_dec_factor, int, 0644);
+MODULE_PARM_DESC(nv_loss_dec_factor, "on loss new cwnd = cwnd * this / 1024");

net/ipv4/tcp_nv.c line 131

Quoted 10 lines
net/ipv4/tcp_nv.c new file +10 -0
+module_param(nv_cwnd_growth_rate_neg, int, 0644);
+MODULE_PARM_DESC(nv_cwnd_growth_rate_neg, "Applies when current cwnd growth"
+		 " rate < Reno");
+module_param(nv_cwnd_growth_rate_pos, int, 0644);
+MODULE_PARM_DESC(nv_cwnd_growth_rate_pos, "Applies when current cwnd growth"
+		 " rate >= Reno");
+module_param(nv_min_min_rtt, int, 0644);
+MODULE_PARM_DESC(nv_min_min_rtt, "lower bound for ca->nv_min_rtt");
+module_param(nv_max_min_rtt, int, 0644);
+MODULE_PARM_DESC(nv_max_min_rtt, "upper bound for ca->nv_min_rtt");

That's a disturbingly huge number of module parameters. Even the first one "nv_enable" is superfluous, just hook up another congestion control algorithm.

Please trim this down to something reasonable. The more of these you have, the more of them people will start wanting to use and depend upon, and then you're stuck with them whether you like it or not.

#4 lore raw
Quoted 69 lines · David Miller

From: Lawrence Brakmo <[email protected]>
Date: Fri, 3 Jun 2016 13:37:58 -0700

Quoted 56 lines
(quoted diff) +2 -0
+module_param(nv_enable, int, 0644);
+MODULE_PARM_DESC(nv_enable, "enable NV (congestion avoidance)

behavior");

net/ipv4/tcp_nv.c new file +8 -0
+module_param(nv_pad, int, 0644);
+MODULE_PARM_DESC(nv_pad, "extra packets above congestion level");
+module_param(nv_pad_buffer, int, 0644);
+MODULE_PARM_DESC(nv_pad_buffer, "no growth buffer zone");
+module_param(nv_reset_period, int, 0644);
+MODULE_PARM_DESC(nv_reset_period, "nv_min_rtt reset period (secs)");
+module_param(nv_min_cwnd, int, 0644);
+MODULE_PARM_DESC(nv_min_cwnd, "NV will not decrease cwnd below this

value"

net/ipv4/tcp_nv.c new file +3 -0
+		 " without losses");
+module_param(nv_dec_eval_min_calls, int, 0644);
+MODULE_PARM_DESC(nv_dec_eval_min_calls, "Wait for this many data

points"

net/ipv4/tcp_nv.c new file +3 -0
+		 " before declaring congestion");
+module_param(nv_inc_eval_min_calls, int, 0644);
+MODULE_PARM_DESC(nv_inc_eval_min_calls, "Wait for this many data

points"

net/ipv4/tcp_nv.c new file +3 -0
+		 " before allowing cwnd growth");
+module_param(nv_stop_rtt_cnt, int, 0644);
+MODULE_PARM_DESC(nv_stop_rtt_cnt, "Wait for this many RTTs before

stopping"

net/ipv4/tcp_nv.c new file +3 -0
+		 " cwnd growth");
+module_param(nv_ssthresh_eval_min_calls, int, 0644);
+MODULE_PARM_DESC(nv_ssthresh_eval_min_calls, "Wait for this many data

points"

net/ipv4/tcp_nv.c new file +3 -0
+		 " before declaring congestion during initial slow-start");
+module_param(nv_rtt_min_cnt, int, 0644);
+MODULE_PARM_DESC(nv_rtt_min_cnt, "Wait for this many RTTs before

declaring"

net/ipv4/tcp_nv.c new file +9 -0
+		 " congestion");
+module_param(nv_cong_dec_mult, int, 0644);
+MODULE_PARM_DESC(nv_cong_dec_mult, "Congestion decrease factor");
+module_param(nv_ssthresh_factor, int, 0644);
+MODULE_PARM_DESC(nv_ssthresh_factor, "ssthresh factor");
+module_param(nv_rtt_factor, int, 0644);
+MODULE_PARM_DESC(nv_rtt_factor, "rtt averaging factor");
+module_param(nv_rtt_cnt_dec_delta, int, 0644);
+MODULE_PARM_DESC(nv_rtt_cnt_dec_delta, "decrease cwnd for this many

RTTs"

net/ipv4/tcp_nv.c new file +3 -0
+		 " every 100 RTTs");
+module_param(nv_dec_factor, int, 0644);
+MODULE_PARM_DESC(nv_dec_factor, "decrease cwnd every ~192 RTTS by

factor/8");

(quoted diff) +2 -0
+module_param(nv_loss_dec_factor, int, 0644);
+MODULE_PARM_DESC(nv_loss_dec_factor, "on loss new cwnd = cwnd * this /

1024");

(quoted diff) +2 -0
+module_param(nv_cwnd_growth_rate_neg, int, 0644);
+MODULE_PARM_DESC(nv_cwnd_growth_rate_neg, "Applies when current cwnd

growth"

net/ipv4/tcp_nv.c new file +3 -0
+		 " rate < Reno");
+module_param(nv_cwnd_growth_rate_pos, int, 0644);
+MODULE_PARM_DESC(nv_cwnd_growth_rate_pos, "Applies when current cwnd

growth"

net/ipv4/tcp_nv.c line 131

Quoted 5 lines
net/ipv4/tcp_nv.c new file +5 -0
+		 " rate >= Reno");
+module_param(nv_min_min_rtt, int, 0644);
+MODULE_PARM_DESC(nv_min_min_rtt, "lower bound for ca->nv_min_rtt");
+module_param(nv_max_min_rtt, int, 0644);
+MODULE_PARM_DESC(nv_max_min_rtt, "upper bound for ca->nv_min_rtt");

That's a disturbingly huge number of module parameters. Even the first one "nv_enable" is superfluous, just hook up another congestion control algorithm.

Quoted 5 lines

Please trim this down to something reasonable. The more of these you have,
the more of them people will start wanting to use and depend upon, and then
you're stuck with them whether you like it or not.

I will trim them down to something much smaller. My original intent was to support experimentation, but those interested can use this version of the patch to play with a larger number of parameters/tunables.

In regards to the parameter ³nv_enable², its function is to quickly allow existing NV flows to revert to Reno behavior (by ³echo 0 > /sys/module/tcp_nv/parameters/nv_enable²). The reason why this may be necessary, is that under some conditions NV flows competing with more aggressive flows will perform poorly. People may be more willing to test NV if there is a quick and simple way to revert if necessary (without having to restart the flows).

As to why NV could perform poorly, it has to do with the inherent unfairness between flows that only decrease their cwnd when there are losses (congestion control) and flows that decrease their cwnd when they detect queue buildup (congestion avoidance) unless there is network support. This is specially true when the RTTs for both types are small (traffic within a DC), but the unfairness decreases as the RTTs of the congestion control flows increases.

So, is it okay if I leave the parameter ³nv_enable² or would you still prefer that I remove it?

maintainer
#5 lore raw

From: Lawrence Brakmo <[email protected]>
Date: Tue, 7 Jun 2016 01:04:06 +0000

Quoted 5 lines

The reason why this may be necessary, is that under some conditions NV flows competing with more aggressive flows will perform poorly. People may be more willing to test NV if there is a quick and simple way to revert if necessary (without having to restart the flows).

This is a property that may apply to any congestion control algorithm whatsoever, not just NV.