Thread (3 messages) 3 messages, 2 authors, 2017-07-17

Re: [PATCH net-next resubmit] skbuff: optimize the pull_pages code in __pskb_pull_tail()

From: Eric Dumazet <hidden>
Date: 2017-07-17 07:32:44
Subsystem: networking [general], the rest · Maintainers: "David S. Miller", Eric Dumazet, Jakub Kicinski, Paolo Abeni, Linus Torvalds

On Mon, 2017-07-17 at 10:22 +0800, Lin Zhang wrote:
quoted hunk ↗ jump to hunk
In the pull_pages code block, if the first frag size > eat,
we can end the loop in advance to avoid extra copy.

Signed-off-by: Lin Zhang <redacted>
---
 net/core/skbuff.c | 4 ++++
 1 file changed, 4 insertions(+)
diff --git a/net/core/skbuff.c b/net/core/skbuff.c
index f990eb8..c00a1df 100644
--- a/net/core/skbuff.c
+++ b/net/core/skbuff.c
@@ -1720,6 +1720,10 @@ void *__pskb_pull_tail(struct sk_buff *skb, int delta)
 				skb_shinfo(skb)->frags[k].page_offset += eat;
 				skb_frag_size_sub(&skb_shinfo(skb)->frags[k], eat);
 				eat = 0;
+				if (!i) {
+					k = skb_shinfo(skb)->nr_frags;
+					break;
+				}
 			}
 			k++;
 		}
-CC lkml  (no need to spam lkml for netdev patches )

Why even reading skb_shinfo(skb)->nr_frags to write it again ?

I would use something like :
diff --git a/net/core/skbuff.c b/net/core/skbuff.c
index 8b11341ed69ad97d34dd3e9b73c8c44ef7c452ff..a562b0e61afa3faf7abdd7f9209ae9096310fb7d 100644
--- a/net/core/skbuff.c
+++ b/net/core/skbuff.c
@@ -1719,13 +1719,15 @@ void *__pskb_pull_tail(struct sk_buff *skb, int delta)
 			if (eat) {
 				skb_shinfo(skb)->frags[k].page_offset += eat;
 				skb_frag_size_sub(&skb_shinfo(skb)->frags[k], eat);
+				if (!i)
+					goto end;
 				eat = 0;
 			}
 			k++;
 		}
 	}
 	skb_shinfo(skb)->nr_frags = k;
-
+end:
 	skb->tail     += delta;
 	skb->data_len -= delta;
 
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help