Skip to content

Commit 5f852eb

Browse files
edumazetdavem330
authored andcommitted
tcp: tso: remove tp->tso_deferred
TSO relies on ability to defer sending a small amount of packets. Heuristic is to wait for future ACKS in hope to send more packets at once. Current algorithm uses a per socket tso_deferred field as a pseudo timer. This pseudo timer relies on future ACK, but there is no guarantee we receive them in time. Fix would be to use a real timer, but cost of such timer is probably too expensive for typical cases. This patch changes the logic to test the time of last transmit, because we should not add bursts of more than 1ms for any given flow. We've used this patch for about two years at Google, before FQ/pacing as it would reduce a fair amount of bursts. Signed-off-by: Eric Dumazet <[email protected]> Signed-off-by: Yuchung Cheng <[email protected]> Signed-off-by: Neal Cardwell <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 6588af6 commit 5f852eb

File tree

2 files changed

+5
-10
lines changed

2 files changed

+5
-10
lines changed

include/linux/tcp.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -236,7 +236,6 @@ struct tcp_sock {
236236
u32 lost_out; /* Lost packets */
237237
u32 sacked_out; /* SACK'd packets */
238238
u32 fackets_out; /* FACK'd packets */
239-
u32 tso_deferred;
240239

241240
/* from STCP, retrans queue hinting */
242241
struct sk_buff* lost_skb_hint;

net/ipv4/tcp_output.c

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1763,9 +1763,10 @@ static bool tcp_tso_should_defer(struct sock *sk, struct sk_buff *skb,
17631763
if (icsk->icsk_ca_state != TCP_CA_Open)
17641764
goto send_now;
17651765

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

17711772
in_flight = tcp_packets_in_flight(tp);
@@ -1807,19 +1808,14 @@ static bool tcp_tso_should_defer(struct sock *sk, struct sk_buff *skb,
18071808
goto send_now;
18081809
}
18091810

1810-
/* Ok, it looks like it is advisable to defer.
1811-
* Do not rearm the timer if already set to not break TCP ACK clocking.
1812-
*/
1813-
if (!tp->tso_deferred)
1814-
tp->tso_deferred = 1 | (jiffies << 1);
1811+
/* Ok, it looks like it is advisable to defer. */
18151812

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

18191816
return true;
18201817

18211818
send_now:
1822-
tp->tso_deferred = 0;
18231819
return false;
18241820
}
18251821

0 commit comments

Comments
 (0)