Skip to content

Commit

Permalink
Merge branch 'tcp-tso'
Browse files Browse the repository at this point in the history
Eric Dumazet says:

====================
tcp: tso improvements

This patch serie reworks tcp_tso_should_defer() a bit
to get less bursts, and better ECN behavior.

We also removed tso_deferred field in tcp socket.
====================

Signed-off-by: David S. Miller <[email protected]>
  • Loading branch information
davem330 committed Feb 28, 2015
2 parents 6588af6 + a0ea700 commit f9c7ce1
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 13 deletions.
1 change: 0 additions & 1 deletion include/linux/tcp.h
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,6 @@ struct tcp_sock {
u32 lost_out; /* Lost packets */
u32 sacked_out; /* SACK'd packets */
u32 fackets_out; /* FACK'd packets */
u32 tso_deferred;

/* from STCP, retrans queue hinting */
struct sk_buff* lost_skb_hint;
Expand Down
29 changes: 17 additions & 12 deletions net/ipv4/tcp_output.c
Original file line number Diff line number Diff line change
Expand Up @@ -1752,20 +1752,23 @@ static int tso_fragment(struct sock *sk, struct sk_buff *skb, unsigned int len,
static bool tcp_tso_should_defer(struct sock *sk, struct sk_buff *skb,
bool *is_cwnd_limited, u32 max_segs)
{
struct tcp_sock *tp = tcp_sk(sk);
const struct inet_connection_sock *icsk = inet_csk(sk);
u32 send_win, cong_win, limit, in_flight;
u32 age, send_win, cong_win, limit, in_flight;
struct tcp_sock *tp = tcp_sk(sk);
struct skb_mstamp now;
struct sk_buff *head;
int win_divisor;

if (TCP_SKB_CB(skb)->tcp_flags & TCPHDR_FIN)
goto send_now;

if (icsk->icsk_ca_state != TCP_CA_Open)
if (!((1 << icsk->icsk_ca_state) & (TCPF_CA_Open | TCPF_CA_CWR)))
goto send_now;

/* Defer for less than two clock ticks. */
if (tp->tso_deferred &&
(((u32)jiffies << 1) >> 1) - (tp->tso_deferred >> 1) > 1)
/* Avoid bursty behavior by allowing defer
* only if the last write was recent.
*/
if ((s32)(tcp_time_stamp - tp->lsndtime) > 0)
goto send_now;

in_flight = tcp_packets_in_flight(tp);
Expand Down Expand Up @@ -1807,19 +1810,21 @@ static bool tcp_tso_should_defer(struct sock *sk, struct sk_buff *skb,
goto send_now;
}

/* Ok, it looks like it is advisable to defer.
* Do not rearm the timer if already set to not break TCP ACK clocking.
*/
if (!tp->tso_deferred)
tp->tso_deferred = 1 | (jiffies << 1);
head = tcp_write_queue_head(sk);
skb_mstamp_get(&now);
age = skb_mstamp_us_delta(&now, &head->skb_mstamp);
/* If next ACK is likely to come too late (half srtt), do not defer */
if (age < (tp->srtt_us >> 4))
goto send_now;

/* Ok, it looks like it is advisable to defer. */

if (cong_win < send_win && cong_win < skb->len)
*is_cwnd_limited = true;

return true;

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

Expand Down

0 comments on commit f9c7ce1

Please sign in to comment.