summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLawrence Brakmo <brakmo@fb.com>2016-05-11 13:02:13 -0400
committerDavid S. Miller <davem@davemloft.net>2016-05-11 14:43:19 -0400
commit756ee1729b2feb3a45767da29e338f70f2086ba3 (patch)
tree9329409e197d2912d3fba7e247a57239996c99e9
parentcf88585b1d5ce49515aabb381812976e2840a967 (diff)
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. Signed-off-by: Lawrence Brakmo <brakmo@fb.com> Acked-by: Yuchung Cheng <ycheng@google.com> Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r--include/net/tcp.h7
-rw-r--r--net/ipv4/tcp_bic.c6
-rw-r--r--net/ipv4/tcp_cdg.c14
-rw-r--r--net/ipv4/tcp_cubic.c6
-rw-r--r--net/ipv4/tcp_htcp.c10
-rw-r--r--net/ipv4/tcp_illinois.c21
-rw-r--r--net/ipv4/tcp_input.c8
-rw-r--r--net/ipv4/tcp_lp.c6
-rw-r--r--net/ipv4/tcp_vegas.c6
-rw-r--r--net/ipv4/tcp_vegas.h2
-rw-r--r--net/ipv4/tcp_veno.c7
-rw-r--r--net/ipv4/tcp_westwood.c7
-rw-r--r--net/ipv4/tcp_yeah.c7
13 files changed, 60 insertions, 47 deletions
diff --git a/include/net/tcp.h b/include/net/tcp.h
index 4775a1bba7f7..c9ab561387c4 100644
--- a/include/net/tcp.h
+++ b/include/net/tcp.h
@@ -854,6 +854,11 @@ enum tcp_ca_ack_event_flags {
854 854
855union tcp_cc_info; 855union tcp_cc_info;
856 856
857struct ack_sample {
858 u32 pkts_acked;
859 s32 rtt_us;
860};
861
857struct tcp_congestion_ops { 862struct tcp_congestion_ops {
858 struct list_head list; 863 struct list_head list;
859 u32 key; 864 u32 key;
@@ -877,7 +882,7 @@ struct tcp_congestion_ops {
877 /* new value of cwnd after loss (optional) */ 882 /* new value of cwnd after loss (optional) */
878 u32 (*undo_cwnd)(struct sock *sk); 883 u32 (*undo_cwnd)(struct sock *sk);
879 /* hook for packet ack accounting (optional) */ 884 /* hook for packet ack accounting (optional) */
880 void (*pkts_acked)(struct sock *sk, u32 num_acked, s32 rtt_us); 885 void (*pkts_acked)(struct sock *sk, const struct ack_sample *sample);
881 /* get info for inet_diag (optional) */ 886 /* get info for inet_diag (optional) */
882 size_t (*get_info)(struct sock *sk, u32 ext, int *attr, 887 size_t (*get_info)(struct sock *sk, u32 ext, int *attr,
883 union tcp_cc_info *info); 888 union tcp_cc_info *info);
diff --git a/net/ipv4/tcp_bic.c b/net/ipv4/tcp_bic.c
index fd1405d37c14..36087bca9f48 100644
--- a/net/ipv4/tcp_bic.c
+++ b/net/ipv4/tcp_bic.c
@@ -197,15 +197,15 @@ static void bictcp_state(struct sock *sk, u8 new_state)
197/* Track delayed acknowledgment ratio using sliding window 197/* Track delayed acknowledgment ratio using sliding window
198 * ratio = (15*ratio + sample) / 16 198 * ratio = (15*ratio + sample) / 16
199 */ 199 */
200static void bictcp_acked(struct sock *sk, u32 cnt, s32 rtt) 200static void bictcp_acked(struct sock *sk, const struct ack_sample *sample)
201{ 201{
202 const struct inet_connection_sock *icsk = inet_csk(sk); 202 const struct inet_connection_sock *icsk = inet_csk(sk);
203 203
204 if (icsk->icsk_ca_state == TCP_CA_Open) { 204 if (icsk->icsk_ca_state == TCP_CA_Open) {
205 struct bictcp *ca = inet_csk_ca(sk); 205 struct bictcp *ca = inet_csk_ca(sk);
206 206
207 cnt -= ca->delayed_ack >> ACK_RATIO_SHIFT; 207 ca->delayed_ack += sample->pkts_acked -
208 ca->delayed_ack += cnt; 208 (ca->delayed_ack >> ACK_RATIO_SHIFT);
209 } 209 }
210} 210}
211 211
diff --git a/net/ipv4/tcp_cdg.c b/net/ipv4/tcp_cdg.c
index ccce8a55f1e1..03725b294286 100644
--- a/net/ipv4/tcp_cdg.c
+++ b/net/ipv4/tcp_cdg.c
@@ -294,12 +294,12 @@ static void tcp_cdg_cong_avoid(struct sock *sk, u32 ack, u32 acked)
294 ca->shadow_wnd = max(ca->shadow_wnd, ca->shadow_wnd + incr); 294 ca->shadow_wnd = max(ca->shadow_wnd, ca->shadow_wnd + incr);
295} 295}
296 296
297static void tcp_cdg_acked(struct sock *sk, u32 num_acked, s32 rtt_us) 297static void tcp_cdg_acked(struct sock *sk, const struct ack_sample *sample)
298{ 298{
299 struct cdg *ca = inet_csk_ca(sk); 299 struct cdg *ca = inet_csk_ca(sk);
300 struct tcp_sock *tp = tcp_sk(sk); 300 struct tcp_sock *tp = tcp_sk(sk);
301 301
302 if (rtt_us <= 0) 302 if (sample->rtt_us <= 0)
303 return; 303 return;
304 304
305 /* A heuristic for filtering delayed ACKs, adapted from: 305 /* 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)
307 * delay and rate based TCP mechanisms." TR 100219A. CAIA, 2010. 307 * delay and rate based TCP mechanisms." TR 100219A. CAIA, 2010.
308 */ 308 */
309 if (tp->sacked_out == 0) { 309 if (tp->sacked_out == 0) {
310 if (num_acked == 1 && ca->delack) { 310 if (sample->pkts_acked == 1 && ca->delack) {
311 /* A delayed ACK is only used for the minimum if it is 311 /* A delayed ACK is only used for the minimum if it is
312 * provenly lower than an existing non-zero minimum. 312 * provenly lower than an existing non-zero minimum.
313 */ 313 */
314 ca->rtt.min = min(ca->rtt.min, rtt_us); 314 ca->rtt.min = min(ca->rtt.min, sample->rtt_us);
315 ca->delack--; 315 ca->delack--;
316 return; 316 return;
317 } else if (num_acked > 1 && ca->delack < 5) { 317 } else if (sample->pkts_acked > 1 && ca->delack < 5) {
318 ca->delack++; 318 ca->delack++;
319 } 319 }
320 } 320 }
321 321
322 ca->rtt.min = min_not_zero(ca->rtt.min, rtt_us); 322 ca->rtt.min = min_not_zero(ca->rtt.min, sample->rtt_us);
323 ca->rtt.max = max(ca->rtt.max, rtt_us); 323 ca->rtt.max = max(ca->rtt.max, sample->rtt_us);
324} 324}
325 325
326static u32 tcp_cdg_ssthresh(struct sock *sk) 326static u32 tcp_cdg_ssthresh(struct sock *sk)
diff --git a/net/ipv4/tcp_cubic.c b/net/ipv4/tcp_cubic.c
index 0ce946e395e1..c99230efcd52 100644
--- a/net/ipv4/tcp_cubic.c
+++ b/net/ipv4/tcp_cubic.c
@@ -437,21 +437,21 @@ static void hystart_update(struct sock *sk, u32 delay)
437/* Track delayed acknowledgment ratio using sliding window 437/* Track delayed acknowledgment ratio using sliding window
438 * ratio = (15*ratio + sample) / 16 438 * ratio = (15*ratio + sample) / 16
439 */ 439 */
440static void bictcp_acked(struct sock *sk, u32 cnt, s32 rtt_us) 440static void bictcp_acked(struct sock *sk, const struct ack_sample *sample)
441{ 441{
442 const struct tcp_sock *tp = tcp_sk(sk); 442 const struct tcp_sock *tp = tcp_sk(sk);
443 struct bictcp *ca = inet_csk_ca(sk); 443 struct bictcp *ca = inet_csk_ca(sk);
444 u32 delay; 444 u32 delay;
445 445
446 /* Some calls are for duplicates without timetamps */ 446 /* Some calls are for duplicates without timetamps */
447 if (rtt_us < 0) 447 if (sample->rtt_us < 0)
448 return; 448 return;
449 449
450 /* Discard delay samples right after fast recovery */ 450 /* Discard delay samples right after fast recovery */
451 if (ca->epoch_start && (s32)(tcp_time_stamp - ca->epoch_start) < HZ) 451 if (ca->epoch_start && (s32)(tcp_time_stamp - ca->epoch_start) < HZ)
452 return; 452 return;
453 453
454 delay = (rtt_us << 3) / USEC_PER_MSEC; 454 delay = (sample->rtt_us << 3) / USEC_PER_MSEC;
455 if (delay == 0) 455 if (delay == 0)
456 delay = 1; 456 delay = 1;
457 457
diff --git a/net/ipv4/tcp_htcp.c b/net/ipv4/tcp_htcp.c
index 82f0d9ed60f5..4a4d8e76738f 100644
--- a/net/ipv4/tcp_htcp.c
+++ b/net/ipv4/tcp_htcp.c
@@ -99,7 +99,7 @@ static inline void measure_rtt(struct sock *sk, u32 srtt)
99} 99}
100 100
101static void measure_achieved_throughput(struct sock *sk, 101static void measure_achieved_throughput(struct sock *sk,
102 u32 pkts_acked, s32 rtt) 102 const struct ack_sample *sample)
103{ 103{
104 const struct inet_connection_sock *icsk = inet_csk(sk); 104 const struct inet_connection_sock *icsk = inet_csk(sk);
105 const struct tcp_sock *tp = tcp_sk(sk); 105 const struct tcp_sock *tp = tcp_sk(sk);
@@ -107,10 +107,10 @@ static void measure_achieved_throughput(struct sock *sk,
107 u32 now = tcp_time_stamp; 107 u32 now = tcp_time_stamp;
108 108
109 if (icsk->icsk_ca_state == TCP_CA_Open) 109 if (icsk->icsk_ca_state == TCP_CA_Open)
110 ca->pkts_acked = pkts_acked; 110 ca->pkts_acked = sample->pkts_acked;
111 111
112 if (rtt > 0) 112 if (sample->rtt_us > 0)
113 measure_rtt(sk, usecs_to_jiffies(rtt)); 113 measure_rtt(sk, usecs_to_jiffies(sample->rtt_us));
114 114
115 if (!use_bandwidth_switch) 115 if (!use_bandwidth_switch)
116 return; 116 return;
@@ -122,7 +122,7 @@ static void measure_achieved_throughput(struct sock *sk,
122 return; 122 return;
123 } 123 }
124 124
125 ca->packetcount += pkts_acked; 125 ca->packetcount += sample->pkts_acked;
126 126
127 if (ca->packetcount >= tp->snd_cwnd - (ca->alpha >> 7 ? : 1) && 127 if (ca->packetcount >= tp->snd_cwnd - (ca->alpha >> 7 ? : 1) &&
128 now - ca->lasttime >= ca->minRTT && 128 now - ca->lasttime >= ca->minRTT &&
diff --git a/net/ipv4/tcp_illinois.c b/net/ipv4/tcp_illinois.c
index 2ab9bbb6faff..c8e6d86be114 100644
--- a/net/ipv4/tcp_illinois.c
+++ b/net/ipv4/tcp_illinois.c
@@ -82,30 +82,31 @@ static void tcp_illinois_init(struct sock *sk)
82} 82}
83 83
84/* Measure RTT for each ack. */ 84/* Measure RTT for each ack. */
85static void tcp_illinois_acked(struct sock *sk, u32 pkts_acked, s32 rtt) 85static void tcp_illinois_acked(struct sock *sk, const struct ack_sample *sample)
86{ 86{
87 struct illinois *ca = inet_csk_ca(sk); 87 struct illinois *ca = inet_csk_ca(sk);
88 s32 rtt_us = sample->rtt_us;
88 89
89 ca->acked = pkts_acked; 90 ca->acked = sample->pkts_acked;
90 91
91 /* dup ack, no rtt sample */ 92 /* dup ack, no rtt sample */
92 if (rtt < 0) 93 if (rtt_us < 0)
93 return; 94 return;
94 95
95 /* ignore bogus values, this prevents wraparound in alpha math */ 96 /* ignore bogus values, this prevents wraparound in alpha math */
96 if (rtt > RTT_MAX) 97 if (rtt_us > RTT_MAX)
97 rtt = RTT_MAX; 98 rtt_us = RTT_MAX;
98 99
99 /* keep track of minimum RTT seen so far */ 100 /* keep track of minimum RTT seen so far */
100 if (ca->base_rtt > rtt) 101 if (ca->base_rtt > rtt_us)
101 ca->base_rtt = rtt; 102 ca->base_rtt = rtt_us;
102 103
103 /* and max */ 104 /* and max */
104 if (ca->max_rtt < rtt) 105 if (ca->max_rtt < rtt_us)
105 ca->max_rtt = rtt; 106 ca->max_rtt = rtt_us;
106 107
107 ++ca->cnt_rtt; 108 ++ca->cnt_rtt;
108 ca->sum_rtt += rtt; 109 ca->sum_rtt += rtt_us;
109} 110}
110 111
111/* Maximum queuing delay */ 112/* Maximum queuing delay */
diff --git a/net/ipv4/tcp_input.c b/net/ipv4/tcp_input.c
index a914e0607895..d6c8f4cd0800 100644
--- a/net/ipv4/tcp_input.c
+++ b/net/ipv4/tcp_input.c
@@ -3248,8 +3248,12 @@ static int tcp_clean_rtx_queue(struct sock *sk, int prior_fackets,
3248 tcp_rearm_rto(sk); 3248 tcp_rearm_rto(sk);
3249 } 3249 }
3250 3250
3251 if (icsk->icsk_ca_ops->pkts_acked) 3251 if (icsk->icsk_ca_ops->pkts_acked) {
3252 icsk->icsk_ca_ops->pkts_acked(sk, pkts_acked, ca_rtt_us); 3252 struct ack_sample sample = { .pkts_acked = pkts_acked,
3253 .rtt_us = ca_rtt_us };
3254
3255 icsk->icsk_ca_ops->pkts_acked(sk, &sample);
3256 }
3253 3257
3254#if FASTRETRANS_DEBUG > 0 3258#if FASTRETRANS_DEBUG > 0
3255 WARN_ON((int)tp->sacked_out < 0); 3259 WARN_ON((int)tp->sacked_out < 0);
diff --git a/net/ipv4/tcp_lp.c b/net/ipv4/tcp_lp.c
index 1e70fa8fa793..c67ece1390c2 100644
--- a/net/ipv4/tcp_lp.c
+++ b/net/ipv4/tcp_lp.c
@@ -260,13 +260,13 @@ static void tcp_lp_rtt_sample(struct sock *sk, u32 rtt)
260 * newReno in increase case. 260 * newReno in increase case.
261 * We work it out by following the idea from TCP-LP's paper directly 261 * We work it out by following the idea from TCP-LP's paper directly
262 */ 262 */
263static void tcp_lp_pkts_acked(struct sock *sk, u32 num_acked, s32 rtt_us) 263static void tcp_lp_pkts_acked(struct sock *sk, const struct ack_sample *sample)
264{ 264{
265 struct tcp_sock *tp = tcp_sk(sk); 265 struct tcp_sock *tp = tcp_sk(sk);
266 struct lp *lp = inet_csk_ca(sk); 266 struct lp *lp = inet_csk_ca(sk);
267 267
268 if (rtt_us > 0) 268 if (sample->rtt_us > 0)
269 tcp_lp_rtt_sample(sk, rtt_us); 269 tcp_lp_rtt_sample(sk, sample->rtt_us);
270 270
271 /* calc inference */ 271 /* calc inference */
272 if (tcp_time_stamp > tp->rx_opt.rcv_tsecr) 272 if (tcp_time_stamp > tp->rx_opt.rcv_tsecr)
diff --git a/net/ipv4/tcp_vegas.c b/net/ipv4/tcp_vegas.c
index 13951c4087d4..4c4bac1b5eab 100644
--- a/net/ipv4/tcp_vegas.c
+++ b/net/ipv4/tcp_vegas.c
@@ -107,16 +107,16 @@ EXPORT_SYMBOL_GPL(tcp_vegas_init);
107 * o min-filter RTT samples from a much longer window (forever for now) 107 * o min-filter RTT samples from a much longer window (forever for now)
108 * to find the propagation delay (baseRTT) 108 * to find the propagation delay (baseRTT)
109 */ 109 */
110void tcp_vegas_pkts_acked(struct sock *sk, u32 cnt, s32 rtt_us) 110void tcp_vegas_pkts_acked(struct sock *sk, const struct ack_sample *sample)
111{ 111{
112 struct vegas *vegas = inet_csk_ca(sk); 112 struct vegas *vegas = inet_csk_ca(sk);
113 u32 vrtt; 113 u32 vrtt;
114 114
115 if (rtt_us < 0) 115 if (sample->rtt_us < 0)
116 return; 116 return;
117 117
118 /* Never allow zero rtt or baseRTT */ 118 /* Never allow zero rtt or baseRTT */
119 vrtt = rtt_us + 1; 119 vrtt = sample->rtt_us + 1;
120 120
121 /* Filter to find propagation delay: */ 121 /* Filter to find propagation delay: */
122 if (vrtt < vegas->baseRTT) 122 if (vrtt < vegas->baseRTT)
diff --git a/net/ipv4/tcp_vegas.h b/net/ipv4/tcp_vegas.h
index ef9da5306c68..248cfc0ff9ae 100644
--- a/net/ipv4/tcp_vegas.h
+++ b/net/ipv4/tcp_vegas.h
@@ -17,7 +17,7 @@ struct vegas {
17 17
18void tcp_vegas_init(struct sock *sk); 18void tcp_vegas_init(struct sock *sk);
19void tcp_vegas_state(struct sock *sk, u8 ca_state); 19void tcp_vegas_state(struct sock *sk, u8 ca_state);
20void tcp_vegas_pkts_acked(struct sock *sk, u32 cnt, s32 rtt_us); 20void tcp_vegas_pkts_acked(struct sock *sk, const struct ack_sample *sample);
21void tcp_vegas_cwnd_event(struct sock *sk, enum tcp_ca_event event); 21void tcp_vegas_cwnd_event(struct sock *sk, enum tcp_ca_event event);
22size_t tcp_vegas_get_info(struct sock *sk, u32 ext, int *attr, 22size_t tcp_vegas_get_info(struct sock *sk, u32 ext, int *attr,
23 union tcp_cc_info *info); 23 union tcp_cc_info *info);
diff --git a/net/ipv4/tcp_veno.c b/net/ipv4/tcp_veno.c
index 0d094b995cd9..40171e163cff 100644
--- a/net/ipv4/tcp_veno.c
+++ b/net/ipv4/tcp_veno.c
@@ -69,16 +69,17 @@ static void tcp_veno_init(struct sock *sk)
69} 69}
70 70
71/* Do rtt sampling needed for Veno. */ 71/* Do rtt sampling needed for Veno. */
72static void tcp_veno_pkts_acked(struct sock *sk, u32 cnt, s32 rtt_us) 72static void tcp_veno_pkts_acked(struct sock *sk,
73 const struct ack_sample *sample)
73{ 74{
74 struct veno *veno = inet_csk_ca(sk); 75 struct veno *veno = inet_csk_ca(sk);
75 u32 vrtt; 76 u32 vrtt;
76 77
77 if (rtt_us < 0) 78 if (sample->rtt_us < 0)
78 return; 79 return;
79 80
80 /* Never allow zero rtt or baseRTT */ 81 /* Never allow zero rtt or baseRTT */
81 vrtt = rtt_us + 1; 82 vrtt = sample->rtt_us + 1;
82 83
83 /* Filter to find propagation delay: */ 84 /* Filter to find propagation delay: */
84 if (vrtt < veno->basertt) 85 if (vrtt < veno->basertt)
diff --git a/net/ipv4/tcp_westwood.c b/net/ipv4/tcp_westwood.c
index c10732e39837..4b03a2e2a050 100644
--- a/net/ipv4/tcp_westwood.c
+++ b/net/ipv4/tcp_westwood.c
@@ -99,12 +99,13 @@ static void westwood_filter(struct westwood *w, u32 delta)
99 * Called after processing group of packets. 99 * Called after processing group of packets.
100 * but all westwood needs is the last sample of srtt. 100 * but all westwood needs is the last sample of srtt.
101 */ 101 */
102static void tcp_westwood_pkts_acked(struct sock *sk, u32 cnt, s32 rtt) 102static void tcp_westwood_pkts_acked(struct sock *sk,
103 const struct ack_sample *sample)
103{ 104{
104 struct westwood *w = inet_csk_ca(sk); 105 struct westwood *w = inet_csk_ca(sk);
105 106
106 if (rtt > 0) 107 if (sample->rtt_us > 0)
107 w->rtt = usecs_to_jiffies(rtt); 108 w->rtt = usecs_to_jiffies(sample->rtt_us);
108} 109}
109 110
110/* 111/*
diff --git a/net/ipv4/tcp_yeah.c b/net/ipv4/tcp_yeah.c
index 3e6a472e6b88..028eb046ea40 100644
--- a/net/ipv4/tcp_yeah.c
+++ b/net/ipv4/tcp_yeah.c
@@ -56,15 +56,16 @@ static void tcp_yeah_init(struct sock *sk)
56 tp->snd_cwnd_clamp = min_t(u32, tp->snd_cwnd_clamp, 0xffffffff/128); 56 tp->snd_cwnd_clamp = min_t(u32, tp->snd_cwnd_clamp, 0xffffffff/128);
57} 57}
58 58
59static void tcp_yeah_pkts_acked(struct sock *sk, u32 pkts_acked, s32 rtt_us) 59static void tcp_yeah_pkts_acked(struct sock *sk,
60 const struct ack_sample *sample)
60{ 61{
61 const struct inet_connection_sock *icsk = inet_csk(sk); 62 const struct inet_connection_sock *icsk = inet_csk(sk);
62 struct yeah *yeah = inet_csk_ca(sk); 63 struct yeah *yeah = inet_csk_ca(sk);
63 64
64 if (icsk->icsk_ca_state == TCP_CA_Open) 65 if (icsk->icsk_ca_state == TCP_CA_Open)
65 yeah->pkts_acked = pkts_acked; 66 yeah->pkts_acked = sample->pkts_acked;
66 67
67 tcp_vegas_pkts_acked(sk, pkts_acked, rtt_us); 68 tcp_vegas_pkts_acked(sk, sample);
68} 69}
69 70
70static void tcp_yeah_cong_avoid(struct sock *sk, u32 ack, u32 acked) 71static void tcp_yeah_cong_avoid(struct sock *sk, u32 ack, u32 acked)