All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH net-next 1/2] tcp: set recv_skip_hint when tcp_inq is less than PAGE_SIZE
@ 2018-09-26 20:57 Soheil Hassas Yeganeh
  2018-09-26 20:57 ` [PATCH net-next 2/2] tcp: adjust rcv zerocopy hints based on frag sizes Soheil Hassas Yeganeh
  2018-10-02  5:37 ` [PATCH net-next 1/2] tcp: set recv_skip_hint when tcp_inq is less than PAGE_SIZE David Miller
  0 siblings, 2 replies; 4+ messages in thread
From: Soheil Hassas Yeganeh @ 2018-09-26 20:57 UTC (permalink / raw)
  To: davem, netdev; +Cc: edumazet, Soheil Hassas Yeganeh

From: Soheil Hassas Yeganeh <soheil@google.com>

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: Soheil Hassas Yeganeh <soheil@google.com>
Signed-off-by: Eric Dumazet <edumazet@google.com>
---
 net/ipv4/tcp.c | 14 +++++++++-----
 1 file changed, 9 insertions(+), 5 deletions(-)

diff --git a/net/ipv4/tcp.c b/net/ipv4/tcp.c
index 69c236943f56..3e17501fc1a1 100644
--- a/net/ipv4/tcp.c
+++ b/net/ipv4/tcp.c
@@ -1753,6 +1753,7 @@ static int tcp_zerocopy_receive(struct sock *sk,
 	struct vm_area_struct *vma;
 	struct sk_buff *skb = NULL;
 	struct tcp_sock *tp;
+	int inq;
 	int ret;
 
 	if (address & (PAGE_SIZE - 1) || address != zc->address)
@@ -1773,12 +1774,15 @@ static int tcp_zerocopy_receive(struct sock *sk,
 
 	tp = tcp_sk(sk);
 	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);
-
-	zap_page_range(vma, address, zc->length);
-
-	zc->recv_skip_hint = 0;
+	if (zc->length) {
+		zap_page_range(vma, address, zc->length);
+		zc->recv_skip_hint = 0;
+	} else {
+		zc->recv_skip_hint = inq;
+	}
 	ret = 0;
 	while (length + PAGE_SIZE <= zc->length) {
 		if (zc->recv_skip_hint < PAGE_SIZE) {
-- 
2.19.0.605.g01d371f741-goog

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [PATCH net-next 2/2] tcp: adjust rcv zerocopy hints based on frag sizes
  2018-09-26 20:57 [PATCH net-next 1/2] tcp: set recv_skip_hint when tcp_inq is less than PAGE_SIZE Soheil Hassas Yeganeh
@ 2018-09-26 20:57 ` Soheil Hassas Yeganeh
  2018-10-02  5:37   ` David Miller
  2018-10-02  5:37 ` [PATCH net-next 1/2] tcp: set recv_skip_hint when tcp_inq is less than PAGE_SIZE David Miller
  1 sibling, 1 reply; 4+ messages in thread
From: Soheil Hassas Yeganeh @ 2018-09-26 20:57 UTC (permalink / raw)
  To: davem, netdev; +Cc: edumazet, Soheil Hassas Yeganeh

From: Soheil Hassas Yeganeh <soheil@google.com>

When SKBs are coalesced, we can have SKBs with different
frag sizes. Some with PAGE_SIZE and some not with PAGE_SIZE.
Since recv_skip_hint is always set to the full SKB size,
it can overestimate the amount that should be read using
normal read for coalesced packets.

Change the recv_skip_hint so that it only includes the first
frags that are not of PAGE_SIZE.

Signed-off-by: Soheil Hassas Yeganeh <soheil@google.com>
Signed-off-by: Eric Dumazet <edumazet@google.com>
---
 net/ipv4/tcp.c | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)

diff --git a/net/ipv4/tcp.c b/net/ipv4/tcp.c
index 3e17501fc1a1..cdbd423bdeb4 100644
--- a/net/ipv4/tcp.c
+++ b/net/ipv4/tcp.c
@@ -1805,8 +1805,17 @@ static int tcp_zerocopy_receive(struct sock *sk,
 				frags++;
 			}
 		}
-		if (frags->size != PAGE_SIZE || frags->page_offset)
+		if (frags->size != PAGE_SIZE || frags->page_offset) {
+			int remaining = zc->recv_skip_hint;
+
+			while (remaining && (frags->size != PAGE_SIZE ||
+					     frags->page_offset)) {
+				remaining -= frags->size;
+				frags++;
+			}
+			zc->recv_skip_hint -= remaining;
 			break;
+		}
 		ret = vm_insert_page(vma, address + length,
 				     skb_frag_page(frags));
 		if (ret)
-- 
2.19.0.605.g01d371f741-goog

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH net-next 1/2] tcp: set recv_skip_hint when tcp_inq is less than PAGE_SIZE
  2018-09-26 20:57 [PATCH net-next 1/2] tcp: set recv_skip_hint when tcp_inq is less than PAGE_SIZE Soheil Hassas Yeganeh
  2018-09-26 20:57 ` [PATCH net-next 2/2] tcp: adjust rcv zerocopy hints based on frag sizes Soheil Hassas Yeganeh
@ 2018-10-02  5:37 ` David Miller
  1 sibling, 0 replies; 4+ messages in thread
From: David Miller @ 2018-10-02  5:37 UTC (permalink / raw)
  To: soheil.kdev; +Cc: netdev, edumazet, soheil

From: Soheil Hassas Yeganeh <soheil.kdev@gmail.com>
Date: Wed, 26 Sep 2018 16:57:03 -0400

> From: Soheil Hassas Yeganeh <soheil@google.com>
> 
> 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: Soheil Hassas Yeganeh <soheil@google.com>
> Signed-off-by: Eric Dumazet <edumazet@google.com>

Applied.

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH net-next 2/2] tcp: adjust rcv zerocopy hints based on frag sizes
  2018-09-26 20:57 ` [PATCH net-next 2/2] tcp: adjust rcv zerocopy hints based on frag sizes Soheil Hassas Yeganeh
@ 2018-10-02  5:37   ` David Miller
  0 siblings, 0 replies; 4+ messages in thread
From: David Miller @ 2018-10-02  5:37 UTC (permalink / raw)
  To: soheil.kdev; +Cc: netdev, edumazet, soheil

From: Soheil Hassas Yeganeh <soheil.kdev@gmail.com>
Date: Wed, 26 Sep 2018 16:57:04 -0400

> From: Soheil Hassas Yeganeh <soheil@google.com>
> 
> When SKBs are coalesced, we can have SKBs with different
> frag sizes. Some with PAGE_SIZE and some not with PAGE_SIZE.
> Since recv_skip_hint is always set to the full SKB size,
> it can overestimate the amount that should be read using
> normal read for coalesced packets.
> 
> Change the recv_skip_hint so that it only includes the first
> frags that are not of PAGE_SIZE.
> 
> Signed-off-by: Soheil Hassas Yeganeh <soheil@google.com>
> Signed-off-by: Eric Dumazet <edumazet@google.com>

Applied.

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2018-10-02 12:18 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-09-26 20:57 [PATCH net-next 1/2] tcp: set recv_skip_hint when tcp_inq is less than PAGE_SIZE Soheil Hassas Yeganeh
2018-09-26 20:57 ` [PATCH net-next 2/2] tcp: adjust rcv zerocopy hints based on frag sizes Soheil Hassas Yeganeh
2018-10-02  5:37   ` David Miller
2018-10-02  5:37 ` [PATCH net-next 1/2] tcp: set recv_skip_hint when tcp_inq is less than PAGE_SIZE David Miller

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.