Skip to content

Commit

Permalink
tcp: Set rcv zerocopy hint correctly if skb last frag is < PAGE_SIZE
Browse files Browse the repository at this point in the history
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>
Signed-off-by: Jakub Kicinski <jakub.kicinski@netronome.com>
  • Loading branch information
Arjun Roy authored and Jakub Kicinski committed Dec 15, 2019
1 parent 29115ce commit 0e62719
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions net/ipv4/tcp.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit 0e62719

Please sign in to comment.