Skip to content

Commit

Permalink
net-zerocopy: Fast return if inq < PAGE_SIZE
Browse files Browse the repository at this point in the history
Sometimes, we may call tcp receive zerocopy when inq is 0,
or inq < PAGE_SIZE, in which case we cannot remap pages. In this case,
simply return the appropriate hint for regular copying without taking
mmap_sem.

Signed-off-by: Arjun Roy <arjunroy@google.com>
Signed-off-by: Eric Dumazet <edumazet@google.com>
Signed-off-by: Soheil Hassas Yeganeh <soheil@google.com>
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
  • Loading branch information
Arjun Roy authored and Jakub Kicinski committed Dec 4, 2020
1 parent 98917cf commit 936ced4
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions net/ipv4/tcp.c
Original file line number Diff line number Diff line change
Expand Up @@ -1904,6 +1904,14 @@ static int tcp_zerocopy_receive(struct sock *sk,

sock_rps_record_flow(sk);

if (inq < PAGE_SIZE) {
zc->length = 0;
zc->recv_skip_hint = inq;
if (!inq && sock_flag(sk, SOCK_DONE))
return -EIO;
return 0;
}

mmap_read_lock(current->mm);

vma = find_vma(current->mm, address);
Expand Down

0 comments on commit 936ced4

Please sign in to comment.