Skip to contentSkip to conversation

skbuff: optimize the pull_pages code in __pskb_pull_tail()

PATCH Applied Lin Zhang 3 participants 3 messages Jul 17, 2017

Subsystems (2)
lore
Share & tools
lore

Lin Zhang

author
#0 lore raw

PATCH v2 1/1 skbuff: optimize the pull_pages code in __pskb_pull_tail()

In the pull_pages code block, if the first frag size > eat, we can end the loop in advance to avoid extra copy.

---
v1 -> v2:
* no need to rewrite skb_shinfo(skb)->nr_frags, per Eric Dumazet.

---
 net/core/skbuff.c | 3 +++
 1 file changed, 3 insertions(+)
net/core/skbuff.c +3 -0
index f990eb8..af61065 100644
@@ -1719,6 +1719,8 @@ 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++;
@@ -1726,6 +1728,7 @@ void *__pskb_pull_tail(struct sk_buff *skb, int delta)
 	}
 	skb_shinfo(skb)->nr_frags = k;
 
+end:
 	skb->tail     += delta;
 	skb->data_len -= delta;
 
Signature · 1 line
1.8.3.1