Skip to contentSkip to conversation

tcp: autocork: take MSG_EOR hint into consideration

PATCH Applied Eric Dumazet 3 participants 3 messages Mar 9, 2022 – Mar 10, 2022

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 tcp: autocork: take MSG_EOR hint into consideration

From: Eric Dumazet <[email protected]>

tcp_should_autocork() is evaluating if it makes senses to not immediately send current skb, hoping that user space will add more payload on it by the time TCP stack reacts to upcoming TX completions.

If current skb got MSG_EOR mark, then we know that no further data will be added, it is therefore futile to wait.

SOF_TIMESTAMPING_TX_ACK will become a bit more accurate, if prior packets are still in qdisc/device queues.

Cc Martin KaFai Lau <[email protected]>
Cc Soheil Hassas Yeganeh <[email protected]>
Cc Willem de Bruijn <[email protected]>
---
 net/ipv4/tcp.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
net/ipv4/tcp.c +2 -1
index 33f20134e3f19c1cd8a4046a2f88533693a9a912..b6a03a121e7694e3e8cc5b4f47b7954a341c966e 100644
@@ -688,7 +688,8 @@ static bool tcp_should_autocork(struct sock *sk, struct sk_buff *skb,
 	return skb->len < size_goal &&
 	       sock_net(sk)->ipv4.sysctl_tcp_autocorking &&
 	       !tcp_rtx_queue_empty(sk) &&
-	       refcount_read(&sk->sk_wmem_alloc) > skb->truesize;
+	       refcount_read(&sk->sk_wmem_alloc) > skb->truesize &&
+	       tcp_skb_can_collapse_to(skb);
 }
 
 void tcp_push(struct sock *sk, int flags, int mss_now,
Signature · 1 line
2.35.1.616.g0bdcbb4464-goog
Acked-by on v1 1/1
#1 lore raw
Quoted 12 lines · Eric Dumazet

From: Eric Dumazet <[email protected]>

tcp_should_autocork() is evaluating if it makes senses to not immediately send current skb, hoping that user space will add more payload on it by the time TCP stack reacts to upcoming TX completions.

If current skb got MSG_EOR mark, then we know that no further data will be added, it is therefore futile to wait.

Quoted 7 lines

SOF_TIMESTAMPING_TX_ACK will become a bit more accurate, if prior packets are still in qdisc/device queues.

Cc Martin KaFai Lau <[email protected]>
Cc Soheil Hassas Yeganeh <[email protected]>
Cc Willem de Bruijn <[email protected]>

Thanks for catching this!

Quoted 21 lines
---
 net/ipv4/tcp.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
net/ipv4/tcp.c +2 -2
index 33f20134e3f19c1cd8a4046a2f88533693a9a912..b6a03a121e7694e3e8cc5b4f47b7954a341c966e 100644
@@ -688,7 +688,8 @@ static bool tcp_should_autocork(struct sock *sk, struct sk_buff *skb,
        return skb->len < size_goal &&
               sock_net(sk)->ipv4.sysctl_tcp_autocorking &&
               !tcp_rtx_queue_empty(sk) &&
-              refcount_read(&sk->sk_wmem_alloc) > skb->truesize;
+              refcount_read(&sk->sk_wmem_alloc) > skb->truesize &&
+              tcp_skb_can_collapse_to(skb);
 }
 
 void tcp_push(struct sock *sk, int flags, int mss_now,
--

2.35.1.616.g0bdcbb4464-goog

#2 lore raw
In reply to Eric Dumazet
This patch was applied to netdev/net-next.git (master) by Jakub Kicinski <[email protected]>:

Hello:

This patch was applied to netdev/net-next.git (master) by Jakub Kicinski <[email protected]>:

Quoted 8 lines · On Tue, 8 Mar 2022 21:47:06 -0800 you wrote:

From: Eric Dumazet <[email protected]>

tcp_should_autocork() is evaluating if it makes senses to not immediately send current skb, hoping that user space will add more payload on it by the time TCP stack reacts to upcoming TX completions.

[...]

Here is the summary with links:
- [net-next] tcp: autocork: take MSG_EOR hint into consideration

    https://git.kernel.org/netdev/net-next/c/b0de0cf4f57c

You are awesome, thank you!

Signature · 2 lines
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html