Skip to content

Commit 42f3a8a

Browse files
edumazetdavem330
authored andcommitted
tcp_cubic: tweak Hystart detection for short RTT flows
After switching ca->delay_min to usec resolution, we exit slow start prematurely for very low RTT flows, setting snd_ssthresh to 20. The reason is that delay_min is fed with RTT of small packet trains. Then as cwnd is increased, TCP sends bigger TSO packets. LRO/GRO aggregation and/or interrupt mitigation strategies on receiver tend to inflate RTT samples. Fix this by adding to delay_min the expected delay of two TSO packets, given current pacing rate. Tested: Sender uses pfifo_fast qdisc Before : $ nstat -n;for f in {1..10}; do ./super_netperf 1 -H lpaa24 -l -4000000; done;nstat|egrep "Hystart" 11348 11707 11562 11428 11773 11534 9878 11693 10597 10968 TcpExtTCPHystartTrainDetect 10 0.0 TcpExtTCPHystartTrainCwnd 200 0.0 After : $ nstat -n;for f in {1..10}; do ./super_netperf 1 -H lpaa24 -l -4000000; done;nstat|egrep "Hystart" 14877 14517 15797 18466 17376 14833 17558 17933 16039 18059 TcpExtTCPHystartTrainDetect 10 0.0 TcpExtTCPHystartTrainCwnd 1670 0.0 Signed-off-by: Eric Dumazet <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent cff04e2 commit 42f3a8a

File tree

1 file changed

+21
-2
lines changed

1 file changed

+21
-2
lines changed

net/ipv4/tcp_cubic.c

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -436,8 +436,27 @@ static void bictcp_acked(struct sock *sk, const struct ack_sample *sample)
436436
delay = 1;
437437

438438
/* first time call or link delay decreases */
439-
if (ca->delay_min == 0 || ca->delay_min > delay)
440-
ca->delay_min = delay;
439+
if (ca->delay_min == 0 || ca->delay_min > delay) {
440+
unsigned long rate = READ_ONCE(sk->sk_pacing_rate);
441+
442+
/* Account for TSO/GRO delays.
443+
* Otherwise short RTT flows could get too small ssthresh,
444+
* since during slow start we begin with small TSO packets
445+
* and could lower ca->delay_min too much.
446+
* Ideally even with a very small RTT we would like to have
447+
* at least one TSO packet being sent and received by GRO,
448+
* and another one in qdisc layer.
449+
* We apply another 100% factor because @rate is doubled at
450+
* this point.
451+
* We cap the cushion to 1ms.
452+
*/
453+
if (rate)
454+
delay += min_t(u64, USEC_PER_MSEC,
455+
div64_ul((u64)GSO_MAX_SIZE *
456+
4 * USEC_PER_SEC, rate));
457+
if (ca->delay_min == 0 || ca->delay_min > delay)
458+
ca->delay_min = delay;
459+
}
441460

442461
/* hystart triggers when cwnd is larger than some threshold */
443462
if (!ca->found && hystart && tcp_in_slow_start(tp) &&

0 commit comments

Comments
 (0)