Skip to contentSkip to conversation

tcp: Set rcv zerocopy hint correctly if skb last frag is < PAGE_SIZE.

PATCH In review Arjun Roy 3 participants 3 messages Dec 12, 2019 – Dec 15, 2019

Subsystems (3)
lore
Share & tools
lore

Arjun Roy

author
#0 lore raw

PATCH 1/1 tcp: Set rcv zerocopy hint correctly if skb last frag is < PAGE_SIZE.

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.

---
 net/ipv4/tcp.c | 2 ++
 1 file changed, 2 insertions(+)
net/ipv4/tcp.c +2 -0
index 34490d972758..b9623d896469 100644
@@ -1904,6 +1904,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 {
Signature · 1 line
2.24.1.735.g03f4e72817-goog
#1 lore raw
Quoted 5 lines · Arjun Roy

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.

nit: this commit message doesn't really tell us why or what the effects
are going to be.

Quoted 3 lines

WARNING: Missing Signed-off-by: line by nominal patch author 'Arjun Roy <[email protected]>'

You gotta send it from the same address you signed it off from.

Quoted 13 lines
net/ipv4/tcp.c +2 -0
index 34490d972758..b9623d896469 100644
@@ -1904,6 +1904,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 {
#2 lore raw
Quoted 9 lines · Jakub Kicinski
Quoted 5 lines · Arjun Roy

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.

nit: this commit message doesn't really tell us why or what the effects
are going to be.

Right, I added a bit of explanation.

Basically we would hint the application to copy more bytes than needed.

Since zerocopy is best effort, this can target net-next

Quoted 8 lines
Quoted 4 lines

WARNING: Missing Signed-off-by: line by nominal patch author 'Arjun Roy <[email protected]>'

You gotta send it from the same address you signed it off from.

I sent a v2 on behalf of Arjun.

Thanks.