[net-next,v2] tcp: Set rcv zerocopy hint correctly if skb last frag is < PAGE_SIZE
diff mbox series

Message ID 20191215195451.180553-1-edumazet@google.com
State Accepted
Delegated to: David Miller
Headers show
Series
  • [net-next,v2] tcp: Set rcv zerocopy hint correctly if skb last frag is < PAGE_SIZE
Related show

Commit Message

Eric Dumazet Dec. 15, 2019, 7:54 p.m. UTC
From: Arjun Roy <arjunroy@google.com>

At present, if the last frag of paged data in a skb has < PAGE_SIZE
data, we compute the recv_skip_hint as being equal to the size of that
frag and the entire next skb.

Instead, just return the runt frag size as the hint.

recv_skip_hint is used by the application to skip over
bytes that can not be mmaped, so returning a too big
chunk is pessimistic and forces more bytes to be copied.

Signed-off-by: Arjun Roy <arjunroy@google.com>
Acked-by: Soheil Hassas Yeganeh <soheil@google.com>
Signed-off-by: Eric Dumazet <edumazet@google.com>
---
v2: added more info in the changelog (Jakub)

 net/ipv4/tcp.c | 2 ++
 1 file changed, 2 insertions(+)

Comments

Jakub Kicinski Dec. 15, 2019, 8:15 p.m. UTC | #1
On Sun, 15 Dec 2019 11:54:51 -0800, Eric Dumazet wrote:
> From: Arjun Roy <arjunroy@google.com>
> 
> At present, if the last frag of paged data in a skb has < PAGE_SIZE
> data, we compute the recv_skip_hint as being equal to the size of that
> frag and the entire next skb.
> 
> Instead, just return the runt frag size as the hint.
> 
> recv_skip_hint is used by the application to skip over
> bytes that can not be mmaped, so returning a too big
> chunk is pessimistic and forces more bytes to be copied.
> 
> Signed-off-by: Arjun Roy <arjunroy@google.com>
> Acked-by: Soheil Hassas Yeganeh <soheil@google.com>
> Signed-off-by: Eric Dumazet <edumazet@google.com>

Applied, thank you!!

Patch
diff mbox series

diff --git a/net/ipv4/tcp.c b/net/ipv4/tcp.c
index 09e2cae929565a438b298ab6c0df3e2c263e7a11..93fe77c5b02d631ce0f0742f107c570a81d139fe 100644
--- a/net/ipv4/tcp.c
+++ b/net/ipv4/tcp.c
@@ -1778,6 +1778,8 @@  static int tcp_zerocopy_receive(struct sock *sk,
 	while (length + PAGE_SIZE <= zc->length) {
 		if (zc->recv_skip_hint < PAGE_SIZE) {
 			if (skb) {
+				if (zc->recv_skip_hint > 0)
+					break;
 				skb = skb->next;
 				offset = seq - TCP_SKB_CB(skb)->seq;
 			} else {