Commit 8ea333eb authored by John Heffner's avatar John Heffner Committed by David S. Miller

[TCP]: Fix and simplify microsecond rtt sampling

This changes the microsecond RTT sampling so that samples are taken in
the same way that RTT samples are taken for the RTO calculator: on the
last segment acknowledged, and only when the segment hasn't been
retransmitted.
Signed-off-by: default avatarJohn Heffner <jheffner@psc.edu>
Acked-by: default avatarStephen Hemminger <shemminger@osdl.org>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent bfbea8a8
...@@ -2239,13 +2239,12 @@ static int tcp_tso_acked(struct sock *sk, struct sk_buff *skb, ...@@ -2239,13 +2239,12 @@ static int tcp_tso_acked(struct sock *sk, struct sk_buff *skb,
return acked; return acked;
} }
static u32 tcp_usrtt(const struct sk_buff *skb) static u32 tcp_usrtt(struct timeval *tv)
{ {
struct timeval tv, now; struct timeval now;
do_gettimeofday(&now); do_gettimeofday(&now);
skb_get_timestamp(skb, &tv); return (now.tv_sec - tv->tv_sec) * 1000000 + (now.tv_usec - tv->tv_usec);
return (now.tv_sec - tv.tv_sec) * 1000000 + (now.tv_usec - tv.tv_usec);
} }
/* Remove acknowledged frames from the retransmission queue. */ /* Remove acknowledged frames from the retransmission queue. */
...@@ -2260,6 +2259,7 @@ static int tcp_clean_rtx_queue(struct sock *sk, __s32 *seq_rtt_p) ...@@ -2260,6 +2259,7 @@ static int tcp_clean_rtx_queue(struct sock *sk, __s32 *seq_rtt_p)
u32 pkts_acked = 0; u32 pkts_acked = 0;
void (*rtt_sample)(struct sock *sk, u32 usrtt) void (*rtt_sample)(struct sock *sk, u32 usrtt)
= icsk->icsk_ca_ops->rtt_sample; = icsk->icsk_ca_ops->rtt_sample;
struct timeval tv;
while ((skb = skb_peek(&sk->sk_write_queue)) && while ((skb = skb_peek(&sk->sk_write_queue)) &&
skb != sk->sk_send_head) { skb != sk->sk_send_head) {
...@@ -2308,8 +2308,7 @@ static int tcp_clean_rtx_queue(struct sock *sk, __s32 *seq_rtt_p) ...@@ -2308,8 +2308,7 @@ static int tcp_clean_rtx_queue(struct sock *sk, __s32 *seq_rtt_p)
seq_rtt = -1; seq_rtt = -1;
} else if (seq_rtt < 0) { } else if (seq_rtt < 0) {
seq_rtt = now - scb->when; seq_rtt = now - scb->when;
if (rtt_sample) skb_get_timestamp(skb, &tv);
(*rtt_sample)(sk, tcp_usrtt(skb));
} }
if (sacked & TCPCB_SACKED_ACKED) if (sacked & TCPCB_SACKED_ACKED)
tp->sacked_out -= tcp_skb_pcount(skb); tp->sacked_out -= tcp_skb_pcount(skb);
...@@ -2322,8 +2321,7 @@ static int tcp_clean_rtx_queue(struct sock *sk, __s32 *seq_rtt_p) ...@@ -2322,8 +2321,7 @@ static int tcp_clean_rtx_queue(struct sock *sk, __s32 *seq_rtt_p)
} }
} else if (seq_rtt < 0) { } else if (seq_rtt < 0) {
seq_rtt = now - scb->when; seq_rtt = now - scb->when;
if (rtt_sample) skb_get_timestamp(skb, &tv);
(*rtt_sample)(sk, tcp_usrtt(skb));
} }
tcp_dec_pcount_approx(&tp->fackets_out, skb); tcp_dec_pcount_approx(&tp->fackets_out, skb);
tcp_packets_out_dec(tp, skb); tcp_packets_out_dec(tp, skb);
...@@ -2335,6 +2333,8 @@ static int tcp_clean_rtx_queue(struct sock *sk, __s32 *seq_rtt_p) ...@@ -2335,6 +2333,8 @@ static int tcp_clean_rtx_queue(struct sock *sk, __s32 *seq_rtt_p)
if (acked&FLAG_ACKED) { if (acked&FLAG_ACKED) {
tcp_ack_update_rtt(sk, acked, seq_rtt); tcp_ack_update_rtt(sk, acked, seq_rtt);
tcp_ack_packets_out(sk, tp); tcp_ack_packets_out(sk, tp);
if (rtt_sample && !(acked & FLAG_RETRANS_DATA_ACKED))
(*rtt_sample)(sk, tcp_usrtt(&tv));
if (icsk->icsk_ca_ops->pkts_acked) if (icsk->icsk_ca_ops->pkts_acked)
icsk->icsk_ca_ops->pkts_acked(sk, pkts_acked); icsk->icsk_ca_ops->pkts_acked(sk, pkts_acked);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment