tcp: set recv_skip_hint when tcp_inq is less than PAGE_SIZE
Subsystems (3)
PATCH 1/2 tcp: set recv_skip_hint when tcp_inq is less than PAGE_SIZE
From: Soheil Hassas Yeganeh <[email protected]>
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.
--- net/ipv4/tcp.c | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-)
net/ipv4/tcp.c +9 -5
@@ -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 ) {
Signature · 1 line
2.19.0.605.g01d371f741-goog
PATCH 2/2 tcp: adjust rcv zerocopy hints based on frag sizes
From: Soheil Hassas Yeganeh <[email protected]>
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.
--- net/ipv4/tcp.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-)
net/ipv4/tcp.c +10 -1
@@ -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)
Signature · 1 line
2.19.0.605.g01d371f741-goog
Re: [PATCH net-next 2/2] tcp: adjust rcv zerocopy hints based on frag sizes
From: Soheil Hassas Yeganeh <[email protected]>
Date: Wed, 26 Sep 2018 16:57:04 -0400
Quoted 8 lines
From: Soheil Hassas Yeganeh <[email protected]>
When SKBs are coalesced, we can have SKBs with different frag sizes. Some with
PAGE_SIZEand some not withPAGE_SIZE. Sincerecv_skip_hintis always set to the full SKB size, it can overestimate the amount that should be read using normal read for coalesced packets.
Quoted 5 lines
Change the
recv_skip_hintso that it only includes the first frags that are not ofPAGE_SIZE.Signed-off-by Soheil Hassas Yeganeh <[email protected]>Signed-off-by Eric Dumazet <[email protected]>
Applied.
From: Soheil Hassas Yeganeh <[email protected]>
Date: Wed, 26 Sep 2018 16:57:03 -0400
Quoted 8 lines
From: Soheil Hassas Yeganeh <[email protected]>
When we have less than
PAGE_SIZEof data on receive queue, we setrecv_skip_hintto 0. Instead, set it to the actual number of bytes available.Signed-off-by Soheil Hassas Yeganeh <[email protected]>Signed-off-by Eric Dumazet <[email protected]>
Applied.