Commit 8f2b0293 authored by Soheil Hassas Yeganeh's avatar Soheil Hassas Yeganeh Committed by David S. Miller

tcp: set recv_skip_hint when tcp_inq is less than PAGE_SIZE

When we have less than PAGE_SIZE of data on receive queue,
we set recv_skip_hint to 0. Instead, set it to the actual
number of bytes available.
Signed-off-by: default avatarSoheil Hassas Yeganeh <soheil@google.com>
Signed-off-by: default avatarEric Dumazet <edumazet@google.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 2240c12d
...@@ -1753,6 +1753,7 @@ static int tcp_zerocopy_receive(struct sock *sk, ...@@ -1753,6 +1753,7 @@ static int tcp_zerocopy_receive(struct sock *sk,
struct vm_area_struct *vma; struct vm_area_struct *vma;
struct sk_buff *skb = NULL; struct sk_buff *skb = NULL;
struct tcp_sock *tp; struct tcp_sock *tp;
int inq;
int ret; int ret;
if (address & (PAGE_SIZE - 1) || address != zc->address) if (address & (PAGE_SIZE - 1) || address != zc->address)
...@@ -1773,12 +1774,15 @@ static int tcp_zerocopy_receive(struct sock *sk, ...@@ -1773,12 +1774,15 @@ static int tcp_zerocopy_receive(struct sock *sk,
tp = tcp_sk(sk); tp = tcp_sk(sk);
seq = tp->copied_seq; seq = tp->copied_seq;
zc->length = min_t(u32, zc->length, tcp_inq(sk)); inq = tcp_inq(sk);
zc->length = min_t(u32, zc->length, inq);
zc->length &= ~(PAGE_SIZE - 1); zc->length &= ~(PAGE_SIZE - 1);
if (zc->length) {
zap_page_range(vma, address, zc->length); zap_page_range(vma, address, zc->length);
zc->recv_skip_hint = 0;
zc->recv_skip_hint = 0; } else {
zc->recv_skip_hint = inq;
}
ret = 0; ret = 0;
while (length + PAGE_SIZE <= zc->length) { while (length + PAGE_SIZE <= zc->length) {
if (zc->recv_skip_hint < PAGE_SIZE) { if (zc->recv_skip_hint < PAGE_SIZE) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment