Commit 91fed7a1 authored by Ilpo Järvinen's avatar Ilpo Järvinen Committed by David S. Miller

[TCP]: Make fackets_out accurate

Substraction for fackets_out is unconditional when snd_una
advances, thus there's no need to do it inside the loop. Just
make sure correct bounds are honored.
Signed-off-by: default avatarIlpo Järvinen <ilpo.jarvinen@helsinki.fi>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 0dde7b54
...@@ -2299,8 +2299,8 @@ tcp_fastretrans_alert(struct sock *sk, int pkts_acked, int flag) ...@@ -2299,8 +2299,8 @@ tcp_fastretrans_alert(struct sock *sk, int pkts_acked, int flag)
* 1. Reno does not count dupacks (sacked_out) automatically. */ * 1. Reno does not count dupacks (sacked_out) automatically. */
if (!tp->packets_out) if (!tp->packets_out)
tp->sacked_out = 0; tp->sacked_out = 0;
/* 2. SACK counts snd_fack in packets inaccurately. */
if (tp->sacked_out == 0) if (WARN_ON(!tp->sacked_out && tp->fackets_out))
tp->fackets_out = 0; tp->fackets_out = 0;
/* Now state machine starts. /* Now state machine starts.
...@@ -2568,10 +2568,6 @@ static int tcp_tso_acked(struct sock *sk, struct sk_buff *skb, ...@@ -2568,10 +2568,6 @@ static int tcp_tso_acked(struct sock *sk, struct sk_buff *skb,
} else if (*seq_rtt < 0) } else if (*seq_rtt < 0)
*seq_rtt = now - scb->when; *seq_rtt = now - scb->when;
if (tp->fackets_out) {
__u32 dval = min(tp->fackets_out, packets_acked);
tp->fackets_out -= dval;
}
/* hint's skb might be NULL but we don't need to care */ /* hint's skb might be NULL but we don't need to care */
tp->fastpath_cnt_hint -= min_t(u32, packets_acked, tp->fastpath_cnt_hint -= min_t(u32, packets_acked,
tp->fastpath_cnt_hint); tp->fastpath_cnt_hint);
...@@ -2657,7 +2653,6 @@ static int tcp_clean_rtx_queue(struct sock *sk, __s32 *seq_rtt_p) ...@@ -2657,7 +2653,6 @@ static int tcp_clean_rtx_queue(struct sock *sk, __s32 *seq_rtt_p)
seq_rtt = now - scb->when; seq_rtt = now - scb->when;
last_ackt = skb->tstamp; last_ackt = skb->tstamp;
} }
tcp_dec_pcount_approx(&tp->fackets_out, skb);
tp->packets_out -= tcp_skb_pcount(skb); tp->packets_out -= tcp_skb_pcount(skb);
tcp_unlink_write_queue(skb, sk); tcp_unlink_write_queue(skb, sk);
sk_stream_free_skb(sk, skb); sk_stream_free_skb(sk, skb);
...@@ -2672,6 +2667,7 @@ static int tcp_clean_rtx_queue(struct sock *sk, __s32 *seq_rtt_p) ...@@ -2672,6 +2667,7 @@ static int tcp_clean_rtx_queue(struct sock *sk, __s32 *seq_rtt_p)
tcp_ack_update_rtt(sk, acked, seq_rtt); tcp_ack_update_rtt(sk, acked, seq_rtt);
tcp_rearm_rto(sk); tcp_rearm_rto(sk);
tp->fackets_out -= min(pkts_acked, tp->fackets_out);
if (tcp_is_reno(tp)) if (tcp_is_reno(tp))
tcp_remove_reno_sacks(sk, pkts_acked); tcp_remove_reno_sacks(sk, pkts_acked);
......
...@@ -652,6 +652,26 @@ static void tcp_set_skb_tso_segs(struct sock *sk, struct sk_buff *skb, unsigned ...@@ -652,6 +652,26 @@ static void tcp_set_skb_tso_segs(struct sock *sk, struct sk_buff *skb, unsigned
} }
} }
/* When a modification to fackets out becomes necessary, we need to check
* skb is counted to fackets_out or not. Another important thing is to
* tweak SACK fastpath hint too as it would overwrite all changes unless
* hint is also changed.
*/
static void tcp_adjust_fackets_out(struct tcp_sock *tp, struct sk_buff *skb,
int decr)
{
if (!tp->sacked_out)
return;
if (!before(tp->highest_sack, TCP_SKB_CB(skb)->seq))
tp->fackets_out -= decr;
/* cnt_hint is "off-by-one" compared with fackets_out (see sacktag) */
if (tp->fastpath_skb_hint != NULL &&
after(TCP_SKB_CB(tp->fastpath_skb_hint)->seq, TCP_SKB_CB(skb)->seq))
tp->fastpath_cnt_hint -= decr;
}
/* Function to create two new TCP segments. Shrinks the given segment /* Function to create two new TCP segments. Shrinks the given segment
* to the specified size and appends a new segment with the rest of the * to the specified size and appends a new segment with the rest of the
* packet to the list. This won't be called frequently, I hope. * packet to the list. This won't be called frequently, I hope.
...@@ -746,21 +766,12 @@ int tcp_fragment(struct sock *sk, struct sk_buff *skb, u32 len, unsigned int mss ...@@ -746,21 +766,12 @@ int tcp_fragment(struct sock *sk, struct sk_buff *skb, u32 len, unsigned int mss
if (TCP_SKB_CB(skb)->sacked & TCPCB_LOST) if (TCP_SKB_CB(skb)->sacked & TCPCB_LOST)
tp->lost_out -= diff; tp->lost_out -= diff;
if (diff > 0) {
/* Adjust Reno SACK estimate. */ /* Adjust Reno SACK estimate. */
if (tcp_is_reno(tp)) { if (tcp_is_reno(tp) && diff > 0) {
tcp_dec_pcount_approx_int(&tp->sacked_out, diff); tcp_dec_pcount_approx_int(&tp->sacked_out, diff);
tcp_verify_left_out(tp); tcp_verify_left_out(tp);
} }
tcp_adjust_fackets_out(tp, skb, diff);
tcp_dec_pcount_approx_int(&tp->fackets_out, diff);
/* SACK fastpath might overwrite it unless dealt with */
if (tp->fastpath_skb_hint != NULL &&
after(TCP_SKB_CB(tp->fastpath_skb_hint)->seq,
TCP_SKB_CB(skb)->seq)) {
tcp_dec_pcount_approx_int(&tp->fastpath_cnt_hint, diff);
}
}
} }
/* Link BUFF into the send queue. */ /* Link BUFF into the send queue. */
...@@ -1746,10 +1757,7 @@ static void tcp_retrans_try_collapse(struct sock *sk, struct sk_buff *skb, int m ...@@ -1746,10 +1757,7 @@ static void tcp_retrans_try_collapse(struct sock *sk, struct sk_buff *skb, int m
if (tcp_is_reno(tp) && tp->sacked_out) if (tcp_is_reno(tp) && tp->sacked_out)
tcp_dec_pcount_approx(&tp->sacked_out, next_skb); tcp_dec_pcount_approx(&tp->sacked_out, next_skb);
/* Not quite right: it can be > snd.fack, but tcp_adjust_fackets_out(tp, skb, tcp_skb_pcount(next_skb));
* it is better to underestimate fackets.
*/
tcp_dec_pcount_approx(&tp->fackets_out, next_skb);
tp->packets_out -= tcp_skb_pcount(next_skb); tp->packets_out -= tcp_skb_pcount(next_skb);
sk_stream_free_skb(sk, next_skb); sk_stream_free_skb(sk, next_skb);
} }
......
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