aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorstephen hemminger <shemminger@vyatta.com>2011-03-14 03:52:15 -0400
committerDavid S. Miller <davem@davemloft.net>2011-03-14 18:54:39 -0400
commit17a6e9f1aa9ba07ca13a1eaf1e631e743af50cca (patch)
tree131ea88cfe5d80c162de866ee4156178f70156b1
parentaac46324e12a2bf2e9e0855ad6a287945e34ad39 (diff)
tcp_cubic: fix clock dependency
The hystart code was written with assumption that HZ=1000. Replace the use of jiffies with bictcp_clock as a millisecond real time clock. Signed-off-by: Stephen Hemminger <shemminger@vyatta.com> Reported-by: Lucas Nussbaum <lucas.nussbaum@loria.fr> Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r--net/ipv4/tcp_cubic.c31
1 files changed, 19 insertions, 12 deletions
diff --git a/net/ipv4/tcp_cubic.c b/net/ipv4/tcp_cubic.c
index 66d3b00233ec..f4fb2d4b90ad 100644
--- a/net/ipv4/tcp_cubic.c
+++ b/net/ipv4/tcp_cubic.c
@@ -88,7 +88,7 @@ struct bictcp {
88 u32 last_time; /* time when updated last_cwnd */ 88 u32 last_time; /* time when updated last_cwnd */
89 u32 bic_origin_point;/* origin point of bic function */ 89 u32 bic_origin_point;/* origin point of bic function */
90 u32 bic_K; /* time to origin point from the beginning of the current epoch */ 90 u32 bic_K; /* time to origin point from the beginning of the current epoch */
91 u32 delay_min; /* min delay */ 91 u32 delay_min; /* min delay (msec << 3) */
92 u32 epoch_start; /* beginning of an epoch */ 92 u32 epoch_start; /* beginning of an epoch */
93 u32 ack_cnt; /* number of acks */ 93 u32 ack_cnt; /* number of acks */
94 u32 tcp_cwnd; /* estimated tcp cwnd */ 94 u32 tcp_cwnd; /* estimated tcp cwnd */
@@ -98,7 +98,7 @@ struct bictcp {
98 u8 found; /* the exit point is found? */ 98 u8 found; /* the exit point is found? */
99 u32 round_start; /* beginning of each round */ 99 u32 round_start; /* beginning of each round */
100 u32 end_seq; /* end_seq of the round */ 100 u32 end_seq; /* end_seq of the round */
101 u32 last_jiffies; /* last time when the ACK spacing is close */ 101 u32 last_ack; /* last time when the ACK spacing is close */
102 u32 curr_rtt; /* the minimum rtt of current round */ 102 u32 curr_rtt; /* the minimum rtt of current round */
103}; 103};
104 104
@@ -119,12 +119,21 @@ static inline void bictcp_reset(struct bictcp *ca)
119 ca->found = 0; 119 ca->found = 0;
120} 120}
121 121
122static inline u32 bictcp_clock(void)
123{
124#if HZ < 1000
125 return ktime_to_ms(ktime_get_real());
126#else
127 return jiffies_to_msecs(jiffies);
128#endif
129}
130
122static inline void bictcp_hystart_reset(struct sock *sk) 131static inline void bictcp_hystart_reset(struct sock *sk)
123{ 132{
124 struct tcp_sock *tp = tcp_sk(sk); 133 struct tcp_sock *tp = tcp_sk(sk);
125 struct bictcp *ca = inet_csk_ca(sk); 134 struct bictcp *ca = inet_csk_ca(sk);
126 135
127 ca->round_start = ca->last_jiffies = jiffies; 136 ca->round_start = ca->last_ack = bictcp_clock();
128 ca->end_seq = tp->snd_nxt; 137 ca->end_seq = tp->snd_nxt;
129 ca->curr_rtt = 0; 138 ca->curr_rtt = 0;
130 ca->sample_cnt = 0; 139 ca->sample_cnt = 0;
@@ -239,8 +248,8 @@ static inline void bictcp_update(struct bictcp *ca, u32 cwnd)
239 */ 248 */
240 249
241 /* change the unit from HZ to bictcp_HZ */ 250 /* change the unit from HZ to bictcp_HZ */
242 t = ((tcp_time_stamp + (ca->delay_min>>3) - ca->epoch_start) 251 t = ((tcp_time_stamp + msecs_to_jiffies(ca->delay_min>>3)
243 << BICTCP_HZ) / HZ; 252 - ca->epoch_start) << BICTCP_HZ) / HZ;
244 253
245 if (t < ca->bic_K) /* t - K */ 254 if (t < ca->bic_K) /* t - K */
246 offs = ca->bic_K - t; 255 offs = ca->bic_K - t;
@@ -342,14 +351,12 @@ static void hystart_update(struct sock *sk, u32 delay)
342 struct bictcp *ca = inet_csk_ca(sk); 351 struct bictcp *ca = inet_csk_ca(sk);
343 352
344 if (!(ca->found & hystart_detect)) { 353 if (!(ca->found & hystart_detect)) {
345 u32 curr_jiffies = jiffies; 354 u32 now = bictcp_clock();
346 355
347 /* first detection parameter - ack-train detection */ 356 /* first detection parameter - ack-train detection */
348 if ((s32)(curr_jiffies - ca->last_jiffies) <= 357 if ((s32)(now - ca->last_ack) <= hystart_ack_delta) {
349 msecs_to_jiffies(hystart_ack_delta)) { 358 ca->last_ack = now;
350 ca->last_jiffies = curr_jiffies; 359 if ((s32)(now - ca->round_start) > ca->delay_min >> 4)
351 if ((s32) (curr_jiffies - ca->round_start) >
352 ca->delay_min >> 4)
353 ca->found |= HYSTART_ACK_TRAIN; 360 ca->found |= HYSTART_ACK_TRAIN;
354 } 361 }
355 362
@@ -396,7 +403,7 @@ static void bictcp_acked(struct sock *sk, u32 cnt, s32 rtt_us)
396 if ((s32)(tcp_time_stamp - ca->epoch_start) < HZ) 403 if ((s32)(tcp_time_stamp - ca->epoch_start) < HZ)
397 return; 404 return;
398 405
399 delay = usecs_to_jiffies(rtt_us) << 3; 406 delay = (rtt_us << 3) / USEC_PER_MSEC;
400 if (delay == 0) 407 if (delay == 0)
401 delay = 1; 408 delay = 1;
402 409