skbuff: add check for non-linear to warn_if_lro and needs_linearize
authorAlexander Duyck <alexander.h.duyck@intel.com>
Wed, 2 Jun 2010 12:24:37 +0000 (12:24 +0000)
committerDavid S. Miller <davem@davemloft.net>
Sat, 5 Jun 2010 09:23:16 +0000 (02:23 -0700)
We can avoid an unecessary cache miss by checking if the skb is non-linear
before accessing gso_size/gso_type in skb_warn_if_lro, the same can also be
done to avoid a cache miss on nr_frags if data_len is 0.

Signed-off-by: Alexander Duyck <alexander.h.duyck@intel.com>
Signed-off-by: Jeff Kirsher <jeffrey.t.kirsher@intel.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
include/linux/skbuff.h
net/core/dev.c

index bf243fc54959098e49d6a77dac955aea8cf9d4b6..645e78d395fd6dd9d6f9c53b0fa31c887ef2e06b 100644 (file)
@@ -2129,7 +2129,8 @@ static inline bool skb_warn_if_lro(const struct sk_buff *skb)
        /* LRO sets gso_size but not gso_type, whereas if GSO is really
         * wanted then gso_type will be set. */
        struct skb_shared_info *shinfo = skb_shinfo(skb);
-       if (shinfo->gso_size != 0 && unlikely(shinfo->gso_type == 0)) {
+       if (skb_is_nonlinear(skb) && shinfo->gso_size != 0 &&
+           unlikely(shinfo->gso_type == 0)) {
                __skb_warn_lro_forwarding(skb);
                return true;
        }
index ec01a5998d70ff7a33d89879ea4ae28428727a33..3abb3a6058be07dc3c91ca5f404216a2803040e9 100644 (file)
@@ -2103,9 +2103,10 @@ static inline int __dev_xmit_skb(struct sk_buff *skb, struct Qdisc *q,
 static inline int skb_needs_linearize(struct sk_buff *skb,
                                      struct net_device *dev)
 {
-       return (skb_has_frags(skb) && !(dev->features & NETIF_F_FRAGLIST)) ||
-              (skb_shinfo(skb)->nr_frags && (!(dev->features & NETIF_F_SG) ||
-                                             illegal_highdma(dev, skb)));
+       return skb_is_nonlinear(skb) &&
+              ((skb_has_frags(skb) && !(dev->features & NETIF_F_FRAGLIST)) ||
+               (skb_shinfo(skb)->nr_frags && (!(dev->features & NETIF_F_SG) ||
+                                             illegal_highdma(dev, skb))));
 }
 
 /**