Skip to content

Commit

Permalink
[TCP]: Bound TSO defer time
Browse files Browse the repository at this point in the history
This patch limits the amount of time you will defer sending a TSO segment
to less than two clock ticks, or the time between two acks, whichever is
longer.

On slow links, deferring causes significant bursts.  See attached plots,
which show RTT through a 1 Mbps link with a 100 ms RTT and ~100 ms queue
for (a) non-TSO, (b) currnet TSO, and (c) patched TSO.  This burstiness
causes significant jitter, tends to overflow queues early (bad for short
queues), and makes delay-based congestion control more difficult.

Deferring by a couple clock ticks I believe will have a relatively small
impact on performance.

Signed-off-by: John Heffner <jheffner@psc.edu>
Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
John Heffner authored and David S. Miller committed Oct 19, 2006
1 parent b52f070 commit ae8064a
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 5 deletions.
2 changes: 2 additions & 0 deletions include/linux/tcp.h
Original file line number Diff line number Diff line change
Expand Up @@ -342,6 +342,8 @@ struct tcp_sock {

unsigned long last_synq_overflow;

__u32 tso_deferred;

/* Receiver side RTT estimation */
struct {
__u32 rtt;
Expand Down
20 changes: 15 additions & 5 deletions net/ipv4/tcp_output.c
Original file line number Diff line number Diff line change
Expand Up @@ -1096,10 +1096,14 @@ static int tcp_tso_should_defer(struct sock *sk, struct tcp_sock *tp, struct sk_
u32 send_win, cong_win, limit, in_flight;

if (TCP_SKB_CB(skb)->flags & TCPCB_FLAG_FIN)
return 0;
goto send_now;

if (icsk->icsk_ca_state != TCP_CA_Open)
return 0;
goto send_now;

/* Defer for less than two clock ticks. */
if (!tp->tso_deferred && ((jiffies<<1)>>1) - (tp->tso_deferred>>1) > 1)
goto send_now;

in_flight = tcp_packets_in_flight(tp);

Expand All @@ -1115,7 +1119,7 @@ static int tcp_tso_should_defer(struct sock *sk, struct tcp_sock *tp, struct sk_

/* If a full-sized TSO skb can be sent, do it. */
if (limit >= 65536)
return 0;
goto send_now;

if (sysctl_tcp_tso_win_divisor) {
u32 chunk = min(tp->snd_wnd, tp->snd_cwnd * tp->mss_cache);
Expand All @@ -1125,19 +1129,25 @@ static int tcp_tso_should_defer(struct sock *sk, struct tcp_sock *tp, struct sk_
*/
chunk /= sysctl_tcp_tso_win_divisor;
if (limit >= chunk)
return 0;
goto send_now;
} else {
/* Different approach, try not to defer past a single
* ACK. Receiver should ACK every other full sized
* frame, so if we have space for more than 3 frames
* then send now.
*/
if (limit > tcp_max_burst(tp) * tp->mss_cache)
return 0;
goto send_now;
}

/* Ok, it looks like it is advisable to defer. */
tp->tso_deferred = 1 | (jiffies<<1);

return 1;

send_now:
tp->tso_deferred = 0;
return 0;
}

/* Create a new MTU probe if we are ready.
Expand Down

0 comments on commit ae8064a

Please sign in to comment.