Skip to contentSkip to conversation

include:linux:Optimizations to __skb_push

PATCH In review Mohammad Jamal 4 participants 5 messages Jan 22, 2015 – Jan 23, 2015 Networking

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 include:linux:Optimizations to __skb_push

This patch optimizes __skb_push function

---
 include/linux/skbuff.h |    3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
include/linux/skbuff.h +1 -2
index 85ab7d7..9acffb2 100644
@@ -1671,9 +1671,8 @@ static inline unsigned char *__skb_put(struct sk_buff *skb, unsigned int len)
 unsigned char *skb_push(struct sk_buff *skb, unsigned int len);
 static inline unsigned char *__skb_push(struct sk_buff *skb, unsigned int len)
 {
-	skb->data -= len;
 	skb->len  += len;
-	return skb->data;
+	return skb->data -= len;
 }
 
 unsigned char *skb_pull(struct sk_buff *skb, unsigned int len);
Signature · 1 line
1.7.9.5
#1 lore raw
Quoted 12 lines · Mohammad Jamal

This patch optimizes __skb_push function

---
 include/linux/skbuff.h |    3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
include/linux/skbuff.h +0 -0
index 85ab7d7..9acffb2 100644

include/linux/skbuff.h static inline unsigned char *__skb_put(struct sk_buff *skb, unsigned int len) · line 1677

Quoted 9 lines
include/linux/skbuff.h +1 -2
@@ -1671,9 +1671,8 @@ static inline unsigned char *__skb_put(struct sk_buff *skb, unsigned int len)
 unsigned char *skb_push(struct sk_buff *skb, unsigned int len);
 static inline unsigned char *__skb_push(struct sk_buff *skb, unsigned int len)
 {
-       skb->data -= len;
        skb->len  += len;
-       return skb->data;
+       return skb->data -= len;
 }
 

Hmm, this seems less readable to me. What is the effect of this patch? Does the compiler even produce different assembly?

Thanks,
Tom

Quoted 4 lines
include/linux/skbuff.h +0 -1
 unsigned char *skb_pull(struct sk_buff *skb, unsigned int len);
--

1.7.9.5

#2 lore raw
Quoted 2 lines · Tom Herbert

Hmm, this seems less readable to me. What is the effect of this patch? Does the compiler even produce different assembly?

No change at all in generated assembly, this looks not worth it.

BTW, most __skb_push() callers ignore return value.

#3 lore raw
Quoted 8 lines · Eric Dumazet
Quoted 2 lines · Tom Herbert

Hmm, this seems less readable to me. What is the effect of this patch? Does the compiler even produce different assembly?

No change at all in generated assembly, this looks not worth it.

BTW, most __skb_push() callers ignore return value.

it just reduces the number of lines....