tcp: fix receive autotune again
Subsystems (5)
cover tcp: fix receive autotune again
Neal Cardwell found that recent kernels were having RWIN limited issues, even when net.ipv4.tcp_rmem[2] was set to a very big value like 512MB
He suspected that tcp_stream default buffer size (64KB) was triggering heuristic added in ea33537d8292 ("tcp: add receive queue awareness in tcp_rcv_space_adjust()").
After more testing, it turns out the bug was added earlier with commit 65c5287892e9 ("tcp: fix sk_rcvbuf overshoot").
I forgot once again that DRS has one RTT latency.
MPTCP also got the same issue.
This series :
- adds rcv_ssthresh, window_clamp and rcv_wnd to trace_tcp_rcvbuf_grow().
- Refactors code in a patch with no functional changes.
- Fixes the issue in the final patch.
Eric Dumazet (3):
trace: tcp: add three metrics to trace_tcp_rcvbuf_grow()
tcp: add newval parameter to tcp_rcvbuf_grow()
tcp: fix too slow tcp_rcvbuf_grow() action
include/net/tcp.h | 2 +- include/trace/events/tcp.h | 9 +++++++++ net/ipv4/tcp_input.c | 21 ++++++++++++++------- net/mptcp/protocol.c | 23 +++++++++++++++-------- 4 files changed, 39 insertions(+), 16 deletions(-)
Signature · 1 line
2.51.1.821.gb6fe4d2222-goog
PATCH 1/3 trace: tcp: add three metrics to trace_tcp_rcvbuf_grow()
While chasing yet another receive autotuning bug,
I found useful to add rcv_ssthresh, window_clamp and rcv_wnd.
tcp_stream 40597 [068] 2172.978198: tcp:tcp_rcvbuf_grow: time=50307 rtt_us=50179 copied=77824 inq=0 space=40960 ooo=0 scaling_ratio=219 rcvbuf=131072 rcv_ssthresh=107474 window_clamp=112128 rcv_wnd=110592 tcp_stream 40597 [068] 2173.028528: tcp:tcp_rcvbuf_grow: time=50336 rtt_us=50206 copied=110592 inq=0 space=77824 ooo=0 scaling_ratio=219 rcvbuf=509444 rcv_ssthresh=328658 window_clamp=435813 rcv_wnd=331776 tcp_stream 40597 [068] 2173.078830: tcp:tcp_rcvbuf_grow: time=50305 rtt_us=50070 copied=270336 inq=0 space=110592 ooo=0 scaling_ratio=219 rcvbuf=509444 rcv_ssthresh=431159 window_clamp=435813 rcv_wnd=434176 tcp_stream 40597 [068] 2173.129137: tcp:tcp_rcvbuf_grow: time=50313 rtt_us=50118 copied=434176 inq=0 space=270336 ooo=0 scaling_ratio=219 rcvbuf=2457847 rcv_ssthresh=1299511 window_clamp=2102611 rcv_wnd=1302528 tcp_stream 40597 [068] 2173.179451: tcp:tcp_rcvbuf_grow: time=50318 rtt_us=50041 copied=1019904 inq=0 space=434176 ooo=0 scaling_ratio=219 rcvbuf=2457847 rcv_ssthresh=2087445 window_clamp=2102611 rcv_wnd=2088960
--- include/trace/events/tcp.h | 9 +++++++++ 1 file changed, 9 insertions(+)
include/trace/events/tcp.h +9 -0
@@ -218,6 +218,9 @@ TRACE_EVENT(tcp_rcvbuf_grow, __field(__u32, space) __field(__u32, ooo_space) __field(__u32, rcvbuf) + __field(__u32, rcv_ssthresh) + __field(__u32, window_clamp) + __field(__u32, rcv_wnd) __field(__u8, scaling_ratio) __field(__u16, sport)__field (__u16, dport)
@@ -245,6 +248,9 @@ TRACE_EVENT(tcp_rcvbuf_grow, tp->rcv_nxt; __entry->rcvbuf = sk->sk_rcvbuf; + __entry->rcv_ssthresh = tp->rcv_ssthresh; + __entry->window_clamp = tp->window_clamp; + __entry->rcv_wnd = tp->rcv_wnd; __entry->scaling_ratio = tp->scaling_ratio; __entry->sport =ntohs (inet->inet_sport); __entry->dport =ntohs (inet->inet_dport);
@@ -264,11 +270,14 @@ TRACE_EVENT(tcp_rcvbuf_grow, ), TP_printk("time=%u rtt_us=%u copied=%u inq=%u space=%u ooo=%u scaling_ratio=%u rcvbuf=%u " + "rcv_ssthresh=%u window_clamp=%u rcv_wnd=%u " "family=%s sport=%hu dport=%hu saddr=%pI4 daddr=%pI4 " "saddrv6=%pI6c daddrv6=%pI6c skaddr=%p sock_cookie=%llx", __entry->time, __entry->rtt_us, __entry->copied, __entry->inq, __entry->space, __entry->ooo_space, __entry->scaling_ratio, __entry->rcvbuf, + __entry->rcv_ssthresh, __entry->window_clamp, + __entry->rcv_wnd, show_family_name(__entry->family), __entry->sport, __entry->dport, __entry->saddr, __entry->daddr,
Signature · 1 line
2.51.1.821.gb6fe4d2222-goog
PATCH 2/3 tcp: add newval parameter to tcp_rcvbuf_grow()
In reply to Eric DumazetThis patch has no functional change, and prepares the following one.
tcp_rcvbuf_grow() will need to have access to tp->rcvq_space.space old and new values.
Change mptcp_rcvbuf_grow() in a similar way.
--- include/net/tcp.h | 2 +- net/ipv4/tcp_input.c | 15 ++++++++------- net/mptcp/protocol.c | 16 ++++++++-------- 3 files changed, 17 insertions(+), 16 deletions(-)
include/net/tcp.h +1 -1
@@ -373,7 +373,7 @@ void tcp_delack_timer_handler(struct sock *sk);int tcp_ioctl (struct sock *sk,int cmd,int *karg);enum skb_drop_reason tcp_rcv_state_process (struct sock *sk,struct sk_buff *skb);void tcp_rcv_established (struct sock *sk,struct sk_buff *skb); -void tcp_rcvbuf_grow (struct sock *sk); +void tcp_rcvbuf_grow (struct sock *sk,u32 newval);void tcp_rcv_space_adjust (struct sock *sk);int tcp_twsk_unique (struct sock *sk,struct sock *sktw,void *twp);void tcp_twsk_destructor (struct sock *sk);
net/ipv4/tcp_input.c +8 -7
@@ -891,18 +891,21 @@ static inline void tcp_rcv_rtt_measure_ts(struct sock *sk, } } -void tcp_rcvbuf_grow (struct sock *sk) +void tcp_rcvbuf_grow (struct sock *sk,u32 newval) {const struct net *net =sock_net (sk);struct tcp_sock *tp =tcp_sk (sk); -int rcvwin, rcvbuf, cap; +u32 rcvwin, rcvbuf, cap, oldval; + + oldval = tp->rcvq_space.space; + tp->rcvq_space.space = newval;if (!READ_ONCE (net->ipv4.sysctl_tcp_moderate_rcvbuf) || (sk->sk_userlocks &SOCK_RCVBUF_LOCK ))return ;/* slow start: allow the sender to double its rate. */ - rcvwin = tp->rcvq_space.space <<1 ; + rcvwin = newval <<1 ;if (!RB_EMPTY_ROOT (&tp->out_of_order_queue)) rcvwin +=TCP_SKB_CB (tp->ooo_last_skb)->end_seq - tp->rcv_nxt;
@@ -943,9 +946,7 @@ void tcp_rcv_space_adjust(struct sock *sk)trace_tcp_rcvbuf_grow (sk, time); - tp->rcvq_space.space = copied; - -tcp_rcvbuf_grow (sk); +tcp_rcvbuf_grow (sk, copied); new_measure: tp->rcvq_space.seq = tp->copied_seq;
@@ -5270,7 +5271,7 @@ static void tcp_data_queue_ofo(struct sock *sk, struct sk_buff *skb) }/* do not grow rcvbuf for not-yet-accepted or orphaned sockets. */ if (sk->sk_socket) -tcp_rcvbuf_grow (sk); +tcp_rcvbuf_grow (sk, tp->rcvq_space.space); } static int __must_check tcp_queue_rcv(struct sock *sk, struct sk_buff *skb,
net/mptcp/protocol.c +8 -8
@@ -194,17 +194,19 @@ static bool mptcp_ooo_try_coalesce(struct mptcp_sock *msk, struct sk_buff *to,* - mptcp does not maintain a msk-level window clamp * - returns true when the receive buffer is actually updated */ -static bool mptcp_rcvbuf_grow (struct sock *sk) +static bool mptcp_rcvbuf_grow (struct sock *sk,u32 newval) {struct mptcp_sock *msk =mptcp_sk (sk);const struct net *net =sock_net (sk); -int rcvwin, rcvbuf, cap; +u32 rcvwin, rcvbuf, cap, oldval; + oldval = msk->rcvq_space.copied; + msk->rcvq_space.copied = newval;if (!READ_ONCE (net->ipv4.sysctl_tcp_moderate_rcvbuf) || (sk->sk_userlocks &SOCK_RCVBUF_LOCK ))return false; - rcvwin = msk->rcvq_space.space <<1 ; + rcvwin = newval <<1 ;if (!RB_EMPTY_ROOT (&msk->out_of_order_queue)) rcvwin +=MPTCP_SKB_CB (msk->ooo_last_skb)->end_seq - msk->ack_seq;
@@ -334,7 +336,7 @@ static void mptcp_data_queue_ofo(struct mptcp_sock *msk, struct sk_buff *skb)skb_set_owner_r (skb, sk);/* do not grow rcvbuf for not-yet-accepted or orphaned sockets. */ if (sk->sk_socket) -mptcp_rcvbuf_grow (sk); +mptcp_rcvbuf_grow (sk, msk->rcvq_space.space); } static void mptcp_init_skb(struct sock *ssk, struct sk_buff *skb, int offset,
@@ -2050,8 +2052,7 @@ static void mptcp_rcv_space_adjust(struct mptcp_sock *msk, int copied)if (msk->rcvq_space.copied <= msk->rcvq_space.space) goto new_measure; - msk->rcvq_space.space = msk->rcvq_space.copied; -if (mptcp_rcvbuf_grow (sk)) { +if (mptcp_rcvbuf_grow (sk, msk->rcvq_space.copied)) {/* Make subflows follow along. If we do not do this, we * get drops at subflow level if skbs can't be moved to
@@ -2064,8 +2065,7 @@ static void mptcp_rcv_space_adjust(struct mptcp_sock *msk, int copied) ssk =mptcp_subflow_tcp_sock (subflow); slow =lock_sock_fast (ssk); -tcp_sk (ssk)->rcvq_space.space = msk->rcvq_space.copied; -tcp_rcvbuf_grow (ssk); +tcp_rcvbuf_grow (ssk, msk->rcvq_space.copied);unlock_sock_fast (ssk, slow); } }
Signature · 1 line
2.51.1.821.gb6fe4d2222-goog
Paolo Abeni
maintainerRe: [PATCH net-next 2/3] tcp: add newval parameter to tcp_rcvbuf_grow()
Hi Eric,
Many thanks for tracking this down!
Recently we are observing mptcp selftests instabilities in simult_flows.sh, Geliang bisected them to e118cdc34dd1 ("mptcp: rcvbuf auto-tuning improvement") and the rcvbuf growing less. I *think* mptcp selftests provide some value even for plain tcp :)
Quoted 8 lines · Eric Dumazet
net/mptcp/protocol.c +0
-0@@ -194,17 +194,19 @@ static bool mptcp_ooo_try_coalesce(struct mptcp_sock *msk, struct sk_buff *to,* - mptcp does not maintain a msk-level window clamp * - returns true when the receive buffer is actually updated */
net/mptcp/protocol.c static bool mptcp_ooo_try_coalesce(struct mptcp_sock *msk, struct sk_buff *to, · line 204
Quoted 10 lines
net/mptcp/protocol.c +4
-2-static bool mptcp_rcvbuf_grow (struct sock *sk) +static bool mptcp_rcvbuf_grow (struct sock *sk,u32 newval) {struct mptcp_sock *msk =mptcp_sk (sk);const struct net *net =sock_net (sk); -int rcvwin, rcvbuf, cap; +u32 rcvwin, rcvbuf, cap, oldval; + oldval = msk->rcvq_space.copied; + msk->rcvq_space.copied = newval;
I *think* the above should be:
oldval = msk->rcvq_space.space; msk->rcvq_space.space = newval;
mptcp tracks the copied bytes incrementally - msk->rcvq_space.copied is updated at each rcvmesg() iteration - and such difference IMHO makes porting this kind of changes to mptcp a little more difficult.
If you prefer, I can take care of the mptcp bits afterwards - I'll also try to remove the mentioned difference and possibly move the algebra in a common helper.
Thanks,
Paolo
Re: [PATCH net-next 2/3] tcp: add newval parameter to tcp_rcvbuf_grow()
Quoted 27 lines · Paolo Abeni
Hi Eric,
Many thanks for tracking this down!
Recently we are observing mptcp selftests instabilities in
simult_flows.sh, Geliang bisected them toe118cdc34dd1("mptcp: rcvbuf auto-tuning improvement") and the rcvbuf growing less. I *think* mptcp selftests provide some value even for plain tcp :)Quoted 16 lines · Eric Dumazet
net/mptcp/protocol.c +2
-2@@ -194,17 +194,19 @@ static bool mptcp_ooo_try_coalesce(struct mptcp_sock *msk, struct sk_buff *to,* - mptcp does not maintain a msk-level window clamp * - returns true when the receive buffer is actually updated */ -static bool mptcp_rcvbuf_grow (struct sock *sk) +static bool mptcp_rcvbuf_grow (struct sock *sk,u32 newval) {struct mptcp_sock *msk =mptcp_sk (sk);const struct net *net =sock_net (sk); -int rcvwin, rcvbuf, cap; +u32 rcvwin, rcvbuf, cap, oldval;
Quoted 8 lines
net/mptcp/protocol.c static bool mptcp_ooo_try_coalesce(struct mptcp_sock *msk, struct sk_buff *to, · line 204
Quoted 2 lines
net/mptcp/protocol.c +2
-0+ oldval = msk->rcvq_space.copied; + msk->rcvq_space.copied = newval;I *think* the above should be:
oldval = msk->rcvq_space.space; msk->rcvq_space.space = newval;
You are right, thanks for catching this.
I developed / tested this series on a kernel where MPTCP changes were not there yet.
Only when rebasing to net-next I realized MPTCP had to be changed.
Quoted 7 lines
mptcp tracks the copied bytes incrementally -
msk->rcvq_space.copiedis updated at eachrcvmesg()iteration - and such difference IMHO makes porting this kind of changes to mptcp a little more difficult.If you prefer, I can take care of the mptcp bits afterwards - I'll also try to remove the mentioned difference and possibly move the algebra in a common helper.
Do you want me to split this patch in two parts or is it okay if I send a V2 with
the a/msk->rcvq_space.copied/msk->rcvq_space.space/ ?
Paolo Abeni
maintainerRe: [PATCH net-next 2/3] tcp: add newval parameter to tcp_rcvbuf_grow()
Quoted 38 lines · Eric Dumazet
Quoted 17 lines · Paolo Abeni
Quoted 16 lines · Eric Dumazet
net/mptcp/protocol.c +2
-2@@ -194,17 +194,19 @@ static bool mptcp_ooo_try_coalesce(struct mptcp_sock *msk, struct sk_buff *to,* - mptcp does not maintain a msk-level window clamp * - returns true when the receive buffer is actually updated */ -static bool mptcp_rcvbuf_grow (struct sock *sk) +static bool mptcp_rcvbuf_grow (struct sock *sk,u32 newval) {struct mptcp_sock *msk =mptcp_sk (sk);const struct net *net =sock_net (sk); -int rcvwin, rcvbuf, cap; +u32 rcvwin, rcvbuf, cap, oldval;Quoted 8 lines
net/mptcp/protocol.c static bool mptcp_ooo_try_coalesce(struct mptcp_sock *msk, struct sk_buff *to, · line 204
Quoted 2 lines
net/mptcp/protocol.c +2
-0+ oldval = msk->rcvq_space.copied; + msk->rcvq_space.copied = newval;I *think* the above should be:
oldval = msk->rcvq_space.space; msk->rcvq_space.space = newval;You are right, thanks for catching this.
I developed / tested this series on a kernel where MPTCP changes were not there yet.
Only when rebasing to net-next I realized MPTCP had to be changed.
Quoted 4 lines
mptcp tracks the copied bytes incrementally -
msk->rcvq_space.copiedis updated at eachrcvmesg()iteration - and such difference IMHO makes porting this kind of changes to mptcp a little more difficult.
Quoted 7 lines
Quoted 3 lines
If you prefer, I can take care of the mptcp bits afterwards - I'll also try to remove the mentioned difference and possibly move the algebra in a common helper.
Do you want me to split this patch in two parts or is it okay if I send a V2 with
the a/msk->rcvq_space.copied/msk->rcvq_space.space/ ?
I'm fine either way, please pick whatever fits you better. Given the strict interconnection between this specific mptcp and tcp bits, and thinking again about it, I now suspect splitting may harder and updating the patch as described above could be the better option.
Thanks,
Paolo
Matthieu Baerts
maintainerRe: [PATCH net-next 2/3] tcp: add newval parameter to tcp_rcvbuf_grow()
In reply to Eric DumazetHi Eric,
Quoted 37 lines · Eric Dumazet
Quoted 27 lines · Paolo Abeni
Hi Eric,
Many thanks for tracking this down!
Recently we are observing mptcp selftests instabilities in
simult_flows.sh, Geliang bisected them toe118cdc34dd1("mptcp: rcvbuf auto-tuning improvement") and the rcvbuf growing less. I *think* mptcp selftests provide some value even for plain tcp :)Quoted 16 lines · Eric Dumazet
net/mptcp/protocol.c +2
-2@@ -194,17 +194,19 @@ static bool mptcp_ooo_try_coalesce(struct mptcp_sock *msk, struct sk_buff *to,* - mptcp does not maintain a msk-level window clamp * - returns true when the receive buffer is actually updated */ -static bool mptcp_rcvbuf_grow (struct sock *sk) +static bool mptcp_rcvbuf_grow (struct sock *sk,u32 newval) {struct mptcp_sock *msk =mptcp_sk (sk);const struct net *net =sock_net (sk); -int rcvwin, rcvbuf, cap; +u32 rcvwin, rcvbuf, cap, oldval;Quoted 8 lines
net/mptcp/protocol.c static bool mptcp_ooo_try_coalesce(struct mptcp_sock *msk, struct sk_buff *to, · line 204
Quoted 2 lines
net/mptcp/protocol.c +2
-0+ oldval = msk->rcvq_space.copied; + msk->rcvq_space.copied = newval;I *think* the above should be:
oldval = msk->rcvq_space.space; msk->rcvq_space.space = newval;
Quoted 6 lines
You are right, thanks for catching this.
I developed / tested this series on a kernel where MPTCP changes were not there yet.
Only when rebasing to net-next I realized MPTCP had to be changed.
Thank you for the fix, and for having adapted MPTCP as well!
Quoted 11 lines
Quoted 7 lines
mptcp tracks the copied bytes incrementally -
msk->rcvq_space.copiedis updated at eachrcvmesg()iteration - and such difference IMHO makes porting this kind of changes to mptcp a little more difficult.If you prefer, I can take care of the mptcp bits afterwards - I'll also try to remove the mentioned difference and possibly move the algebra in a common helper.
Do you want me to split this patch in two parts or is it okay if I send a V2 with
the a/msk->rcvq_space.copied/msk->rcvq_space.space/ ?
If you send a v2, could it eventually target "net" instead please?
If the idea is to delay the fix to stable, it is always possible to ask the stable team to backport it to stable in a few weeks / months, e.g.
Cheers,
Matt
Signature · 1 line
Sponsored by the NGI0 Core fund.
Re: [PATCH net-next 2/3] tcp: add newval parameter to tcp_rcvbuf_grow()
Quoted 62 lines · Matthieu Baerts
Hi Eric,
Quoted 37 lines · Eric Dumazet
Quoted 27 lines · Paolo Abeni
Hi Eric,
Many thanks for tracking this down!
Recently we are observing mptcp selftests instabilities in
simult_flows.sh, Geliang bisected them toe118cdc34dd1("mptcp: rcvbuf auto-tuning improvement") and the rcvbuf growing less. I *think* mptcp selftests provide some value even for plain tcp :)Quoted 16 lines · Eric Dumazet
net/mptcp/protocol.c +2
-2@@ -194,17 +194,19 @@ static bool mptcp_ooo_try_coalesce(struct mptcp_sock *msk, struct sk_buff *to,* - mptcp does not maintain a msk-level window clamp * - returns true when the receive buffer is actually updated */ -static bool mptcp_rcvbuf_grow (struct sock *sk) +static bool mptcp_rcvbuf_grow (struct sock *sk,u32 newval) {struct mptcp_sock *msk =mptcp_sk (sk);const struct net *net =sock_net (sk); -int rcvwin, rcvbuf, cap; +u32 rcvwin, rcvbuf, cap, oldval;Quoted 8 lines
net/mptcp/protocol.c static bool mptcp_ooo_try_coalesce(struct mptcp_sock *msk, struct sk_buff *to, · line 204
Quoted 2 lines
net/mptcp/protocol.c +2
-0+ oldval = msk->rcvq_space.copied; + msk->rcvq_space.copied = newval;I *think* the above should be:
oldval = msk->rcvq_space.space; msk->rcvq_space.space = newval;Quoted 6 lines
You are right, thanks for catching this.
I developed / tested this series on a kernel where MPTCP changes were not there yet.
Only when rebasing to net-next I realized MPTCP had to be changed.
Thank you for the fix, and for having adapted MPTCP as well!
Quoted 11 lines
Quoted 7 lines
mptcp tracks the copied bytes incrementally -
msk->rcvq_space.copiedis updated at eachrcvmesg()iteration - and such difference IMHO makes porting this kind of changes to mptcp a little more difficult.If you prefer, I can take care of the mptcp bits afterwards - I'll also try to remove the mentioned difference and possibly move the algebra in a common helper.
Do you want me to split this patch in two parts or is it okay if I send a V2 with
the a/msk->rcvq_space.copied/msk->rcvq_space.space/ ?
Quoted 7 lines
If you send a v2, could it eventually target "net" instead please?
If the idea is to delay the fix to stable, it is always possible to ask the stable team to backport it to stable in a few weeks / months, e.g.
Cc <[email protected]> # after -rc6
I usually stack multiple patches, and net-next allows for less merge conflicts.
See for instance
https://lore.kernel.org/netdev/[email protected]/T/#u
which touches tcp_rcv_space_adjust(), and definitely net-next candidate.
Bug was added 5 months ago, and does not seem critical to me (otherwise we would have caught it much much earlier) ?
Truth be told, I had first to fix TSO defer code, and thought the fix was not good enough.
Re: [PATCH net-next 2/3] tcp: add newval parameter to tcp_rcvbuf_grow()
Quoted 9 lines · Eric Dumazet
I usually stack multiple patches, and net-next allows for less merge conflicts.
See for instance
https://lore.kernel.org/netdev/[email protected]/T/#u
which touchestcp_rcv_space_adjust(), and definitely net-next candidate.
Quoted 5 lines
Bug was added 5 months ago, and does not seem critical to me (otherwise we would have caught it much much earlier) ?
Truth be told, I had first to fix TSO defer code, and thought the fix was not good enough.
To clarify, I will send the V2 targeting net tree, since you asked for it ;)
Matthieu Baerts
maintainerRe: [PATCH net-next 2/3] tcp: add newval parameter to tcp_rcvbuf_grow()
Quoted 10 lines · Eric Dumazet
Quoted 9 lines · Eric Dumazet
I usually stack multiple patches, and net-next allows for less merge conflicts.
See for instance
https://lore.kernel.org/netdev/[email protected]/T/#u
which touchestcp_rcv_space_adjust(), and definitely net-next candidate.
Quoted 7 lines
Quoted 5 lines
Bug was added 5 months ago, and does not seem critical to me (otherwise we would have caught it much much earlier) ?
Truth be told, I had first to fix TSO defer code, and thought the fix was not good enough.
To clarify, I will send the V2 targeting net tree, since you asked for it ;)
Thank you very much!
Note that the bug was apparently more visible with MPTCP, but only since a few weeks ago, after the modifications on MPTCP side. When I looked at the issue, I didn't suspect anything wrong on the algorithm that was copied from TCP side, because this original code was there for a few months (and its author is very trustable :) ). So again, thank you for having fixed that!
Cheers,
Matt
Signature · 1 line
Sponsored by the NGI0 Core fund.
Geliang Tang
reviewerRe: [PATCH net-next 2/3] tcp: add newval parameter to tcp_rcvbuf_grow()
Hi Eric, Paolo, Matt,
Quoted 26 lines · Matthieu Baerts
Quoted 16 lines · Eric Dumazet
Quoted 14 lines · Eric Dumazet
I usually stack multiple patches, and net-next allows for less merge conflicts.
See for instance
https://lore.kernel.org/netdev/[email protected]/T/#u
which touchestcp_rcv_space_adjust(), and definitely net-next candidate.Bug was added 5 months ago, and does not seem critical to me (otherwise we would have caught it much much earlier) ?
Quoted 6 lines
Quoted 3 lines
Truth be told, I had first to fix TSO defer code, and thought the fix
was not good enough.To clarify, I will send the V2 targeting net tree, since you asked for it ;)
Thank you very much!
Quoted 9 lines
Note that the bug was apparently more visible with MPTCP, but only since
a few weeks ago, after the modifications on MPTCP side. When I looked at
the issue, I didn't suspect anything wrong on the algorithm that was copied from TCP side, because this original code was there for a few months (and its author is very trustable :) ). So again, thank you for
having fixed that!
I have just tested and confirmed that this series, together with Paolo's correction (changing msk->rcvq_space.copied to msk-
Quoted 1 line
rcvq_space.space in
mptcp_rcvbuf_grow()), fixes thesimult_flows.sh
issue mentioned in [1].
Thanks,
-Geliang
[1]
https://github.com/multipath-tcp/mptcp_net-next/issues/589
Quoted 3 lines
Cheers,
Matt
PATCH 3/3 tcp: fix too slow tcp_rcvbuf_grow() action
In reply to Eric DumazetWhile the blamed commits apparently avoided an overshoot, they also limited how fast a sender can increase BDP at each RTT.
This is not exactly a revert, we do not add the 16 * tp->advmss cushion we had, and we are keeping the out_of_order_queue contribution.
Do the same in mptcp_rcvbuf_grow().
Tested:
emulated 50ms rtt (tcp_stream --tcp-tx-delay 50000), cubic 20 second flow. net.ipv4.tcp_rmem set to "4096 131072 67000000"
perf record -a -e tcp:tcp_rcvbuf_grow sleep 20
perf script
Before:
We can see we fail to roughly double RWIN at each RTT.
Sender is RWIN limited while CWND is ramping up (before getting tcp_wmem limited)
tcp_stream 33793 [010] 825.717525: tcp:tcp_rcvbuf_grow: time=100869 rtt_us=50428 copied=49152 inq=0 space=40960 ooo=0 scaling_ratio=219 rcvbuf=131072 rcv_ssthresh=103970 window_clamp=112128 rcv_wnd=106496 tcp_stream 33793 [010] 825.768966: tcp:tcp_rcvbuf_grow: time=51447 rtt_us=50362 copied=86016 inq=0 space=49152 ooo=0 scaling_ratio=219 rcvbuf=131072 rcv_ssthresh=107474 window_clamp=112128 rcv_wnd=106496 tcp_stream 33793 [010] 825.821539: tcp:tcp_rcvbuf_grow: time=52577 rtt_us=50243 copied=114688 inq=0 space=86016 ooo=0 scaling_ratio=219 rcvbuf=201096 rcv_ssthresh=167377 window_clamp=172031 rcv_wnd=167936 tcp_stream 33793 [010] 825.871781: tcp:tcp_rcvbuf_grow: time=50248 rtt_us=50237 copied=167936 inq=0 space=114688 ooo=0 scaling_ratio=219 rcvbuf=268129 rcv_ssthresh=224722 window_clamp=229375 rcv_wnd=225280 tcp_stream 33793 [010] 825.922475: tcp:tcp_rcvbuf_grow: time=50698 rtt_us=50183 copied=241664 inq=0 space=167936 ooo=0 scaling_ratio=219 rcvbuf=392617 rcv_ssthresh=331217 window_clamp=335871 rcv_wnd=323584 tcp_stream 33793 [010] 825.973326: tcp:tcp_rcvbuf_grow: time=50855 rtt_us=50213 copied=339968 inq=0 space=241664 ooo=0 scaling_ratio=219 rcvbuf=564986 rcv_ssthresh=478674 window_clamp=483327 rcv_wnd=462848 tcp_stream 33793 [010] 826.023970: tcp:tcp_rcvbuf_grow: time=50647 rtt_us=50248 copied=491520 inq=0 space=339968 ooo=0 scaling_ratio=219 rcvbuf=794811 rcv_ssthresh=671778 window_clamp=679935 rcv_wnd=651264 tcp_stream 33793 [010] 826.074612: tcp:tcp_rcvbuf_grow: time=50648 rtt_us=50227 copied=700416 inq=0 space=491520 ooo=0 scaling_ratio=219 rcvbuf=1149124 rcv_ssthresh=974881 window_clamp=983039 rcv_wnd=942080 tcp_stream 33793 [010] 826.125452: tcp:tcp_rcvbuf_grow: time=50845 rtt_us=50225 copied=987136 inq=8192 space=700416 ooo=0 scaling_ratio=219 rcvbuf=1637502 rcv_ssthresh=1392674 window_clamp=1400831 rcv_wnd=1339392 tcp_stream 33793 [010] 826.175698: tcp:tcp_rcvbuf_grow: time=50250 rtt_us=50198 copied=1347584 inq=0 space=978944 ooo=0 scaling_ratio=219 rcvbuf=2288672 rcv_ssthresh=1949729 window_clamp=1957887 rcv_wnd=1945600 tcp_stream 33793 [010] 826.225947: tcp:tcp_rcvbuf_grow: time=50252 rtt_us=50240 copied=1945600 inq=0 space=1347584 ooo=0 scaling_ratio=219 rcvbuf=3150516 rcv_ssthresh=2687010 window_clamp=2695167 rcv_wnd=2691072 tcp_stream 33793 [010] 826.276175: tcp:tcp_rcvbuf_grow: time=50233 rtt_us=50224 copied=2691072 inq=0 space=1945600 ooo=0 scaling_ratio=219 rcvbuf=4548617 rcv_ssthresh=3883041 window_clamp=3891199 rcv_wnd=3887104 tcp_stream 33793 [010] 826.326403: tcp:tcp_rcvbuf_grow: time=50233 rtt_us=50229 copied=3887104 inq=0 space=2691072 ooo=0 scaling_ratio=219 rcvbuf=6291456 rcv_ssthresh=5370482 window_clamp=5382144 rcv_wnd=5373952 tcp_stream 33793 [010] 826.376723: tcp:tcp_rcvbuf_grow: time=50323 rtt_us=50218 copied=5373952 inq=0 space=3887104 ooo=0 scaling_ratio=219 rcvbuf=9087658 rcv_ssthresh=7755537 window_clamp=7774207 rcv_wnd=7757824 tcp_stream 33793 [010] 826.426991: tcp:tcp_rcvbuf_grow: time=50274 rtt_us=50196 copied=7757824 inq=180224 space=5373952 ooo=0 scaling_ratio=219 rcvbuf=12563759 rcv_ssthresh=10729233 window_clamp=10747903 rcv_wnd=10575872 tcp_stream 33793 [010] 826.477229: tcp:tcp_rcvbuf_grow: time=50241 rtt_us=50078 copied=10731520 inq=180224 space=7577600 ooo=0 scaling_ratio=219 rcvbuf=17715667 rcv_ssthresh=15136529 window_clamp=15155199 rcv_wnd=14983168 tcp_stream 33793 [010] 826.527482: tcp:tcp_rcvbuf_grow: time=50258 rtt_us=50153 copied=15138816 inq=360448 space=10551296 ooo=0 scaling_ratio=219 rcvbuf=24667870 rcv_ssthresh=21073410 window_clamp=21102591 rcv_wnd=20766720 tcp_stream 33793 [010] 826.577712: tcp:tcp_rcvbuf_grow: time=50234 rtt_us=50228 copied=21073920 inq=0 space=14778368 ooo=0 scaling_ratio=219 rcvbuf=34550339 rcv_ssthresh=29517041 window_clamp=29556735 rcv_wnd=29519872 tcp_stream 33793 [010] 826.627982: tcp:tcp_rcvbuf_grow: time=50275 rtt_us=50220 copied=29519872 inq=540672 space=21073920 ooo=0 scaling_ratio=219 rcvbuf=49268707 rcv_ssthresh=42090625 window_clamp=42147839 rcv_wnd=41627648 tcp_stream 33793 [010] 826.678274: tcp:tcp_rcvbuf_grow: time=50296 rtt_us=50185 copied=42053632 inq=761856 space=28979200 ooo=0 scaling_ratio=219 rcvbuf=67000000 rcv_ssthresh=57238168 window_clamp=57316406 rcv_wnd=56606720 tcp_stream 33793 [010] 826.728627: tcp:tcp_rcvbuf_grow: time=50357 rtt_us=50128 copied=43913216 inq=851968 space=41291776 ooo=0 scaling_ratio=219 rcvbuf=67000000 rcv_ssthresh=57290728 window_clamp=57316406 rcv_wnd=56524800 tcp_stream 33793 [010] 827.131364: tcp:tcp_rcvbuf_grow: time=50239 rtt_us=50127 copied=43843584 inq=655360 space=43061248 ooo=0 scaling_ratio=219 rcvbuf=67000000 rcv_ssthresh=57290728 window_clamp=57316406 rcv_wnd=56696832 tcp_stream 33793 [010] 827.181613: tcp:tcp_rcvbuf_grow: time=50254 rtt_us=50115 copied=43843584 inq=524288 space=43188224 ooo=0 scaling_ratio=219 rcvbuf=67000000 rcv_ssthresh=57290728 window_clamp=57316406 rcv_wnd=56807424 tcp_stream 33793 [010] 828.339635: tcp:tcp_rcvbuf_grow: time=50283 rtt_us=50110 copied=43843584 inq=458752 space=43319296 ooo=0 scaling_ratio=219 rcvbuf=67000000 rcv_ssthresh=57290728 window_clamp=57316406 rcv_wnd=56864768 tcp_stream 33793 [010] 828.440350: tcp:tcp_rcvbuf_grow: time=50404 rtt_us=50099 copied=43843584 inq=393216 space=43384832 ooo=0 scaling_ratio=219 rcvbuf=67000000 rcv_ssthresh=57290728 window_clamp=57316406 rcv_wnd=56922112 tcp_stream 33793 [010] 829.195106: tcp:tcp_rcvbuf_grow: time=50154 rtt_us=50077 copied=43843584 inq=196608 space=43450368 ooo=0 scaling_ratio=219 rcvbuf=67000000 rcv_ssthresh=57290728 window_clamp=57316406 rcv_wnd=57090048
After:
It takes few steps to increase RWIN. Sender is no longer RWIN limited.
tcp_stream 50826 [010] 935.634212: tcp:tcp_rcvbuf_grow: time=100788 rtt_us=50315 copied=49152 inq=0 space=40960 ooo=0 scaling_ratio=219 rcvbuf=131072 rcv_ssthresh=103970 window_clamp=112128 rcv_wnd=106496 tcp_stream 50826 [010] 935.685642: tcp:tcp_rcvbuf_grow: time=51437 rtt_us=50361 copied=86016 inq=0 space=49152 ooo=0 scaling_ratio=219 rcvbuf=160875 rcv_ssthresh=132969 window_clamp=137623 rcv_wnd=131072 tcp_stream 50826 [010] 935.738299: tcp:tcp_rcvbuf_grow: time=52660 rtt_us=50256 copied=139264 inq=0 space=86016 ooo=0 scaling_ratio=219 rcvbuf=502741 rcv_ssthresh=411497 window_clamp=430079 rcv_wnd=413696 tcp_stream 50826 [010] 935.788544: tcp:tcp_rcvbuf_grow: time=50249 rtt_us=50233 copied=307200 inq=0 space=139264 ooo=0 scaling_ratio=219 rcvbuf=728690 rcv_ssthresh=618717 window_clamp=623371 rcv_wnd=618496 tcp_stream 50826 [010] 935.838796: tcp:tcp_rcvbuf_grow: time=50258 rtt_us=50202 copied=618496 inq=0 space=307200 ooo=0 scaling_ratio=219 rcvbuf=2450338 rcv_ssthresh=1855709 window_clamp=2096187 rcv_wnd=1859584 tcp_stream 50826 [010] 935.889140: tcp:tcp_rcvbuf_grow: time=50347 rtt_us=50166 copied=1261568 inq=0 space=618496 ooo=0 scaling_ratio=219 rcvbuf=4376503 rcv_ssthresh=3725291 window_clamp=3743961 rcv_wnd=3706880 tcp_stream 50826 [010] 935.939435: tcp:tcp_rcvbuf_grow: time=50300 rtt_us=50185 copied=2478080 inq=24576 space=1261568 ooo=0 scaling_ratio=219 rcvbuf=9082648 rcv_ssthresh=7733731 window_clamp=7769921 rcv_wnd=7692288 tcp_stream 50826 [010] 935.989681: tcp:tcp_rcvbuf_grow: time=50251 rtt_us=50221 copied=4915200 inq=114688 space=2453504 ooo=0 scaling_ratio=219 rcvbuf=16574936 rcv_ssthresh=14108110 window_clamp=14179339 rcv_wnd=14024704 tcp_stream 50826 [010] 936.039967: tcp:tcp_rcvbuf_grow: time=50289 rtt_us=50279 copied=9830400 inq=114688 space=4800512 ooo=0 scaling_ratio=219 rcvbuf=32695050 rcv_ssthresh=27896187 window_clamp=27969593 rcv_wnd=27815936 tcp_stream 50826 [010] 936.090172: tcp:tcp_rcvbuf_grow: time=50211 rtt_us=50200 copied=19841024 inq=114688 space=9715712 ooo=0 scaling_ratio=219 rcvbuf=67000000 rcv_ssthresh=57245176 window_clamp=57316406 rcv_wnd=57163776 tcp_stream 50826 [010] 936.140430: tcp:tcp_rcvbuf_grow: time=50262 rtt_us=50197 copied=39501824 inq=114688 space=19726336 ooo=0 scaling_ratio=219 rcvbuf=67000000 rcv_ssthresh=57245176 window_clamp=57316406 rcv_wnd=57163776 tcp_stream 50826 [010] 936.190527: tcp:tcp_rcvbuf_grow: time=50101 rtt_us=50071 copied=43655168 inq=262144 space=39387136 ooo=0 scaling_ratio=219 rcvbuf=67000000 rcv_ssthresh=57259192 window_clamp=57316406 rcv_wnd=57032704 tcp_stream 50826 [010] 936.240719: tcp:tcp_rcvbuf_grow: time=50197 rtt_us=50057 copied=43843584 inq=262144 space=43393024 ooo=0 scaling_ratio=219 rcvbuf=67000000 rcv_ssthresh=57259192 window_clamp=57316406 rcv_wnd=57032704 tcp_stream 50826 [010] 936.341271: tcp:tcp_rcvbuf_grow: time=50297 rtt_us=50123 copied=43843584 inq=131072 space=43581440 ooo=0 scaling_ratio=219 rcvbuf=67000000 rcv_ssthresh=57259192 window_clamp=57316406 rcv_wnd=57147392 tcp_stream 50826 [010] 936.642503: tcp:tcp_rcvbuf_grow: time=50131 rtt_us=50084 copied=43843584 inq=0 space=43712512 ooo=0 scaling_ratio=219 rcvbuf=67000000 rcv_ssthresh=57259192 window_clamp=57316406 rcv_wnd=57262080
--- net/ipv4/tcp_input.c | 8 +++++++- net/mptcp/protocol.c | 7 +++++++ 2 files changed, 14 insertions(+), 1 deletion(-)
net/ipv4/tcp_input.c +7 -1
@@ -896,6 +896,7 @@ void tcp_rcvbuf_grow(struct sock *sk, u32 newval)const struct net *net =sock_net (sk);struct tcp_sock *tp =tcp_sk (sk);u32 rcvwin, rcvbuf, cap, oldval; +u64 grow; oldval = tp->rcvq_space.space; tp->rcvq_space.space = newval;
@@ -904,9 +905,14 @@ void tcp_rcvbuf_grow(struct sock *sk, u32 newval) (sk->sk_userlocks & SOCK_RCVBUF_LOCK))return ; -/* slow start: allow the sender to double its rate. */ +/* DRS is always one RTT late. */ rcvwin = newval <<1 ; +/* slow start: allow the sender to double its rate. */ + grow = (u64 )rcvwin * (newval - oldval); +do_div (grow, oldval); + rcvwin += grow <<1 ; +if (!RB_EMPTY_ROOT (&tp->out_of_order_queue)) rcvwin +=TCP_SKB_CB (tp->ooo_last_skb)->end_seq - tp->rcv_nxt;
net/mptcp/protocol.c +7 -0
@@ -199,6 +199,7 @@ static bool mptcp_rcvbuf_grow(struct sock *sk, u32 newval)struct mptcp_sock *msk =mptcp_sk (sk);const struct net *net =sock_net (sk);u32 rcvwin, rcvbuf, cap, oldval; +u64 grow; oldval = msk->rcvq_space.copied; msk->rcvq_space.copied = newval;
@@ -206,8 +207,14 @@ static bool mptcp_rcvbuf_grow(struct sock *sk, u32 newval) (sk->sk_userlocks & SOCK_RCVBUF_LOCK))return false; +/* DRS is always one RTT late. */ rcvwin = newval <<1 ; +/* slow start: allow the sender to double its rate. */ + grow = (u64 )rcvwin * (newval - oldval); +do_div (grow, oldval); + rcvwin += grow <<1 ; +if (!RB_EMPTY_ROOT (&msk->out_of_order_queue)) rcvwin +=MPTCP_SKB_CB (msk->ooo_last_skb)->end_seq - msk->ack_seq;
Signature · 1 line
2.51.1.821.gb6fe4d2222-goog
Re: [PATCH net-next 3/3] tcp: fix too slow tcp_rcvbuf_grow() action
Quoted 96 lines · Eric Dumazet
While the blamed commits apparently avoided an overshoot, they also limited how fast a sender can increase BDP at each RTT.
This is not exactly a revert, we do not add the 16 *
tp->advmsscushion we had, and we are keeping theout_of_order_queuecontribution.Do the same in
mptcp_rcvbuf_grow().Tested:
emulated 50ms rtt (
tcp_stream--tcp-tx-delay 50000), cubic 20 second flow. net.ipv4.tcp_rmem set to "4096 131072 67000000"perf record -a -e tcp:tcp_rcvbuf_grow sleep 20
perf scriptBefore:
We can see we fail to roughly double RWIN at each RTT.
Sender is RWIN limited while CWND is ramping up (before gettingtcp_wmemlimited)tcp_stream 33793 [010] 825.717525: tcp:tcp_rcvbuf_grow: time=100869 rtt_us=50428 copied=49152 inq=0 space=40960 ooo=0 scaling_ratio=219 rcvbuf=131072 rcv_ssthresh=103970 window_clamp=112128 rcv_wnd=106496 tcp_stream 33793 [010] 825.768966: tcp:tcp_rcvbuf_grow: time=51447 rtt_us=50362 copied=86016 inq=0 space=49152 ooo=0 scaling_ratio=219 rcvbuf=131072 rcv_ssthresh=107474 window_clamp=112128 rcv_wnd=106496 tcp_stream 33793 [010] 825.821539: tcp:tcp_rcvbuf_grow: time=52577 rtt_us=50243 copied=114688 inq=0 space=86016 ooo=0 scaling_ratio=219 rcvbuf=201096 rcv_ssthresh=167377 window_clamp=172031 rcv_wnd=167936 tcp_stream 33793 [010] 825.871781: tcp:tcp_rcvbuf_grow: time=50248 rtt_us=50237 copied=167936 inq=0 space=114688 ooo=0 scaling_ratio=219 rcvbuf=268129 rcv_ssthresh=224722 window_clamp=229375 rcv_wnd=225280 tcp_stream 33793 [010] 825.922475: tcp:tcp_rcvbuf_grow: time=50698 rtt_us=50183 copied=241664 inq=0 space=167936 ooo=0 scaling_ratio=219 rcvbuf=392617 rcv_ssthresh=331217 window_clamp=335871 rcv_wnd=323584 tcp_stream 33793 [010] 825.973326: tcp:tcp_rcvbuf_grow: time=50855 rtt_us=50213 copied=339968 inq=0 space=241664 ooo=0 scaling_ratio=219 rcvbuf=564986 rcv_ssthresh=478674 window_clamp=483327 rcv_wnd=462848 tcp_stream 33793 [010] 826.023970: tcp:tcp_rcvbuf_grow: time=50647 rtt_us=50248 copied=491520 inq=0 space=339968 ooo=0 scaling_ratio=219 rcvbuf=794811 rcv_ssthresh=671778 window_clamp=679935 rcv_wnd=651264 tcp_stream 33793 [010] 826.074612: tcp:tcp_rcvbuf_grow: time=50648 rtt_us=50227 copied=700416 inq=0 space=491520 ooo=0 scaling_ratio=219 rcvbuf=1149124 rcv_ssthresh=974881 window_clamp=983039 rcv_wnd=942080 tcp_stream 33793 [010] 826.125452: tcp:tcp_rcvbuf_grow: time=50845 rtt_us=50225 copied=987136 inq=8192 space=700416 ooo=0 scaling_ratio=219 rcvbuf=1637502 rcv_ssthresh=1392674 window_clamp=1400831 rcv_wnd=1339392 tcp_stream 33793 [010] 826.175698: tcp:tcp_rcvbuf_grow: time=50250 rtt_us=50198 copied=1347584 inq=0 space=978944 ooo=0 scaling_ratio=219 rcvbuf=2288672 rcv_ssthresh=1949729 window_clamp=1957887 rcv_wnd=1945600 tcp_stream 33793 [010] 826.225947: tcp:tcp_rcvbuf_grow: time=50252 rtt_us=50240 copied=1945600 inq=0 space=1347584 ooo=0 scaling_ratio=219 rcvbuf=3150516 rcv_ssthresh=2687010 window_clamp=2695167 rcv_wnd=2691072 tcp_stream 33793 [010] 826.276175: tcp:tcp_rcvbuf_grow: time=50233 rtt_us=50224 copied=2691072 inq=0 space=1945600 ooo=0 scaling_ratio=219 rcvbuf=4548617 rcv_ssthresh=3883041 window_clamp=3891199 rcv_wnd=3887104 tcp_stream 33793 [010] 826.326403: tcp:tcp_rcvbuf_grow: time=50233 rtt_us=50229 copied=3887104 inq=0 space=2691072 ooo=0 scaling_ratio=219 rcvbuf=6291456 rcv_ssthresh=5370482 window_clamp=5382144 rcv_wnd=5373952 tcp_stream 33793 [010] 826.376723: tcp:tcp_rcvbuf_grow: time=50323 rtt_us=50218 copied=5373952 inq=0 space=3887104 ooo=0 scaling_ratio=219 rcvbuf=9087658 rcv_ssthresh=7755537 window_clamp=7774207 rcv_wnd=7757824 tcp_stream 33793 [010] 826.426991: tcp:tcp_rcvbuf_grow: time=50274 rtt_us=50196 copied=7757824 inq=180224 space=5373952 ooo=0 scaling_ratio=219 rcvbuf=12563759 rcv_ssthresh=10729233 window_clamp=10747903 rcv_wnd=10575872 tcp_stream 33793 [010] 826.477229: tcp:tcp_rcvbuf_grow: time=50241 rtt_us=50078 copied=10731520 inq=180224 space=7577600 ooo=0 scaling_ratio=219 rcvbuf=17715667 rcv_ssthresh=15136529 window_clamp=15155199 rcv_wnd=14983168 tcp_stream 33793 [010] 826.527482: tcp:tcp_rcvbuf_grow: time=50258 rtt_us=50153 copied=15138816 inq=360448 space=10551296 ooo=0 scaling_ratio=219 rcvbuf=24667870 rcv_ssthresh=21073410 window_clamp=21102591 rcv_wnd=20766720 tcp_stream 33793 [010] 826.577712: tcp:tcp_rcvbuf_grow: time=50234 rtt_us=50228 copied=21073920 inq=0 space=14778368 ooo=0 scaling_ratio=219 rcvbuf=34550339 rcv_ssthresh=29517041 window_clamp=29556735 rcv_wnd=29519872 tcp_stream 33793 [010] 826.627982: tcp:tcp_rcvbuf_grow: time=50275 rtt_us=50220 copied=29519872 inq=540672 space=21073920 ooo=0 scaling_ratio=219 rcvbuf=49268707 rcv_ssthresh=42090625 window_clamp=42147839 rcv_wnd=41627648 tcp_stream 33793 [010] 826.678274: tcp:tcp_rcvbuf_grow: time=50296 rtt_us=50185 copied=42053632 inq=761856 space=28979200 ooo=0 scaling_ratio=219 rcvbuf=67000000 rcv_ssthresh=57238168 window_clamp=57316406 rcv_wnd=56606720 tcp_stream 33793 [010] 826.728627: tcp:tcp_rcvbuf_grow: time=50357 rtt_us=50128 copied=43913216 inq=851968 space=41291776 ooo=0 scaling_ratio=219 rcvbuf=67000000 rcv_ssthresh=57290728 window_clamp=57316406 rcv_wnd=56524800 tcp_stream 33793 [010] 827.131364: tcp:tcp_rcvbuf_grow: time=50239 rtt_us=50127 copied=43843584 inq=655360 space=43061248 ooo=0 scaling_ratio=219 rcvbuf=67000000 rcv_ssthresh=57290728 window_clamp=57316406 rcv_wnd=56696832 tcp_stream 33793 [010] 827.181613: tcp:tcp_rcvbuf_grow: time=50254 rtt_us=50115 copied=43843584 inq=524288 space=43188224 ooo=0 scaling_ratio=219 rcvbuf=67000000 rcv_ssthresh=57290728 window_clamp=57316406 rcv_wnd=56807424 tcp_stream 33793 [010] 828.339635: tcp:tcp_rcvbuf_grow: time=50283 rtt_us=50110 copied=43843584 inq=458752 space=43319296 ooo=0 scaling_ratio=219 rcvbuf=67000000 rcv_ssthresh=57290728 window_clamp=57316406 rcv_wnd=56864768 tcp_stream 33793 [010] 828.440350: tcp:tcp_rcvbuf_grow: time=50404 rtt_us=50099 copied=43843584 inq=393216 space=43384832 ooo=0 scaling_ratio=219 rcvbuf=67000000 rcv_ssthresh=57290728 window_clamp=57316406 rcv_wnd=56922112 tcp_stream 33793 [010] 829.195106: tcp:tcp_rcvbuf_grow: time=50154 rtt_us=50077 copied=43843584 inq=196608 space=43450368 ooo=0 scaling_ratio=219 rcvbuf=67000000 rcv_ssthresh=57290728 window_clamp=57316406 rcv_wnd=57090048After:
It takes few steps to increase RWIN. Sender is no longer RWIN limited.
tcp_stream 50826 [010] 935.634212: tcp:tcp_rcvbuf_grow: time=100788 rtt_us=50315 copied=49152 inq=0 space=40960 ooo=0 scaling_ratio=219 rcvbuf=131072 rcv_ssthresh=103970 window_clamp=112128 rcv_wnd=106496 tcp_stream 50826 [010] 935.685642: tcp:tcp_rcvbuf_grow: time=51437 rtt_us=50361 copied=86016 inq=0 space=49152 ooo=0 scaling_ratio=219 rcvbuf=160875 rcv_ssthresh=132969 window_clamp=137623 rcv_wnd=131072 tcp_stream 50826 [010] 935.738299: tcp:tcp_rcvbuf_grow: time=52660 rtt_us=50256 copied=139264 inq=0 space=86016 ooo=0 scaling_ratio=219 rcvbuf=502741 rcv_ssthresh=411497 window_clamp=430079 rcv_wnd=413696 tcp_stream 50826 [010] 935.788544: tcp:tcp_rcvbuf_grow: time=50249 rtt_us=50233 copied=307200 inq=0 space=139264 ooo=0 scaling_ratio=219 rcvbuf=728690 rcv_ssthresh=618717 window_clamp=623371 rcv_wnd=618496 tcp_stream 50826 [010] 935.838796: tcp:tcp_rcvbuf_grow: time=50258 rtt_us=50202 copied=618496 inq=0 space=307200 ooo=0 scaling_ratio=219 rcvbuf=2450338 rcv_ssthresh=1855709 window_clamp=2096187 rcv_wnd=1859584 tcp_stream 50826 [010] 935.889140: tcp:tcp_rcvbuf_grow: time=50347 rtt_us=50166 copied=1261568 inq=0 space=618496 ooo=0 scaling_ratio=219 rcvbuf=4376503 rcv_ssthresh=3725291 window_clamp=3743961 rcv_wnd=3706880 tcp_stream 50826 [010] 935.939435: tcp:tcp_rcvbuf_grow: time=50300 rtt_us=50185 copied=2478080 inq=24576 space=1261568 ooo=0 scaling_ratio=219 rcvbuf=9082648 rcv_ssthresh=7733731 window_clamp=7769921 rcv_wnd=7692288 tcp_stream 50826 [010] 935.989681: tcp:tcp_rcvbuf_grow: time=50251 rtt_us=50221 copied=4915200 inq=114688 space=2453504 ooo=0 scaling_ratio=219 rcvbuf=16574936 rcv_ssthresh=14108110 window_clamp=14179339 rcv_wnd=14024704 tcp_stream 50826 [010] 936.039967: tcp:tcp_rcvbuf_grow: time=50289 rtt_us=50279 copied=9830400 inq=114688 space=4800512 ooo=0 scaling_ratio=219 rcvbuf=32695050 rcv_ssthresh=27896187 window_clamp=27969593 rcv_wnd=27815936 tcp_stream 50826 [010] 936.090172: tcp:tcp_rcvbuf_grow: time=50211 rtt_us=50200 copied=19841024 inq=114688 space=9715712 ooo=0 scaling_ratio=219 rcvbuf=67000000 rcv_ssthresh=57245176 window_clamp=57316406 rcv_wnd=57163776 tcp_stream 50826 [010] 936.140430: tcp:tcp_rcvbuf_grow: time=50262 rtt_us=50197 copied=39501824 inq=114688 space=19726336 ooo=0 scaling_ratio=219 rcvbuf=67000000 rcv_ssthresh=57245176 window_clamp=57316406 rcv_wnd=57163776 tcp_stream 50826 [010] 936.190527: tcp:tcp_rcvbuf_grow: time=50101 rtt_us=50071 copied=43655168 inq=262144 space=39387136 ooo=0 scaling_ratio=219 rcvbuf=67000000 rcv_ssthresh=57259192 window_clamp=57316406 rcv_wnd=57032704 tcp_stream 50826 [010] 936.240719: tcp:tcp_rcvbuf_grow: time=50197 rtt_us=50057 copied=43843584 inq=262144 space=43393024 ooo=0 scaling_ratio=219 rcvbuf=67000000 rcv_ssthresh=57259192 window_clamp=57316406 rcv_wnd=57032704 tcp_stream 50826 [010] 936.341271: tcp:tcp_rcvbuf_grow: time=50297 rtt_us=50123 copied=43843584 inq=131072 space=43581440 ooo=0 scaling_ratio=219 rcvbuf=67000000 rcv_ssthresh=57259192 window_clamp=57316406 rcv_wnd=57147392 tcp_stream 50826 [010] 936.642503: tcp:tcp_rcvbuf_grow: time=50131 rtt_us=50084 copied=43843584 inq=0 space=43712512 ooo=0 scaling_ratio=219 rcvbuf=67000000 rcv_ssthresh=57259192 window_clamp=57316406 rcv_wnd=57262080Fixes 65c5287892e9 ("tcp: fix sk_rcvbuf overshoot")Fixes e118cdc34dd1 ("mptcp: rcvbuf auto-tuning improvement")Reported-by Neal Cardwell <[email protected]>Signed-off-by Eric Dumazet <[email protected]>--- net/ipv4/tcp_input.c | 8 +++++++- net/mptcp/protocol.c | 7 +++++++ 2 files changed, 14 insertions(+), 1 deletion(-)net/ipv4/tcp_input.c +2
-1@@ -896,6 +896,7 @@ void tcp_rcvbuf_grow(struct sock *sk, u32 newval)const struct net *net =sock_net (sk);struct tcp_sock *tp =tcp_sk (sk);u32 rcvwin, rcvbuf, cap, oldval; +u64 grow; oldval = tp->rcvq_space.space; tp->rcvq_space.space = newval;@@ -904,9 +905,14 @@ void tcp_rcvbuf_grow(struct sock *sk, u32 newval) (sk->sk_userlocks & SOCK_RCVBUF_LOCK))return ; -/* slow start: allow the sender to double its rate. */ +/* DRS is always one RTT late. */
net/ipv4/tcp_input.c void tcp_rcvbuf_grow(struct sock *sk, u32 newval) · line 918
Quoted 10 lines
net/ipv4/tcp_input.c +5
-0rcvwin = newval <<1 ; +/* slow start: allow the sender to double its rate. */ + grow = (u64 )rcvwin * (newval - oldval); +do_div (grow, oldval); + rcvwin += grow <<1 ; +if (!RB_EMPTY_ROOT (&tp->out_of_order_queue)) rcvwin +=TCP_SKB_CB (tp->ooo_last_skb)->end_seq - tp->rcv_nxt;
Hi Eric,
When applying this series I see a regression in a simple 25G iperf test:
retransmissions are seen due to packet drops (out of buffer) on the server side.
The test:
- server: iperf3 -s -A 5
- client: iperf3 -c 1.1.1.1 -B 25G
- Configuration:
- Server has a single queue with affinity set on CPU 5.
- Ring size: 1K (4K ring size seems ok)
- MTU: 1500
- Client uses TSO, server uses SW GRO.
Before series (includes first patch):
<...>-2192 [005] 162.451893: tcp_rcvbuf_grow: time=1622 rtt_us=1596 copied=76781 inq=30408 space=14480 ooo=0 scaling_ratio=188 rcvbuf=131072 rcv_ssthresh=91990 window_clamp=96256 rcv_wnd=66560 <...>-2192 [005] 162.451998: tcp_rcvbuf_grow: time=106 rtt_us=105 copied=158720 inq=0 space=46373 ooo=0 scaling_ratio=188 rcvbuf=131072 rcv_ssthresh=91990 window_clamp=96256 rcv_wnd=92160 <...>-2192 [005] 162.453254: tcp_rcvbuf_grow: time=142 rtt_us=44 copied=292496 inq=91512 space=158720 ooo=0 scaling_ratio=188 rcvbuf=432258 rcv_ssthresh=270533 window_clamp=317439 rcv_wnd=253952 <...>-2192 [005] 162.454446: tcp_rcvbuf_grow: time=113 rtt_us=44 copied=343176 inq=127424 space=200984 ooo=0 scaling_ratio=188 rcvbuf=547360 rcv_ssthresh=349656 window_clamp=401967 rcv_wnd=345088 <...>-2192 [005] 162.455726: tcp_rcvbuf_grow: time=52 rtt_us=44 copied=264464 inq=40544 space=215752 ooo=0 scaling_ratio=188 rcvbuf=587579 rcv_ssthresh=391036 window_clamp=431503 rcv_wnd=194560 <...>-2192 [005] 162.456444: tcp_rcvbuf_grow: time=37 rtt_us=36 copied=322560 inq=0 space=223920 ooo=0 scaling_ratio=188 rcvbuf=609824 rcv_ssthresh=391036 window_clamp=447839 rcv_wnd=323584 <...>-2192 [005] 162.456865: tcp_rcvbuf_grow: time=40 rtt_us=36 copied=421840 inq=73848 space=322560 ooo=0 scaling_ratio=188 rcvbuf=878461 rcv_ssthresh=581105 window_clamp=645119 rcv_wnd=515072 <...>-2192 [005] 162.457762: tcp_rcvbuf_grow: time=38 rtt_us=36 copied=430176 inq=65160 space=347992 ooo=0 scaling_ratio=188 rcvbuf=947722 rcv_ssthresh=631969 window_clamp=695983 rcv_wnd=467968 <...>-2192 [005] 162.463191: tcp_rcvbuf_grow: time=35 rtt_us=34 copied=411336 inq=0 space=365016 ooo=0 scaling_ratio=188 rcvbuf=994086 rcv_ssthresh=666017 window_clamp=730031 rcv_wnd=354304 <...>-2192 [005] 162.469069: tcp_rcvbuf_grow: time=38 rtt_us=34 copied=444520 inq=0 space=411336 ooo=0 scaling_ratio=188 rcvbuf=1120234 rcv_ssthresh=783379 window_clamp=822671 rcv_wnd=679936
After series:
<...>-2585 [005] 1061.768676: tcp_rcvbuf_grow: time=623 rtt_us=600 copied=72437 inq=28960 space=14480 ooo=0 scaling_ratio=188 rcvbuf=131072 rcv_ssthresh=81968 window_clamp=96256 rcv_wnd=82944 <...>-2585 [005] 1061.769859: tcp_rcvbuf_grow: time=89 rtt_us=55 copied=250560 inq=46336 space=43477 ooo=0 scaling_ratio=188 rcvbuf=592631 rcv_ssthresh=302062 window_clamp=435213 rcv_wnd=230400 <...>-2585 [005] 1061.775618: tcp_rcvbuf_grow: time=56 rtt_us=55 copied=405296 inq=140016 space=204224 ooo=0 scaling_ratio=188 rcvbuf=4668930 rcv_ssthresh=1927847 window_clamp=3428745 rcv_wnd=1928192 <...>-2585 [005] 1061.777324: tcp_rcvbuf_grow: time=57 rtt_us=55 copied=450664 inq=131072 space=265280 ooo=0 scaling_ratio=188 rcvbuf=4668930 rcv_ssthresh=3106743 window_clamp=3428745 rcv_wnd=3006464 <...>-2585 [005] 1061.783411: tcp_rcvbuf_grow: time=58 rtt_us=55 copied=521280 inq=41160 space=319592 ooo=0 scaling_ratio=188 rcvbuf=4668930 rcv_ssthresh=3364731 window_clamp=3428745 rcv_wnd=2086912 <...>-2585 [005] 1061.790393: tcp_rcvbuf_grow: time=55 rtt_us=55 copied=524288 inq=0 space=480120 ooo=0 scaling_ratio=188 rcvbuf=4668930 rcv_ssthresh=3364731 window_clamp=3428745 rcv_wnd=2492416 <...>-2585 [005] 1061.935387: tcp_rcvbuf_grow: time=55 rtt_us=55 copied=537824 inq=0 space=524288 ooo=0 scaling_ratio=188 rcvbuf=4668930 rcv_ssthresh=3364731 window_clamp=3428745 rcv_wnd=2258944 <...>-2585 [005] 1062.977374: tcp_rcvbuf_grow: time=57 rtt_us=55 copied=545064 inq=0 space=537824 ooo=0 scaling_ratio=188 rcvbuf=4668930 rcv_ssthresh=3428745 window_clamp=3428745 rcv_wnd=2223104 <...>-2585 [005] 1064.873376: tcp_rcvbuf_grow: time=57 rtt_us=55 copied=549408 inq=0 space=545064 ooo=0 scaling_ratio=188 rcvbuf=4668930 rcv_ssthresh=3428745 window_clamp=3428745 rcv_wnd=2509824 <...>-2585 [005] 1065.984340: tcp_rcvbuf_grow: time=59 rtt_us=55 copied=574024 inq=0 space=549408 ooo=0 scaling_ratio=188 rcvbuf=4668930 rcv_ssthresh=3428745 window_clamp=3428745 rcv_wnd=2336768 <...>-2585 [005] 1066.210718: tcp_rcvbuf_grow: time=410 rtt_us=55 copied=589448 inq=0 space=574024 ooo=0 scaling_ratio=188 rcvbuf=4668930 rcv_ssthresh=3428745 window_clamp=3428745 rcv_wnd=3364864
Is this expected?
Thanks,
Dragos
Re: [PATCH net-next 3/3] tcp: fix too slow tcp_rcvbuf_grow() action
Quoted 148 lines · Dragos Tatulea
Quoted 96 lines · Eric Dumazet
While the blamed commits apparently avoided an overshoot, they also limited how fast a sender can increase BDP at each RTT.
This is not exactly a revert, we do not add the 16 *
tp->advmsscushion we had, and we are keeping theout_of_order_queuecontribution.Do the same in
mptcp_rcvbuf_grow().Tested:
emulated 50ms rtt (
tcp_stream--tcp-tx-delay 50000), cubic 20 second flow. net.ipv4.tcp_rmem set to "4096 131072 67000000"perf record -a -e tcp:tcp_rcvbuf_grow sleep 20
perf scriptBefore:
We can see we fail to roughly double RWIN at each RTT.
Sender is RWIN limited while CWND is ramping up (before gettingtcp_wmemlimited)tcp_stream 33793 [010] 825.717525: tcp:tcp_rcvbuf_grow: time=100869 rtt_us=50428 copied=49152 inq=0 space=40960 ooo=0 scaling_ratio=219 rcvbuf=131072 rcv_ssthresh=103970 window_clamp=112128 rcv_wnd=106496 tcp_stream 33793 [010] 825.768966: tcp:tcp_rcvbuf_grow: time=51447 rtt_us=50362 copied=86016 inq=0 space=49152 ooo=0 scaling_ratio=219 rcvbuf=131072 rcv_ssthresh=107474 window_clamp=112128 rcv_wnd=106496 tcp_stream 33793 [010] 825.821539: tcp:tcp_rcvbuf_grow: time=52577 rtt_us=50243 copied=114688 inq=0 space=86016 ooo=0 scaling_ratio=219 rcvbuf=201096 rcv_ssthresh=167377 window_clamp=172031 rcv_wnd=167936 tcp_stream 33793 [010] 825.871781: tcp:tcp_rcvbuf_grow: time=50248 rtt_us=50237 copied=167936 inq=0 space=114688 ooo=0 scaling_ratio=219 rcvbuf=268129 rcv_ssthresh=224722 window_clamp=229375 rcv_wnd=225280 tcp_stream 33793 [010] 825.922475: tcp:tcp_rcvbuf_grow: time=50698 rtt_us=50183 copied=241664 inq=0 space=167936 ooo=0 scaling_ratio=219 rcvbuf=392617 rcv_ssthresh=331217 window_clamp=335871 rcv_wnd=323584 tcp_stream 33793 [010] 825.973326: tcp:tcp_rcvbuf_grow: time=50855 rtt_us=50213 copied=339968 inq=0 space=241664 ooo=0 scaling_ratio=219 rcvbuf=564986 rcv_ssthresh=478674 window_clamp=483327 rcv_wnd=462848 tcp_stream 33793 [010] 826.023970: tcp:tcp_rcvbuf_grow: time=50647 rtt_us=50248 copied=491520 inq=0 space=339968 ooo=0 scaling_ratio=219 rcvbuf=794811 rcv_ssthresh=671778 window_clamp=679935 rcv_wnd=651264 tcp_stream 33793 [010] 826.074612: tcp:tcp_rcvbuf_grow: time=50648 rtt_us=50227 copied=700416 inq=0 space=491520 ooo=0 scaling_ratio=219 rcvbuf=1149124 rcv_ssthresh=974881 window_clamp=983039 rcv_wnd=942080 tcp_stream 33793 [010] 826.125452: tcp:tcp_rcvbuf_grow: time=50845 rtt_us=50225 copied=987136 inq=8192 space=700416 ooo=0 scaling_ratio=219 rcvbuf=1637502 rcv_ssthresh=1392674 window_clamp=1400831 rcv_wnd=1339392 tcp_stream 33793 [010] 826.175698: tcp:tcp_rcvbuf_grow: time=50250 rtt_us=50198 copied=1347584 inq=0 space=978944 ooo=0 scaling_ratio=219 rcvbuf=2288672 rcv_ssthresh=1949729 window_clamp=1957887 rcv_wnd=1945600 tcp_stream 33793 [010] 826.225947: tcp:tcp_rcvbuf_grow: time=50252 rtt_us=50240 copied=1945600 inq=0 space=1347584 ooo=0 scaling_ratio=219 rcvbuf=3150516 rcv_ssthresh=2687010 window_clamp=2695167 rcv_wnd=2691072 tcp_stream 33793 [010] 826.276175: tcp:tcp_rcvbuf_grow: time=50233 rtt_us=50224 copied=2691072 inq=0 space=1945600 ooo=0 scaling_ratio=219 rcvbuf=4548617 rcv_ssthresh=3883041 window_clamp=3891199 rcv_wnd=3887104 tcp_stream 33793 [010] 826.326403: tcp:tcp_rcvbuf_grow: time=50233 rtt_us=50229 copied=3887104 inq=0 space=2691072 ooo=0 scaling_ratio=219 rcvbuf=6291456 rcv_ssthresh=5370482 window_clamp=5382144 rcv_wnd=5373952 tcp_stream 33793 [010] 826.376723: tcp:tcp_rcvbuf_grow: time=50323 rtt_us=50218 copied=5373952 inq=0 space=3887104 ooo=0 scaling_ratio=219 rcvbuf=9087658 rcv_ssthresh=7755537 window_clamp=7774207 rcv_wnd=7757824 tcp_stream 33793 [010] 826.426991: tcp:tcp_rcvbuf_grow: time=50274 rtt_us=50196 copied=7757824 inq=180224 space=5373952 ooo=0 scaling_ratio=219 rcvbuf=12563759 rcv_ssthresh=10729233 window_clamp=10747903 rcv_wnd=10575872 tcp_stream 33793 [010] 826.477229: tcp:tcp_rcvbuf_grow: time=50241 rtt_us=50078 copied=10731520 inq=180224 space=7577600 ooo=0 scaling_ratio=219 rcvbuf=17715667 rcv_ssthresh=15136529 window_clamp=15155199 rcv_wnd=14983168 tcp_stream 33793 [010] 826.527482: tcp:tcp_rcvbuf_grow: time=50258 rtt_us=50153 copied=15138816 inq=360448 space=10551296 ooo=0 scaling_ratio=219 rcvbuf=24667870 rcv_ssthresh=21073410 window_clamp=21102591 rcv_wnd=20766720 tcp_stream 33793 [010] 826.577712: tcp:tcp_rcvbuf_grow: time=50234 rtt_us=50228 copied=21073920 inq=0 space=14778368 ooo=0 scaling_ratio=219 rcvbuf=34550339 rcv_ssthresh=29517041 window_clamp=29556735 rcv_wnd=29519872 tcp_stream 33793 [010] 826.627982: tcp:tcp_rcvbuf_grow: time=50275 rtt_us=50220 copied=29519872 inq=540672 space=21073920 ooo=0 scaling_ratio=219 rcvbuf=49268707 rcv_ssthresh=42090625 window_clamp=42147839 rcv_wnd=41627648 tcp_stream 33793 [010] 826.678274: tcp:tcp_rcvbuf_grow: time=50296 rtt_us=50185 copied=42053632 inq=761856 space=28979200 ooo=0 scaling_ratio=219 rcvbuf=67000000 rcv_ssthresh=57238168 window_clamp=57316406 rcv_wnd=56606720 tcp_stream 33793 [010] 826.728627: tcp:tcp_rcvbuf_grow: time=50357 rtt_us=50128 copied=43913216 inq=851968 space=41291776 ooo=0 scaling_ratio=219 rcvbuf=67000000 rcv_ssthresh=57290728 window_clamp=57316406 rcv_wnd=56524800 tcp_stream 33793 [010] 827.131364: tcp:tcp_rcvbuf_grow: time=50239 rtt_us=50127 copied=43843584 inq=655360 space=43061248 ooo=0 scaling_ratio=219 rcvbuf=67000000 rcv_ssthresh=57290728 window_clamp=57316406 rcv_wnd=56696832 tcp_stream 33793 [010] 827.181613: tcp:tcp_rcvbuf_grow: time=50254 rtt_us=50115 copied=43843584 inq=524288 space=43188224 ooo=0 scaling_ratio=219 rcvbuf=67000000 rcv_ssthresh=57290728 window_clamp=57316406 rcv_wnd=56807424 tcp_stream 33793 [010] 828.339635: tcp:tcp_rcvbuf_grow: time=50283 rtt_us=50110 copied=43843584 inq=458752 space=43319296 ooo=0 scaling_ratio=219 rcvbuf=67000000 rcv_ssthresh=57290728 window_clamp=57316406 rcv_wnd=56864768 tcp_stream 33793 [010] 828.440350: tcp:tcp_rcvbuf_grow: time=50404 rtt_us=50099 copied=43843584 inq=393216 space=43384832 ooo=0 scaling_ratio=219 rcvbuf=67000000 rcv_ssthresh=57290728 window_clamp=57316406 rcv_wnd=56922112 tcp_stream 33793 [010] 829.195106: tcp:tcp_rcvbuf_grow: time=50154 rtt_us=50077 copied=43843584 inq=196608 space=43450368 ooo=0 scaling_ratio=219 rcvbuf=67000000 rcv_ssthresh=57290728 window_clamp=57316406 rcv_wnd=57090048After:
It takes few steps to increase RWIN. Sender is no longer RWIN limited.
tcp_stream 50826 [010] 935.634212: tcp:tcp_rcvbuf_grow: time=100788 rtt_us=50315 copied=49152 inq=0 space=40960 ooo=0 scaling_ratio=219 rcvbuf=131072 rcv_ssthresh=103970 window_clamp=112128 rcv_wnd=106496 tcp_stream 50826 [010] 935.685642: tcp:tcp_rcvbuf_grow: time=51437 rtt_us=50361 copied=86016 inq=0 space=49152 ooo=0 scaling_ratio=219 rcvbuf=160875 rcv_ssthresh=132969 window_clamp=137623 rcv_wnd=131072 tcp_stream 50826 [010] 935.738299: tcp:tcp_rcvbuf_grow: time=52660 rtt_us=50256 copied=139264 inq=0 space=86016 ooo=0 scaling_ratio=219 rcvbuf=502741 rcv_ssthresh=411497 window_clamp=430079 rcv_wnd=413696 tcp_stream 50826 [010] 935.788544: tcp:tcp_rcvbuf_grow: time=50249 rtt_us=50233 copied=307200 inq=0 space=139264 ooo=0 scaling_ratio=219 rcvbuf=728690 rcv_ssthresh=618717 window_clamp=623371 rcv_wnd=618496 tcp_stream 50826 [010] 935.838796: tcp:tcp_rcvbuf_grow: time=50258 rtt_us=50202 copied=618496 inq=0 space=307200 ooo=0 scaling_ratio=219 rcvbuf=2450338 rcv_ssthresh=1855709 window_clamp=2096187 rcv_wnd=1859584 tcp_stream 50826 [010] 935.889140: tcp:tcp_rcvbuf_grow: time=50347 rtt_us=50166 copied=1261568 inq=0 space=618496 ooo=0 scaling_ratio=219 rcvbuf=4376503 rcv_ssthresh=3725291 window_clamp=3743961 rcv_wnd=3706880 tcp_stream 50826 [010] 935.939435: tcp:tcp_rcvbuf_grow: time=50300 rtt_us=50185 copied=2478080 inq=24576 space=1261568 ooo=0 scaling_ratio=219 rcvbuf=9082648 rcv_ssthresh=7733731 window_clamp=7769921 rcv_wnd=7692288 tcp_stream 50826 [010] 935.989681: tcp:tcp_rcvbuf_grow: time=50251 rtt_us=50221 copied=4915200 inq=114688 space=2453504 ooo=0 scaling_ratio=219 rcvbuf=16574936 rcv_ssthresh=14108110 window_clamp=14179339 rcv_wnd=14024704 tcp_stream 50826 [010] 936.039967: tcp:tcp_rcvbuf_grow: time=50289 rtt_us=50279 copied=9830400 inq=114688 space=4800512 ooo=0 scaling_ratio=219 rcvbuf=32695050 rcv_ssthresh=27896187 window_clamp=27969593 rcv_wnd=27815936 tcp_stream 50826 [010] 936.090172: tcp:tcp_rcvbuf_grow: time=50211 rtt_us=50200 copied=19841024 inq=114688 space=9715712 ooo=0 scaling_ratio=219 rcvbuf=67000000 rcv_ssthresh=57245176 window_clamp=57316406 rcv_wnd=57163776 tcp_stream 50826 [010] 936.140430: tcp:tcp_rcvbuf_grow: time=50262 rtt_us=50197 copied=39501824 inq=114688 space=19726336 ooo=0 scaling_ratio=219 rcvbuf=67000000 rcv_ssthresh=57245176 window_clamp=57316406 rcv_wnd=57163776 tcp_stream 50826 [010] 936.190527: tcp:tcp_rcvbuf_grow: time=50101 rtt_us=50071 copied=43655168 inq=262144 space=39387136 ooo=0 scaling_ratio=219 rcvbuf=67000000 rcv_ssthresh=57259192 window_clamp=57316406 rcv_wnd=57032704 tcp_stream 50826 [010] 936.240719: tcp:tcp_rcvbuf_grow: time=50197 rtt_us=50057 copied=43843584 inq=262144 space=43393024 ooo=0 scaling_ratio=219 rcvbuf=67000000 rcv_ssthresh=57259192 window_clamp=57316406 rcv_wnd=57032704 tcp_stream 50826 [010] 936.341271: tcp:tcp_rcvbuf_grow: time=50297 rtt_us=50123 copied=43843584 inq=131072 space=43581440 ooo=0 scaling_ratio=219 rcvbuf=67000000 rcv_ssthresh=57259192 window_clamp=57316406 rcv_wnd=57147392 tcp_stream 50826 [010] 936.642503: tcp:tcp_rcvbuf_grow: time=50131 rtt_us=50084 copied=43843584 inq=0 space=43712512 ooo=0 scaling_ratio=219 rcvbuf=67000000 rcv_ssthresh=57259192 window_clamp=57316406 rcv_wnd=57262080Fixes 65c5287892e9 ("tcp: fix sk_rcvbuf overshoot")Fixes e118cdc34dd1 ("mptcp: rcvbuf auto-tuning improvement")Reported-by Neal Cardwell <[email protected]>Signed-off-by Eric Dumazet <[email protected]>--- net/ipv4/tcp_input.c | 8 +++++++- net/mptcp/protocol.c | 7 +++++++ 2 files changed, 14 insertions(+), 1 deletion(-)net/ipv4/tcp_input.c +2
-1@@ -896,6 +896,7 @@ void tcp_rcvbuf_grow(struct sock *sk, u32 newval)const struct net *net =sock_net (sk);struct tcp_sock *tp =tcp_sk (sk);u32 rcvwin, rcvbuf, cap, oldval; +u64 grow; oldval = tp->rcvq_space.space; tp->rcvq_space.space = newval;@@ -904,9 +905,14 @@ void tcp_rcvbuf_grow(struct sock *sk, u32 newval) (sk->sk_userlocks & SOCK_RCVBUF_LOCK))return ; -/* slow start: allow the sender to double its rate. */ +/* DRS is always one RTT late. */ net/ipv4/tcp_input.c void tcp_rcvbuf_grow(struct sock *sk, u32 newval) · line 918
Quoted 10 lines
net/ipv4/tcp_input.c +5
-0rcvwin = newval <<1 ; +/* slow start: allow the sender to double its rate. */ + grow = (u64 )rcvwin * (newval - oldval); +do_div (grow, oldval); + rcvwin += grow <<1 ; +if (!RB_EMPTY_ROOT (&tp->out_of_order_queue)) rcvwin +=TCP_SKB_CB (tp->ooo_last_skb)->end_seq - tp->rcv_nxt;Hi Eric,
When applying this series I see a regression in a simple 25G iperf test:
retransmissions are seen due to packet drops (out of buffer) on the server side.The test:
- server: iperf3 -s -A 5
- client: iperf3 -c 1.1.1.1 -B 25G
- Configuration:
- Server has a single queue with affinity set on CPU 5.
- Ring size: 1K (4K ring size seems ok)
- MTU: 1500
- Client uses TSO, server uses SW GRO.Before series (includes first patch):
<...>-2192 [005] 162.451893: tcp_rcvbuf_grow: time=1622 rtt_us=1596 copied=76781 inq=30408 space=14480 ooo=0 scaling_ratio=188 rcvbuf=131072 rcv_ssthresh=91990 window_clamp=96256 rcv_wnd=66560 <...>-2192 [005] 162.451998: tcp_rcvbuf_grow: time=106 rtt_us=105 copied=158720 inq=0 space=46373 ooo=0 scaling_ratio=188 rcvbuf=131072 rcv_ssthresh=91990 window_clamp=96256 rcv_wnd=92160 <...>-2192 [005] 162.453254: tcp_rcvbuf_grow: time=142 rtt_us=44 copied=292496 inq=91512 space=158720 ooo=0 scaling_ratio=188 rcvbuf=432258 rcv_ssthresh=270533 window_clamp=317439 rcv_wnd=253952 <...>-2192 [005] 162.454446: tcp_rcvbuf_grow: time=113 rtt_us=44 copied=343176 inq=127424 space=200984 ooo=0 scaling_ratio=188 rcvbuf=547360 rcv_ssthresh=349656 window_clamp=401967 rcv_wnd=345088 <...>-2192 [005] 162.455726: tcp_rcvbuf_grow: time=52 rtt_us=44 copied=264464 inq=40544 space=215752 ooo=0 scaling_ratio=188 rcvbuf=587579 rcv_ssthresh=391036 window_clamp=431503 rcv_wnd=194560 <...>-2192 [005] 162.456444: tcp_rcvbuf_grow: time=37 rtt_us=36 copied=322560 inq=0 space=223920 ooo=0 scaling_ratio=188 rcvbuf=609824 rcv_ssthresh=391036 window_clamp=447839 rcv_wnd=323584 <...>-2192 [005] 162.456865: tcp_rcvbuf_grow: time=40 rtt_us=36 copied=421840 inq=73848 space=322560 ooo=0 scaling_ratio=188 rcvbuf=878461 rcv_ssthresh=581105 window_clamp=645119 rcv_wnd=515072 <...>-2192 [005] 162.457762: tcp_rcvbuf_grow: time=38 rtt_us=36 copied=430176 inq=65160 space=347992 ooo=0 scaling_ratio=188 rcvbuf=947722 rcv_ssthresh=631969 window_clamp=695983 rcv_wnd=467968 <...>-2192 [005] 162.463191: tcp_rcvbuf_grow: time=35 rtt_us=34 copied=411336 inq=0 space=365016 ooo=0 scaling_ratio=188 rcvbuf=994086 rcv_ssthresh=666017 window_clamp=730031 rcv_wnd=354304 <...>-2192 [005] 162.469069: tcp_rcvbuf_grow: time=38 rtt_us=34 copied=444520 inq=0 space=411336 ooo=0 scaling_ratio=188 rcvbuf=1120234 rcv_ssthresh=783379 window_clamp=822671 rcv_wnd=679936After series:
<...>-2585 [005] 1061.768676: tcp_rcvbuf_grow: time=623 rtt_us=600 copied=72437 inq=28960 space=14480 ooo=0 scaling_ratio=188 rcvbuf=131072 rcv_ssthresh=81968 window_clamp=96256 rcv_wnd=82944 <...>-2585 [005] 1061.769859: tcp_rcvbuf_grow: time=89 rtt_us=55 copied=250560 inq=46336 space=43477 ooo=0 scaling_ratio=188 rcvbuf=592631 rcv_ssthresh=302062 window_clamp=435213 rcv_wnd=230400 <...>-2585 [005] 1061.775618: tcp_rcvbuf_grow: time=56 rtt_us=55 copied=405296 inq=140016 space=204224 ooo=0 scaling_ratio=188 rcvbuf=4668930 rcv_ssthresh=1927847 window_clamp=3428745 rcv_wnd=1928192 <...>-2585 [005] 1061.777324: tcp_rcvbuf_grow: time=57 rtt_us=55 copied=450664 inq=131072 space=265280 ooo=0 scaling_ratio=188 rcvbuf=4668930 rcv_ssthresh=3106743 window_clamp=3428745 rcv_wnd=3006464 <...>-2585 [005] 1061.783411: tcp_rcvbuf_grow: time=58 rtt_us=55 copied=521280 inq=41160 space=319592 ooo=0 scaling_ratio=188 rcvbuf=4668930 rcv_ssthresh=3364731 window_clamp=3428745 rcv_wnd=2086912 <...>-2585 [005] 1061.790393: tcp_rcvbuf_grow: time=55 rtt_us=55 copied=524288 inq=0 space=480120 ooo=0 scaling_ratio=188 rcvbuf=4668930 rcv_ssthresh=3364731 window_clamp=3428745 rcv_wnd=2492416 <...>-2585 [005] 1061.935387: tcp_rcvbuf_grow: time=55 rtt_us=55 copied=537824 inq=0 space=524288 ooo=0 scaling_ratio=188 rcvbuf=4668930 rcv_ssthresh=3364731 window_clamp=3428745 rcv_wnd=2258944 <...>-2585 [005] 1062.977374: tcp_rcvbuf_grow: time=57 rtt_us=55 copied=545064 inq=0 space=537824 ooo=0 scaling_ratio=188 rcvbuf=4668930 rcv_ssthresh=3428745 window_clamp=3428745 rcv_wnd=2223104 <...>-2585 [005] 1064.873376: tcp_rcvbuf_grow: time=57 rtt_us=55 copied=549408 inq=0 space=545064 ooo=0 scaling_ratio=188 rcvbuf=4668930 rcv_ssthresh=3428745 window_clamp=3428745 rcv_wnd=2509824 <...>-2585 [005] 1065.984340: tcp_rcvbuf_grow: time=59 rtt_us=55 copied=574024 inq=0 space=549408 ooo=0 scaling_ratio=188 rcvbuf=4668930 rcv_ssthresh=3428745 window_clamp=3428745 rcv_wnd=2336768 <...>-2585 [005] 1066.210718: tcp_rcvbuf_grow: time=410 rtt_us=55 copied=589448 inq=0 space=574024 ooo=0 scaling_ratio=188 rcvbuf=4668930 rcv_ssthresh=3428745 window_clamp=3428745 rcv_wnd=3364864
Quoted 1 line
Is this expected?
Typical cubic reaction I would say, with pfifo_fast ?
I do not think that artificially slowing down senders by not growing rwin fast enough is the right answer.
If you have drops, that is because the sender is sending too fast or with too large burts.
Try using the fq packet scheduler and see if it helps.
Re: [PATCH net-next 3/3] tcp: fix too slow tcp_rcvbuf_grow() action
Quoted 137 lines · Eric Dumazet
Quoted 135 lines · Dragos Tatulea
Quoted 96 lines · Eric Dumazet
While the blamed commits apparently avoided an overshoot, they also limited how fast a sender can increase BDP at each RTT.
This is not exactly a revert, we do not add the 16 *
tp->advmsscushion we had, and we are keeping theout_of_order_queuecontribution.Do the same in
mptcp_rcvbuf_grow().Tested:
emulated 50ms rtt (
tcp_stream--tcp-tx-delay 50000), cubic 20 second flow. net.ipv4.tcp_rmem set to "4096 131072 67000000"perf record -a -e tcp:tcp_rcvbuf_grow sleep 20
perf scriptBefore:
We can see we fail to roughly double RWIN at each RTT.
Sender is RWIN limited while CWND is ramping up (before gettingtcp_wmemlimited)tcp_stream 33793 [010] 825.717525: tcp:tcp_rcvbuf_grow: time=100869 rtt_us=50428 copied=49152 inq=0 space=40960 ooo=0 scaling_ratio=219 rcvbuf=131072 rcv_ssthresh=103970 window_clamp=112128 rcv_wnd=106496 tcp_stream 33793 [010] 825.768966: tcp:tcp_rcvbuf_grow: time=51447 rtt_us=50362 copied=86016 inq=0 space=49152 ooo=0 scaling_ratio=219 rcvbuf=131072 rcv_ssthresh=107474 window_clamp=112128 rcv_wnd=106496 tcp_stream 33793 [010] 825.821539: tcp:tcp_rcvbuf_grow: time=52577 rtt_us=50243 copied=114688 inq=0 space=86016 ooo=0 scaling_ratio=219 rcvbuf=201096 rcv_ssthresh=167377 window_clamp=172031 rcv_wnd=167936 tcp_stream 33793 [010] 825.871781: tcp:tcp_rcvbuf_grow: time=50248 rtt_us=50237 copied=167936 inq=0 space=114688 ooo=0 scaling_ratio=219 rcvbuf=268129 rcv_ssthresh=224722 window_clamp=229375 rcv_wnd=225280 tcp_stream 33793 [010] 825.922475: tcp:tcp_rcvbuf_grow: time=50698 rtt_us=50183 copied=241664 inq=0 space=167936 ooo=0 scaling_ratio=219 rcvbuf=392617 rcv_ssthresh=331217 window_clamp=335871 rcv_wnd=323584 tcp_stream 33793 [010] 825.973326: tcp:tcp_rcvbuf_grow: time=50855 rtt_us=50213 copied=339968 inq=0 space=241664 ooo=0 scaling_ratio=219 rcvbuf=564986 rcv_ssthresh=478674 window_clamp=483327 rcv_wnd=462848 tcp_stream 33793 [010] 826.023970: tcp:tcp_rcvbuf_grow: time=50647 rtt_us=50248 copied=491520 inq=0 space=339968 ooo=0 scaling_ratio=219 rcvbuf=794811 rcv_ssthresh=671778 window_clamp=679935 rcv_wnd=651264 tcp_stream 33793 [010] 826.074612: tcp:tcp_rcvbuf_grow: time=50648 rtt_us=50227 copied=700416 inq=0 space=491520 ooo=0 scaling_ratio=219 rcvbuf=1149124 rcv_ssthresh=974881 window_clamp=983039 rcv_wnd=942080 tcp_stream 33793 [010] 826.125452: tcp:tcp_rcvbuf_grow: time=50845 rtt_us=50225 copied=987136 inq=8192 space=700416 ooo=0 scaling_ratio=219 rcvbuf=1637502 rcv_ssthresh=1392674 window_clamp=1400831 rcv_wnd=1339392 tcp_stream 33793 [010] 826.175698: tcp:tcp_rcvbuf_grow: time=50250 rtt_us=50198 copied=1347584 inq=0 space=978944 ooo=0 scaling_ratio=219 rcvbuf=2288672 rcv_ssthresh=1949729 window_clamp=1957887 rcv_wnd=1945600 tcp_stream 33793 [010] 826.225947: tcp:tcp_rcvbuf_grow: time=50252 rtt_us=50240 copied=1945600 inq=0 space=1347584 ooo=0 scaling_ratio=219 rcvbuf=3150516 rcv_ssthresh=2687010 window_clamp=2695167 rcv_wnd=2691072 tcp_stream 33793 [010] 826.276175: tcp:tcp_rcvbuf_grow: time=50233 rtt_us=50224 copied=2691072 inq=0 space=1945600 ooo=0 scaling_ratio=219 rcvbuf=4548617 rcv_ssthresh=3883041 window_clamp=3891199 rcv_wnd=3887104 tcp_stream 33793 [010] 826.326403: tcp:tcp_rcvbuf_grow: time=50233 rtt_us=50229 copied=3887104 inq=0 space=2691072 ooo=0 scaling_ratio=219 rcvbuf=6291456 rcv_ssthresh=5370482 window_clamp=5382144 rcv_wnd=5373952 tcp_stream 33793 [010] 826.376723: tcp:tcp_rcvbuf_grow: time=50323 rtt_us=50218 copied=5373952 inq=0 space=3887104 ooo=0 scaling_ratio=219 rcvbuf=9087658 rcv_ssthresh=7755537 window_clamp=7774207 rcv_wnd=7757824 tcp_stream 33793 [010] 826.426991: tcp:tcp_rcvbuf_grow: time=50274 rtt_us=50196 copied=7757824 inq=180224 space=5373952 ooo=0 scaling_ratio=219 rcvbuf=12563759 rcv_ssthresh=10729233 window_clamp=10747903 rcv_wnd=10575872 tcp_stream 33793 [010] 826.477229: tcp:tcp_rcvbuf_grow: time=50241 rtt_us=50078 copied=10731520 inq=180224 space=7577600 ooo=0 scaling_ratio=219 rcvbuf=17715667 rcv_ssthresh=15136529 window_clamp=15155199 rcv_wnd=14983168 tcp_stream 33793 [010] 826.527482: tcp:tcp_rcvbuf_grow: time=50258 rtt_us=50153 copied=15138816 inq=360448 space=10551296 ooo=0 scaling_ratio=219 rcvbuf=24667870 rcv_ssthresh=21073410 window_clamp=21102591 rcv_wnd=20766720 tcp_stream 33793 [010] 826.577712: tcp:tcp_rcvbuf_grow: time=50234 rtt_us=50228 copied=21073920 inq=0 space=14778368 ooo=0 scaling_ratio=219 rcvbuf=34550339 rcv_ssthresh=29517041 window_clamp=29556735 rcv_wnd=29519872 tcp_stream 33793 [010] 826.627982: tcp:tcp_rcvbuf_grow: time=50275 rtt_us=50220 copied=29519872 inq=540672 space=21073920 ooo=0 scaling_ratio=219 rcvbuf=49268707 rcv_ssthresh=42090625 window_clamp=42147839 rcv_wnd=41627648 tcp_stream 33793 [010] 826.678274: tcp:tcp_rcvbuf_grow: time=50296 rtt_us=50185 copied=42053632 inq=761856 space=28979200 ooo=0 scaling_ratio=219 rcvbuf=67000000 rcv_ssthresh=57238168 window_clamp=57316406 rcv_wnd=56606720 tcp_stream 33793 [010] 826.728627: tcp:tcp_rcvbuf_grow: time=50357 rtt_us=50128 copied=43913216 inq=851968 space=41291776 ooo=0 scaling_ratio=219 rcvbuf=67000000 rcv_ssthresh=57290728 window_clamp=57316406 rcv_wnd=56524800 tcp_stream 33793 [010] 827.131364: tcp:tcp_rcvbuf_grow: time=50239 rtt_us=50127 copied=43843584 inq=655360 space=43061248 ooo=0 scaling_ratio=219 rcvbuf=67000000 rcv_ssthresh=57290728 window_clamp=57316406 rcv_wnd=56696832 tcp_stream 33793 [010] 827.181613: tcp:tcp_rcvbuf_grow: time=50254 rtt_us=50115 copied=43843584 inq=524288 space=43188224 ooo=0 scaling_ratio=219 rcvbuf=67000000 rcv_ssthresh=57290728 window_clamp=57316406 rcv_wnd=56807424 tcp_stream 33793 [010] 828.339635: tcp:tcp_rcvbuf_grow: time=50283 rtt_us=50110 copied=43843584 inq=458752 space=43319296 ooo=0 scaling_ratio=219 rcvbuf=67000000 rcv_ssthresh=57290728 window_clamp=57316406 rcv_wnd=56864768 tcp_stream 33793 [010] 828.440350: tcp:tcp_rcvbuf_grow: time=50404 rtt_us=50099 copied=43843584 inq=393216 space=43384832 ooo=0 scaling_ratio=219 rcvbuf=67000000 rcv_ssthresh=57290728 window_clamp=57316406 rcv_wnd=56922112 tcp_stream 33793 [010] 829.195106: tcp:tcp_rcvbuf_grow: time=50154 rtt_us=50077 copied=43843584 inq=196608 space=43450368 ooo=0 scaling_ratio=219 rcvbuf=67000000 rcv_ssthresh=57290728 window_clamp=57316406 rcv_wnd=57090048After:
It takes few steps to increase RWIN. Sender is no longer RWIN limited.
tcp_stream 50826 [010] 935.634212: tcp:tcp_rcvbuf_grow: time=100788 rtt_us=50315 copied=49152 inq=0 space=40960 ooo=0 scaling_ratio=219 rcvbuf=131072 rcv_ssthresh=103970 window_clamp=112128 rcv_wnd=106496 tcp_stream 50826 [010] 935.685642: tcp:tcp_rcvbuf_grow: time=51437 rtt_us=50361 copied=86016 inq=0 space=49152 ooo=0 scaling_ratio=219 rcvbuf=160875 rcv_ssthresh=132969 window_clamp=137623 rcv_wnd=131072 tcp_stream 50826 [010] 935.738299: tcp:tcp_rcvbuf_grow: time=52660 rtt_us=50256 copied=139264 inq=0 space=86016 ooo=0 scaling_ratio=219 rcvbuf=502741 rcv_ssthresh=411497 window_clamp=430079 rcv_wnd=413696 tcp_stream 50826 [010] 935.788544: tcp:tcp_rcvbuf_grow: time=50249 rtt_us=50233 copied=307200 inq=0 space=139264 ooo=0 scaling_ratio=219 rcvbuf=728690 rcv_ssthresh=618717 window_clamp=623371 rcv_wnd=618496 tcp_stream 50826 [010] 935.838796: tcp:tcp_rcvbuf_grow: time=50258 rtt_us=50202 copied=618496 inq=0 space=307200 ooo=0 scaling_ratio=219 rcvbuf=2450338 rcv_ssthresh=1855709 window_clamp=2096187 rcv_wnd=1859584 tcp_stream 50826 [010] 935.889140: tcp:tcp_rcvbuf_grow: time=50347 rtt_us=50166 copied=1261568 inq=0 space=618496 ooo=0 scaling_ratio=219 rcvbuf=4376503 rcv_ssthresh=3725291 window_clamp=3743961 rcv_wnd=3706880 tcp_stream 50826 [010] 935.939435: tcp:tcp_rcvbuf_grow: time=50300 rtt_us=50185 copied=2478080 inq=24576 space=1261568 ooo=0 scaling_ratio=219 rcvbuf=9082648 rcv_ssthresh=7733731 window_clamp=7769921 rcv_wnd=7692288 tcp_stream 50826 [010] 935.989681: tcp:tcp_rcvbuf_grow: time=50251 rtt_us=50221 copied=4915200 inq=114688 space=2453504 ooo=0 scaling_ratio=219 rcvbuf=16574936 rcv_ssthresh=14108110 window_clamp=14179339 rcv_wnd=14024704 tcp_stream 50826 [010] 936.039967: tcp:tcp_rcvbuf_grow: time=50289 rtt_us=50279 copied=9830400 inq=114688 space=4800512 ooo=0 scaling_ratio=219 rcvbuf=32695050 rcv_ssthresh=27896187 window_clamp=27969593 rcv_wnd=27815936 tcp_stream 50826 [010] 936.090172: tcp:tcp_rcvbuf_grow: time=50211 rtt_us=50200 copied=19841024 inq=114688 space=9715712 ooo=0 scaling_ratio=219 rcvbuf=67000000 rcv_ssthresh=57245176 window_clamp=57316406 rcv_wnd=57163776 tcp_stream 50826 [010] 936.140430: tcp:tcp_rcvbuf_grow: time=50262 rtt_us=50197 copied=39501824 inq=114688 space=19726336 ooo=0 scaling_ratio=219 rcvbuf=67000000 rcv_ssthresh=57245176 window_clamp=57316406 rcv_wnd=57163776 tcp_stream 50826 [010] 936.190527: tcp:tcp_rcvbuf_grow: time=50101 rtt_us=50071 copied=43655168 inq=262144 space=39387136 ooo=0 scaling_ratio=219 rcvbuf=67000000 rcv_ssthresh=57259192 window_clamp=57316406 rcv_wnd=57032704 tcp_stream 50826 [010] 936.240719: tcp:tcp_rcvbuf_grow: time=50197 rtt_us=50057 copied=43843584 inq=262144 space=43393024 ooo=0 scaling_ratio=219 rcvbuf=67000000 rcv_ssthresh=57259192 window_clamp=57316406 rcv_wnd=57032704 tcp_stream 50826 [010] 936.341271: tcp:tcp_rcvbuf_grow: time=50297 rtt_us=50123 copied=43843584 inq=131072 space=43581440 ooo=0 scaling_ratio=219 rcvbuf=67000000 rcv_ssthresh=57259192 window_clamp=57316406 rcv_wnd=57147392 tcp_stream 50826 [010] 936.642503: tcp:tcp_rcvbuf_grow: time=50131 rtt_us=50084 copied=43843584 inq=0 space=43712512 ooo=0 scaling_ratio=219 rcvbuf=67000000 rcv_ssthresh=57259192 window_clamp=57316406 rcv_wnd=57262080Fixes 65c5287892e9 ("tcp: fix sk_rcvbuf overshoot")Fixes e118cdc34dd1 ("mptcp: rcvbuf auto-tuning improvement")Reported-by Neal Cardwell <[email protected]>Signed-off-by Eric Dumazet <[email protected]>--- net/ipv4/tcp_input.c | 8 +++++++- net/mptcp/protocol.c | 7 +++++++ 2 files changed, 14 insertions(+), 1 deletion(-)net/ipv4/tcp_input.c +2
-1@@ -896,6 +896,7 @@ void tcp_rcvbuf_grow(struct sock *sk, u32 newval)const struct net *net =sock_net (sk);struct tcp_sock *tp =tcp_sk (sk);u32 rcvwin, rcvbuf, cap, oldval; +u64 grow; oldval = tp->rcvq_space.space; tp->rcvq_space.space = newval;@@ -904,9 +905,14 @@ void tcp_rcvbuf_grow(struct sock *sk, u32 newval) (sk->sk_userlocks & SOCK_RCVBUF_LOCK))return ; -/* slow start: allow the sender to double its rate. */ +/* DRS is always one RTT late. */ net/ipv4/tcp_input.c void tcp_rcvbuf_grow(struct sock *sk, u32 newval) · line 918
Quoted 10 lines
net/ipv4/tcp_input.c +5
-0rcvwin = newval <<1 ; +/* slow start: allow the sender to double its rate. */ + grow = (u64 )rcvwin * (newval - oldval); +do_div (grow, oldval); + rcvwin += grow <<1 ; +if (!RB_EMPTY_ROOT (&tp->out_of_order_queue)) rcvwin +=TCP_SKB_CB (tp->ooo_last_skb)->end_seq - tp->rcv_nxt;Hi Eric,
When applying this series I see a regression in a simple 25G iperf test:
retransmissions are seen due to packet drops (out of buffer) on the server side.The test:
- server: iperf3 -s -A 5
- client: iperf3 -c 1.1.1.1 -B 25G
- Configuration:
- Server has a single queue with affinity set on CPU 5.
- Ring size: 1K (4K ring size seems ok)
- MTU: 1500
- Client uses TSO, server uses SW GRO.Before series (includes first patch):
<...>-2192 [005] 162.451893: tcp_rcvbuf_grow: time=1622 rtt_us=1596 copied=76781 inq=30408 space=14480 ooo=0 scaling_ratio=188 rcvbuf=131072 rcv_ssthresh=91990 window_clamp=96256 rcv_wnd=66560 <...>-2192 [005] 162.451998: tcp_rcvbuf_grow: time=106 rtt_us=105 copied=158720 inq=0 space=46373 ooo=0 scaling_ratio=188 rcvbuf=131072 rcv_ssthresh=91990 window_clamp=96256 rcv_wnd=92160 <...>-2192 [005] 162.453254: tcp_rcvbuf_grow: time=142 rtt_us=44 copied=292496 inq=91512 space=158720 ooo=0 scaling_ratio=188 rcvbuf=432258 rcv_ssthresh=270533 window_clamp=317439 rcv_wnd=253952 <...>-2192 [005] 162.454446: tcp_rcvbuf_grow: time=113 rtt_us=44 copied=343176 inq=127424 space=200984 ooo=0 scaling_ratio=188 rcvbuf=547360 rcv_ssthresh=349656 window_clamp=401967 rcv_wnd=345088 <...>-2192 [005] 162.455726: tcp_rcvbuf_grow: time=52 rtt_us=44 copied=264464 inq=40544 space=215752 ooo=0 scaling_ratio=188 rcvbuf=587579 rcv_ssthresh=391036 window_clamp=431503 rcv_wnd=194560 <...>-2192 [005] 162.456444: tcp_rcvbuf_grow: time=37 rtt_us=36 copied=322560 inq=0 space=223920 ooo=0 scaling_ratio=188 rcvbuf=609824 rcv_ssthresh=391036 window_clamp=447839 rcv_wnd=323584 <...>-2192 [005] 162.456865: tcp_rcvbuf_grow: time=40 rtt_us=36 copied=421840 inq=73848 space=322560 ooo=0 scaling_ratio=188 rcvbuf=878461 rcv_ssthresh=581105 window_clamp=645119 rcv_wnd=515072 <...>-2192 [005] 162.457762: tcp_rcvbuf_grow: time=38 rtt_us=36 copied=430176 inq=65160 space=347992 ooo=0 scaling_ratio=188 rcvbuf=947722 rcv_ssthresh=631969 window_clamp=695983 rcv_wnd=467968 <...>-2192 [005] 162.463191: tcp_rcvbuf_grow: time=35 rtt_us=34 copied=411336 inq=0 space=365016 ooo=0 scaling_ratio=188 rcvbuf=994086 rcv_ssthresh=666017 window_clamp=730031 rcv_wnd=354304 <...>-2192 [005] 162.469069: tcp_rcvbuf_grow: time=38 rtt_us=34 copied=444520 inq=0 space=411336 ooo=0 scaling_ratio=188 rcvbuf=1120234 rcv_ssthresh=783379 window_clamp=822671 rcv_wnd=679936
Quoted 2 lines
Quoted 2 lines
After series:
<...>-2585 [005] 1061.768676:tcp_rcvbuf_grow: time=623 rtt_us=600 copied=72437 inq=28960 space=14480 ooo=0 scaling_ratio=188 rcvbuf=131072 rcv_ssthresh=81968 window_clamp=96256 rcv_wnd=82944
Looking again, it seems the initial rtt_us is much bigger than the rtt_us of 55 usec you have later (or 34 usec on previous samples)
DRS is fooled by the apparent explosion (more than traditional Slow Start) of the incoming traffic.
1) Do you have a large initial cwnd ? (standard is IW10)
2) iperf3 does not seem to be able to read the queue fast enough. Is it reading 1000 bytes at a time ?
Quoted 22 lines
Quoted 11 lines
<...>-2585 [005] 1061.769859: tcp_rcvbuf_grow: time=89 rtt_us=55 copied=250560 inq=46336 space=43477 ooo=0 scaling_ratio=188 rcvbuf=592631 rcv_ssthresh=302062 window_clamp=435213 rcv_wnd=230400 <...>-2585 [005] 1061.775618: tcp_rcvbuf_grow: time=56 rtt_us=55 copied=405296 inq=140016 space=204224 ooo=0 scaling_ratio=188 rcvbuf=4668930 rcv_ssthresh=1927847 window_clamp=3428745 rcv_wnd=1928192 <...>-2585 [005] 1061.777324: tcp_rcvbuf_grow: time=57 rtt_us=55 copied=450664 inq=131072 space=265280 ooo=0 scaling_ratio=188 rcvbuf=4668930 rcv_ssthresh=3106743 window_clamp=3428745 rcv_wnd=3006464 <...>-2585 [005] 1061.783411: tcp_rcvbuf_grow: time=58 rtt_us=55 copied=521280 inq=41160 space=319592 ooo=0 scaling_ratio=188 rcvbuf=4668930 rcv_ssthresh=3364731 window_clamp=3428745 rcv_wnd=2086912 <...>-2585 [005] 1061.790393: tcp_rcvbuf_grow: time=55 rtt_us=55 copied=524288 inq=0 space=480120 ooo=0 scaling_ratio=188 rcvbuf=4668930 rcv_ssthresh=3364731 window_clamp=3428745 rcv_wnd=2492416 <...>-2585 [005] 1061.935387: tcp_rcvbuf_grow: time=55 rtt_us=55 copied=537824 inq=0 space=524288 ooo=0 scaling_ratio=188 rcvbuf=4668930 rcv_ssthresh=3364731 window_clamp=3428745 rcv_wnd=2258944 <...>-2585 [005] 1062.977374: tcp_rcvbuf_grow: time=57 rtt_us=55 copied=545064 inq=0 space=537824 ooo=0 scaling_ratio=188 rcvbuf=4668930 rcv_ssthresh=3428745 window_clamp=3428745 rcv_wnd=2223104 <...>-2585 [005] 1064.873376: tcp_rcvbuf_grow: time=57 rtt_us=55 copied=549408 inq=0 space=545064 ooo=0 scaling_ratio=188 rcvbuf=4668930 rcv_ssthresh=3428745 window_clamp=3428745 rcv_wnd=2509824 <...>-2585 [005] 1065.984340: tcp_rcvbuf_grow: time=59 rtt_us=55 copied=574024 inq=0 space=549408 ooo=0 scaling_ratio=188 rcvbuf=4668930 rcv_ssthresh=3428745 window_clamp=3428745 rcv_wnd=2336768 <...>-2585 [005] 1066.210718: tcp_rcvbuf_grow: time=410 rtt_us=55 copied=589448 inq=0 space=574024 ooo=0 scaling_ratio=188 rcvbuf=4668930 rcv_ssthresh=3428745 window_clamp=3428745 rcv_wnd=3364864Quoted 1 line
Is this expected?
Typical cubic reaction I would say, with
pfifo_fast?I do not think that artificially slowing down senders by not growing rwin fast enough is the right answer.
If you have drops, that is because the sender is sending too fast or with too large burts.
Try using the fq packet scheduler and see if it helps.
Re: [PATCH net-next 3/3] tcp: fix too slow tcp_rcvbuf_grow() action
Quoted 138 lines · Eric Dumazet
Quoted 137 lines · Eric Dumazet
Quoted 135 lines · Dragos Tatulea
Quoted 96 lines · Eric Dumazet
While the blamed commits apparently avoided an overshoot, they also limited how fast a sender can increase BDP at each RTT.
This is not exactly a revert, we do not add the 16 *
tp->advmsscushion we had, and we are keeping theout_of_order_queuecontribution.Do the same in
mptcp_rcvbuf_grow().Tested:
emulated 50ms rtt (
tcp_stream--tcp-tx-delay 50000), cubic 20 second flow. net.ipv4.tcp_rmem set to "4096 131072 67000000"perf record -a -e tcp:tcp_rcvbuf_grow sleep 20
perf scriptBefore:
We can see we fail to roughly double RWIN at each RTT.
Sender is RWIN limited while CWND is ramping up (before gettingtcp_wmemlimited)tcp_stream 33793 [010] 825.717525: tcp:tcp_rcvbuf_grow: time=100869 rtt_us=50428 copied=49152 inq=0 space=40960 ooo=0 scaling_ratio=219 rcvbuf=131072 rcv_ssthresh=103970 window_clamp=112128 rcv_wnd=106496 tcp_stream 33793 [010] 825.768966: tcp:tcp_rcvbuf_grow: time=51447 rtt_us=50362 copied=86016 inq=0 space=49152 ooo=0 scaling_ratio=219 rcvbuf=131072 rcv_ssthresh=107474 window_clamp=112128 rcv_wnd=106496 tcp_stream 33793 [010] 825.821539: tcp:tcp_rcvbuf_grow: time=52577 rtt_us=50243 copied=114688 inq=0 space=86016 ooo=0 scaling_ratio=219 rcvbuf=201096 rcv_ssthresh=167377 window_clamp=172031 rcv_wnd=167936 tcp_stream 33793 [010] 825.871781: tcp:tcp_rcvbuf_grow: time=50248 rtt_us=50237 copied=167936 inq=0 space=114688 ooo=0 scaling_ratio=219 rcvbuf=268129 rcv_ssthresh=224722 window_clamp=229375 rcv_wnd=225280 tcp_stream 33793 [010] 825.922475: tcp:tcp_rcvbuf_grow: time=50698 rtt_us=50183 copied=241664 inq=0 space=167936 ooo=0 scaling_ratio=219 rcvbuf=392617 rcv_ssthresh=331217 window_clamp=335871 rcv_wnd=323584 tcp_stream 33793 [010] 825.973326: tcp:tcp_rcvbuf_grow: time=50855 rtt_us=50213 copied=339968 inq=0 space=241664 ooo=0 scaling_ratio=219 rcvbuf=564986 rcv_ssthresh=478674 window_clamp=483327 rcv_wnd=462848 tcp_stream 33793 [010] 826.023970: tcp:tcp_rcvbuf_grow: time=50647 rtt_us=50248 copied=491520 inq=0 space=339968 ooo=0 scaling_ratio=219 rcvbuf=794811 rcv_ssthresh=671778 window_clamp=679935 rcv_wnd=651264 tcp_stream 33793 [010] 826.074612: tcp:tcp_rcvbuf_grow: time=50648 rtt_us=50227 copied=700416 inq=0 space=491520 ooo=0 scaling_ratio=219 rcvbuf=1149124 rcv_ssthresh=974881 window_clamp=983039 rcv_wnd=942080 tcp_stream 33793 [010] 826.125452: tcp:tcp_rcvbuf_grow: time=50845 rtt_us=50225 copied=987136 inq=8192 space=700416 ooo=0 scaling_ratio=219 rcvbuf=1637502 rcv_ssthresh=1392674 window_clamp=1400831 rcv_wnd=1339392 tcp_stream 33793 [010] 826.175698: tcp:tcp_rcvbuf_grow: time=50250 rtt_us=50198 copied=1347584 inq=0 space=978944 ooo=0 scaling_ratio=219 rcvbuf=2288672 rcv_ssthresh=1949729 window_clamp=1957887 rcv_wnd=1945600 tcp_stream 33793 [010] 826.225947: tcp:tcp_rcvbuf_grow: time=50252 rtt_us=50240 copied=1945600 inq=0 space=1347584 ooo=0 scaling_ratio=219 rcvbuf=3150516 rcv_ssthresh=2687010 window_clamp=2695167 rcv_wnd=2691072 tcp_stream 33793 [010] 826.276175: tcp:tcp_rcvbuf_grow: time=50233 rtt_us=50224 copied=2691072 inq=0 space=1945600 ooo=0 scaling_ratio=219 rcvbuf=4548617 rcv_ssthresh=3883041 window_clamp=3891199 rcv_wnd=3887104 tcp_stream 33793 [010] 826.326403: tcp:tcp_rcvbuf_grow: time=50233 rtt_us=50229 copied=3887104 inq=0 space=2691072 ooo=0 scaling_ratio=219 rcvbuf=6291456 rcv_ssthresh=5370482 window_clamp=5382144 rcv_wnd=5373952 tcp_stream 33793 [010] 826.376723: tcp:tcp_rcvbuf_grow: time=50323 rtt_us=50218 copied=5373952 inq=0 space=3887104 ooo=0 scaling_ratio=219 rcvbuf=9087658 rcv_ssthresh=7755537 window_clamp=7774207 rcv_wnd=7757824 tcp_stream 33793 [010] 826.426991: tcp:tcp_rcvbuf_grow: time=50274 rtt_us=50196 copied=7757824 inq=180224 space=5373952 ooo=0 scaling_ratio=219 rcvbuf=12563759 rcv_ssthresh=10729233 window_clamp=10747903 rcv_wnd=10575872 tcp_stream 33793 [010] 826.477229: tcp:tcp_rcvbuf_grow: time=50241 rtt_us=50078 copied=10731520 inq=180224 space=7577600 ooo=0 scaling_ratio=219 rcvbuf=17715667 rcv_ssthresh=15136529 window_clamp=15155199 rcv_wnd=14983168 tcp_stream 33793 [010] 826.527482: tcp:tcp_rcvbuf_grow: time=50258 rtt_us=50153 copied=15138816 inq=360448 space=10551296 ooo=0 scaling_ratio=219 rcvbuf=24667870 rcv_ssthresh=21073410 window_clamp=21102591 rcv_wnd=20766720 tcp_stream 33793 [010] 826.577712: tcp:tcp_rcvbuf_grow: time=50234 rtt_us=50228 copied=21073920 inq=0 space=14778368 ooo=0 scaling_ratio=219 rcvbuf=34550339 rcv_ssthresh=29517041 window_clamp=29556735 rcv_wnd=29519872 tcp_stream 33793 [010] 826.627982: tcp:tcp_rcvbuf_grow: time=50275 rtt_us=50220 copied=29519872 inq=540672 space=21073920 ooo=0 scaling_ratio=219 rcvbuf=49268707 rcv_ssthresh=42090625 window_clamp=42147839 rcv_wnd=41627648 tcp_stream 33793 [010] 826.678274: tcp:tcp_rcvbuf_grow: time=50296 rtt_us=50185 copied=42053632 inq=761856 space=28979200 ooo=0 scaling_ratio=219 rcvbuf=67000000 rcv_ssthresh=57238168 window_clamp=57316406 rcv_wnd=56606720 tcp_stream 33793 [010] 826.728627: tcp:tcp_rcvbuf_grow: time=50357 rtt_us=50128 copied=43913216 inq=851968 space=41291776 ooo=0 scaling_ratio=219 rcvbuf=67000000 rcv_ssthresh=57290728 window_clamp=57316406 rcv_wnd=56524800 tcp_stream 33793 [010] 827.131364: tcp:tcp_rcvbuf_grow: time=50239 rtt_us=50127 copied=43843584 inq=655360 space=43061248 ooo=0 scaling_ratio=219 rcvbuf=67000000 rcv_ssthresh=57290728 window_clamp=57316406 rcv_wnd=56696832 tcp_stream 33793 [010] 827.181613: tcp:tcp_rcvbuf_grow: time=50254 rtt_us=50115 copied=43843584 inq=524288 space=43188224 ooo=0 scaling_ratio=219 rcvbuf=67000000 rcv_ssthresh=57290728 window_clamp=57316406 rcv_wnd=56807424 tcp_stream 33793 [010] 828.339635: tcp:tcp_rcvbuf_grow: time=50283 rtt_us=50110 copied=43843584 inq=458752 space=43319296 ooo=0 scaling_ratio=219 rcvbuf=67000000 rcv_ssthresh=57290728 window_clamp=57316406 rcv_wnd=56864768 tcp_stream 33793 [010] 828.440350: tcp:tcp_rcvbuf_grow: time=50404 rtt_us=50099 copied=43843584 inq=393216 space=43384832 ooo=0 scaling_ratio=219 rcvbuf=67000000 rcv_ssthresh=57290728 window_clamp=57316406 rcv_wnd=56922112 tcp_stream 33793 [010] 829.195106: tcp:tcp_rcvbuf_grow: time=50154 rtt_us=50077 copied=43843584 inq=196608 space=43450368 ooo=0 scaling_ratio=219 rcvbuf=67000000 rcv_ssthresh=57290728 window_clamp=57316406 rcv_wnd=57090048After:
It takes few steps to increase RWIN. Sender is no longer RWIN limited.
tcp_stream 50826 [010] 935.634212: tcp:tcp_rcvbuf_grow: time=100788 rtt_us=50315 copied=49152 inq=0 space=40960 ooo=0 scaling_ratio=219 rcvbuf=131072 rcv_ssthresh=103970 window_clamp=112128 rcv_wnd=106496 tcp_stream 50826 [010] 935.685642: tcp:tcp_rcvbuf_grow: time=51437 rtt_us=50361 copied=86016 inq=0 space=49152 ooo=0 scaling_ratio=219 rcvbuf=160875 rcv_ssthresh=132969 window_clamp=137623 rcv_wnd=131072 tcp_stream 50826 [010] 935.738299: tcp:tcp_rcvbuf_grow: time=52660 rtt_us=50256 copied=139264 inq=0 space=86016 ooo=0 scaling_ratio=219 rcvbuf=502741 rcv_ssthresh=411497 window_clamp=430079 rcv_wnd=413696 tcp_stream 50826 [010] 935.788544: tcp:tcp_rcvbuf_grow: time=50249 rtt_us=50233 copied=307200 inq=0 space=139264 ooo=0 scaling_ratio=219 rcvbuf=728690 rcv_ssthresh=618717 window_clamp=623371 rcv_wnd=618496 tcp_stream 50826 [010] 935.838796: tcp:tcp_rcvbuf_grow: time=50258 rtt_us=50202 copied=618496 inq=0 space=307200 ooo=0 scaling_ratio=219 rcvbuf=2450338 rcv_ssthresh=1855709 window_clamp=2096187 rcv_wnd=1859584 tcp_stream 50826 [010] 935.889140: tcp:tcp_rcvbuf_grow: time=50347 rtt_us=50166 copied=1261568 inq=0 space=618496 ooo=0 scaling_ratio=219 rcvbuf=4376503 rcv_ssthresh=3725291 window_clamp=3743961 rcv_wnd=3706880 tcp_stream 50826 [010] 935.939435: tcp:tcp_rcvbuf_grow: time=50300 rtt_us=50185 copied=2478080 inq=24576 space=1261568 ooo=0 scaling_ratio=219 rcvbuf=9082648 rcv_ssthresh=7733731 window_clamp=7769921 rcv_wnd=7692288 tcp_stream 50826 [010] 935.989681: tcp:tcp_rcvbuf_grow: time=50251 rtt_us=50221 copied=4915200 inq=114688 space=2453504 ooo=0 scaling_ratio=219 rcvbuf=16574936 rcv_ssthresh=14108110 window_clamp=14179339 rcv_wnd=14024704 tcp_stream 50826 [010] 936.039967: tcp:tcp_rcvbuf_grow: time=50289 rtt_us=50279 copied=9830400 inq=114688 space=4800512 ooo=0 scaling_ratio=219 rcvbuf=32695050 rcv_ssthresh=27896187 window_clamp=27969593 rcv_wnd=27815936 tcp_stream 50826 [010] 936.090172: tcp:tcp_rcvbuf_grow: time=50211 rtt_us=50200 copied=19841024 inq=114688 space=9715712 ooo=0 scaling_ratio=219 rcvbuf=67000000 rcv_ssthresh=57245176 window_clamp=57316406 rcv_wnd=57163776 tcp_stream 50826 [010] 936.140430: tcp:tcp_rcvbuf_grow: time=50262 rtt_us=50197 copied=39501824 inq=114688 space=19726336 ooo=0 scaling_ratio=219 rcvbuf=67000000 rcv_ssthresh=57245176 window_clamp=57316406 rcv_wnd=57163776 tcp_stream 50826 [010] 936.190527: tcp:tcp_rcvbuf_grow: time=50101 rtt_us=50071 copied=43655168 inq=262144 space=39387136 ooo=0 scaling_ratio=219 rcvbuf=67000000 rcv_ssthresh=57259192 window_clamp=57316406 rcv_wnd=57032704 tcp_stream 50826 [010] 936.240719: tcp:tcp_rcvbuf_grow: time=50197 rtt_us=50057 copied=43843584 inq=262144 space=43393024 ooo=0 scaling_ratio=219 rcvbuf=67000000 rcv_ssthresh=57259192 window_clamp=57316406 rcv_wnd=57032704 tcp_stream 50826 [010] 936.341271: tcp:tcp_rcvbuf_grow: time=50297 rtt_us=50123 copied=43843584 inq=131072 space=43581440 ooo=0 scaling_ratio=219 rcvbuf=67000000 rcv_ssthresh=57259192 window_clamp=57316406 rcv_wnd=57147392 tcp_stream 50826 [010] 936.642503: tcp:tcp_rcvbuf_grow: time=50131 rtt_us=50084 copied=43843584 inq=0 space=43712512 ooo=0 scaling_ratio=219 rcvbuf=67000000 rcv_ssthresh=57259192 window_clamp=57316406 rcv_wnd=57262080Fixes 65c5287892e9 ("tcp: fix sk_rcvbuf overshoot")Fixes e118cdc34dd1 ("mptcp: rcvbuf auto-tuning improvement")Reported-by Neal Cardwell <[email protected]>Signed-off-by Eric Dumazet <[email protected]>--- net/ipv4/tcp_input.c | 8 +++++++- net/mptcp/protocol.c | 7 +++++++ 2 files changed, 14 insertions(+), 1 deletion(-)net/ipv4/tcp_input.c +2
-1@@ -896,6 +896,7 @@ void tcp_rcvbuf_grow(struct sock *sk, u32 newval)const struct net *net =sock_net (sk);struct tcp_sock *tp =tcp_sk (sk);u32 rcvwin, rcvbuf, cap, oldval; +u64 grow; oldval = tp->rcvq_space.space; tp->rcvq_space.space = newval;@@ -904,9 +905,14 @@ void tcp_rcvbuf_grow(struct sock *sk, u32 newval) (sk->sk_userlocks & SOCK_RCVBUF_LOCK))return ; -/* slow start: allow the sender to double its rate. */ +/* DRS is always one RTT late. */ net/ipv4/tcp_input.c void tcp_rcvbuf_grow(struct sock *sk, u32 newval) · line 918
Quoted 10 lines
net/ipv4/tcp_input.c +5
-0rcvwin = newval <<1 ; +/* slow start: allow the sender to double its rate. */ + grow = (u64 )rcvwin * (newval - oldval); +do_div (grow, oldval); + rcvwin += grow <<1 ; +if (!RB_EMPTY_ROOT (&tp->out_of_order_queue)) rcvwin +=TCP_SKB_CB (tp->ooo_last_skb)->end_seq - tp->rcv_nxt;Hi Eric,
When applying this series I see a regression in a simple 25G iperf test:
retransmissions are seen due to packet drops (out of buffer) on the server side.The test:
- server: iperf3 -s -A 5
- client: iperf3 -c 1.1.1.1 -B 25G
- Configuration:
- Server has a single queue with affinity set on CPU 5.
- Ring size: 1K (4K ring size seems ok)
- MTU: 1500
- Client uses TSO, server uses SW GRO.Before series (includes first patch):
<...>-2192 [005] 162.451893: tcp_rcvbuf_grow: time=1622 rtt_us=1596 copied=76781 inq=30408 space=14480 ooo=0 scaling_ratio=188 rcvbuf=131072 rcv_ssthresh=91990 window_clamp=96256 rcv_wnd=66560 <...>-2192 [005] 162.451998: tcp_rcvbuf_grow: time=106 rtt_us=105 copied=158720 inq=0 space=46373 ooo=0 scaling_ratio=188 rcvbuf=131072 rcv_ssthresh=91990 window_clamp=96256 rcv_wnd=92160 <...>-2192 [005] 162.453254: tcp_rcvbuf_grow: time=142 rtt_us=44 copied=292496 inq=91512 space=158720 ooo=0 scaling_ratio=188 rcvbuf=432258 rcv_ssthresh=270533 window_clamp=317439 rcv_wnd=253952 <...>-2192 [005] 162.454446: tcp_rcvbuf_grow: time=113 rtt_us=44 copied=343176 inq=127424 space=200984 ooo=0 scaling_ratio=188 rcvbuf=547360 rcv_ssthresh=349656 window_clamp=401967 rcv_wnd=345088 <...>-2192 [005] 162.455726: tcp_rcvbuf_grow: time=52 rtt_us=44 copied=264464 inq=40544 space=215752 ooo=0 scaling_ratio=188 rcvbuf=587579 rcv_ssthresh=391036 window_clamp=431503 rcv_wnd=194560 <...>-2192 [005] 162.456444: tcp_rcvbuf_grow: time=37 rtt_us=36 copied=322560 inq=0 space=223920 ooo=0 scaling_ratio=188 rcvbuf=609824 rcv_ssthresh=391036 window_clamp=447839 rcv_wnd=323584 <...>-2192 [005] 162.456865: tcp_rcvbuf_grow: time=40 rtt_us=36 copied=421840 inq=73848 space=322560 ooo=0 scaling_ratio=188 rcvbuf=878461 rcv_ssthresh=581105 window_clamp=645119 rcv_wnd=515072 <...>-2192 [005] 162.457762: tcp_rcvbuf_grow: time=38 rtt_us=36 copied=430176 inq=65160 space=347992 ooo=0 scaling_ratio=188 rcvbuf=947722 rcv_ssthresh=631969 window_clamp=695983 rcv_wnd=467968 <...>-2192 [005] 162.463191: tcp_rcvbuf_grow: time=35 rtt_us=34 copied=411336 inq=0 space=365016 ooo=0 scaling_ratio=188 rcvbuf=994086 rcv_ssthresh=666017 window_clamp=730031 rcv_wnd=354304 <...>-2192 [005] 162.469069: tcp_rcvbuf_grow: time=38 rtt_us=34 copied=444520 inq=0 space=411336 ooo=0 scaling_ratio=188 rcvbuf=1120234 rcv_ssthresh=783379 window_clamp=822671 rcv_wnd=679936
Quoted 6 lines
Quoted 2 lines
Quoted 2 lines
After series:
<...>-2585 [005] 1061.768676:tcp_rcvbuf_grow: time=623 rtt_us=600 copied=72437 inq=28960 space=14480 ooo=0 scaling_ratio=188 rcvbuf=131072 rcv_ssthresh=81968 window_clamp=96256 rcv_wnd=82944Looking again, it seems the initial
rtt_usis much bigger than thertt_usof 55 usec you have later (or 34 usec on previous samples)
Right. It is bigger in both cases. Didn't realize that it is not expected.
Quoted 4 lines
DRS is fooled by the apparent explosion (more than traditional Slow Start) of the incoming traffic.
1) Do you have a large initial cwnd ? (standard is IW10)
Nope:
09.390218 IP 1.1.1.2.45754 > 1.1.1.1.5201: Flags [S], seq 2278471684, win 64240, options [mss 1460,sackOK,TS val 4277109415 ecr 0,nop,wscale 10], length 0 09.390224 IP 1.1.1.1.5201 > 1.1.1.2.45754: Flags [S.], seq 533508084, ack 2278471685, win 65160, options [mss 1460,sackOK,TS val 1442753584 ecr 4277109415,nop,wscale 10], length 0 09.390242 IP 1.1.1.2.45754 > 1.1.1.1.5201: Flags [.], ack 1, win 63, options [nop,nop,TS val 4277109415 ecr 1442753584], length 0
09.390248 IP 1.1.1.2.45754 > 1.1.1.1.5201: Flags [P.], seq 1:38, ack 1, win 63, options [nop,nop,TS val 4277109415 ecr 1442753584], length 37 09.390250 IP 1.1.1.1.5201 > 1.1.1.2.45754: Flags [.], ack 38, win 64, options [nop,nop,TS val 1442753584 ecr 4277109415], length 0
09.390722 IP 1.1.1.1.5201 > 1.1.1.2.45742: Flags [P.], seq 3:4, ack 171, win 64, options [nop,nop,TS val 1442753584 ecr 4277109415], length 1 09.390727 IP 1.1.1.1.5201 > 1.1.1.2.45742: Flags [P.], seq 4:5, ack 171, win 64, options [nop,nop,TS val 1442753584 ecr 4277109415], length 1 09.390746 IP 1.1.1.2.45742 > 1.1.1.1.5201: Flags [.], ack 5, win 63, options [nop,nop,TS val 4277109415 ecr 1442753584], length 0
09.390758 IP 1.1.1.2.45754 > 1.1.1.1.5201: Flags [P.], seq 38:7278, ack 1, win 63, options [nop,nop,TS val 4277109415 ecr 1442753584], length 7240 09.390760 IP 1.1.1.2.45754 > 1.1.1.1.5201: Flags [P.], seq 7278:14518, ack 1, win 63, options [nop,nop,TS val 4277109415 ecr 1442753584], length 7240 09.390763 IP 1.1.1.1.5201 > 1.1.1.2.45754: Flags [.], ack 7278, win 79, options [nop,nop,TS val 1442753584 ecr 4277109415], length 0
09.390767 IP 1.1.1.1.5201 > 1.1.1.2.45754: Flags [.], ack 14518, win 81, options [nop,nop,TS val 1442753584 ecr 4277109415], length 0
09.390787 IP 1.1.1.2.45754 > 1.1.1.1.5201: Flags [P.], seq 14518:24654, ack 1, win 63, options [nop,nop,TS val 4277109416 ecr 1442753584], length 10136 09.390789 IP 1.1.1.2.45754 > 1.1.1.1.5201: Flags [P.], seq 24654:39134, ack 1, win 63, options [nop,nop,TS val 4277109416 ecr 1442753584], length 14480 09.390791 IP 1.1.1.1.5201 > 1.1.1.2.45754: Flags [.], ack 24654, win 85, options [nop,nop,TS val 1442753584 ecr 4277109416], length 0
09.390793 IP 1.1.1.1.5201 > 1.1.1.2.45754: Flags [.], ack 39134, win 71, options [nop,nop,TS val 1442753584 ecr 4277109416], length 0
09.390795 IP 1.1.1.2.45754 > 1.1.1.1.5201: Flags [P.], seq 39134:43478, ack 1, win 63, options [nop,nop,TS val 4277109416 ecr 1442753584], length 4344 09.390796 IP 1.1.1.1.5201 > 1.1.1.2.45754: Flags [.], ack 43478, win 67, options [nop,nop,TS val 1442753584 ecr 4277109416], length 0
09.390803 IP 1.1.1.2.45754 > 1.1.1.1.5201: Flags [P.], seq 43478:46374, ack 1, win 63, options [nop,nop,TS val 4277109416 ecr 1442753584], length 2896 09.390805 IP 1.1.1.1.5201 > 1.1.1.2.45754: Flags [.], ack 46374, win 65, options [nop,nop,TS val 1442753584 ecr 4277109416], length 0
09.391880 IP 1.1.1.2.45754 > 1.1.1.1.5201: Flags [P.], seq 46374:76782, ack 1, win 63, options [nop,nop,TS val 4277109417 ecr 1442753584], length 30408
...
Quoted 3 lines
2) iperf3 does not seem to be able to read the queue fast enough. Is it reading 1000 bytes at a time ?
iperf3 is reading 128K bytes at a time.
Quoted 11 lines
Quoted 11 lines
Quoted 11 lines
<...>-2585 [005] 1061.769859: tcp_rcvbuf_grow: time=89 rtt_us=55 copied=250560 inq=46336 space=43477 ooo=0 scaling_ratio=188 rcvbuf=592631 rcv_ssthresh=302062 window_clamp=435213 rcv_wnd=230400 <...>-2585 [005] 1061.775618: tcp_rcvbuf_grow: time=56 rtt_us=55 copied=405296 inq=140016 space=204224 ooo=0 scaling_ratio=188 rcvbuf=4668930 rcv_ssthresh=1927847 window_clamp=3428745 rcv_wnd=1928192 <...>-2585 [005] 1061.777324: tcp_rcvbuf_grow: time=57 rtt_us=55 copied=450664 inq=131072 space=265280 ooo=0 scaling_ratio=188 rcvbuf=4668930 rcv_ssthresh=3106743 window_clamp=3428745 rcv_wnd=3006464 <...>-2585 [005] 1061.783411: tcp_rcvbuf_grow: time=58 rtt_us=55 copied=521280 inq=41160 space=319592 ooo=0 scaling_ratio=188 rcvbuf=4668930 rcv_ssthresh=3364731 window_clamp=3428745 rcv_wnd=2086912 <...>-2585 [005] 1061.790393: tcp_rcvbuf_grow: time=55 rtt_us=55 copied=524288 inq=0 space=480120 ooo=0 scaling_ratio=188 rcvbuf=4668930 rcv_ssthresh=3364731 window_clamp=3428745 rcv_wnd=2492416 <...>-2585 [005] 1061.935387: tcp_rcvbuf_grow: time=55 rtt_us=55 copied=537824 inq=0 space=524288 ooo=0 scaling_ratio=188 rcvbuf=4668930 rcv_ssthresh=3364731 window_clamp=3428745 rcv_wnd=2258944 <...>-2585 [005] 1062.977374: tcp_rcvbuf_grow: time=57 rtt_us=55 copied=545064 inq=0 space=537824 ooo=0 scaling_ratio=188 rcvbuf=4668930 rcv_ssthresh=3428745 window_clamp=3428745 rcv_wnd=2223104 <...>-2585 [005] 1064.873376: tcp_rcvbuf_grow: time=57 rtt_us=55 copied=549408 inq=0 space=545064 ooo=0 scaling_ratio=188 rcvbuf=4668930 rcv_ssthresh=3428745 window_clamp=3428745 rcv_wnd=2509824 <...>-2585 [005] 1065.984340: tcp_rcvbuf_grow: time=59 rtt_us=55 copied=574024 inq=0 space=549408 ooo=0 scaling_ratio=188 rcvbuf=4668930 rcv_ssthresh=3428745 window_clamp=3428745 rcv_wnd=2336768 <...>-2585 [005] 1066.210718: tcp_rcvbuf_grow: time=410 rtt_us=55 copied=589448 inq=0 space=574024 ooo=0 scaling_ratio=188 rcvbuf=4668930 rcv_ssthresh=3428745 window_clamp=3428745 rcv_wnd=3364864
Quoted 4 lines
Quoted 4 lines
Quoted 1 line
Is this expected?
Typical cubic reaction I would say, with
pfifo_fast?
Yes.
Quoted 7 lines
Quoted 7 lines
I do not think that artificially slowing down senders by not growing rwin fast enough is the right answer.
If you have drops, that is because the sender is sending too fast or with too large burts.
Try using the fq packet scheduler and see if it helps.
Switched to fq on the sender but it didn't help. I suppose that in this case having pfifo_fast on the receiver doesn't change much.
Thanks,
Dragos