[PATCH 2/4] net: add likely/unlikely to skb_header_pointer

Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
From: Stephen Hemminger
Date: Monday, August 2, 2010 - 3:00 pm

The expected case that should be optimized is that the offset is valid
and the data is available.

Signed-off-by: Stephen Hemminger <shemminger@vyatta.com>

--- a/include/linux/skbuff.h	2010-08-01 11:20:15.872942674 -0700
+++ b/include/linux/skbuff.h	2010-08-01 11:20:59.513693007 -0700
@@ -1853,13 +1853,13 @@ static inline void *skb_header_pointer(c
 {
 	int hlen = skb_headlen(skb);
 
-	if (hlen + offset < 0)
+	if (unlikely(hlen + offset < 0))
 		return NULL;
 
-	if (hlen - offset >= len)
+	if (likely(hlen - offset >= len))
 		return skb->data + offset;
 
-	if (skb_copy_bits(skb, offset, buffer, len) < 0)
+	if (unlikely(skb_copy_bits(skb, offset, buffer, len) < 0))
 		return NULL;
 
 	return buffer;


--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
[PATCH 2/4] net: add likely/unlikely to skb_header_pointer, Stephen Hemminger, (Mon Aug 2, 3:00 pm)