diff options
author | Alexander Duyck <alexander.h.duyck@intel.com> | 2010-06-02 08:24:37 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2010-06-05 05:23:16 -0400 |
commit | b78462ebc6a4ef9074aa80abebcdd470dc5f0ce0 (patch) | |
tree | fba32dab1e3dca2c5bb5b7d73a64a77c2b6872e8 | |
parent | 55c95e738da85373965cb03b4f975d0fd559865b (diff) |
skbuff: add check for non-linear to warn_if_lro and needs_linearize
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>
-rw-r--r-- | include/linux/skbuff.h | 3 | ||||
-rw-r--r-- | net/core/dev.c | 7 |
2 files changed, 6 insertions, 4 deletions
diff --git a/include/linux/skbuff.h b/include/linux/skbuff.h index bf243fc54959..645e78d395fd 100644 --- a/include/linux/skbuff.h +++ b/include/linux/skbuff.h | |||
@@ -2129,7 +2129,8 @@ static inline bool skb_warn_if_lro(const struct sk_buff *skb) | |||
2129 | /* LRO sets gso_size but not gso_type, whereas if GSO is really | 2129 | /* LRO sets gso_size but not gso_type, whereas if GSO is really |
2130 | * wanted then gso_type will be set. */ | 2130 | * wanted then gso_type will be set. */ |
2131 | struct skb_shared_info *shinfo = skb_shinfo(skb); | 2131 | struct skb_shared_info *shinfo = skb_shinfo(skb); |
2132 | if (shinfo->gso_size != 0 && unlikely(shinfo->gso_type == 0)) { | 2132 | if (skb_is_nonlinear(skb) && shinfo->gso_size != 0 && |
2133 | unlikely(shinfo->gso_type == 0)) { | ||
2133 | __skb_warn_lro_forwarding(skb); | 2134 | __skb_warn_lro_forwarding(skb); |
2134 | return true; | 2135 | return true; |
2135 | } | 2136 | } |
diff --git a/net/core/dev.c b/net/core/dev.c index ec01a5998d70..3abb3a6058be 100644 --- a/net/core/dev.c +++ b/net/core/dev.c | |||
@@ -2103,9 +2103,10 @@ static inline int __dev_xmit_skb(struct sk_buff *skb, struct Qdisc *q, | |||
2103 | static inline int skb_needs_linearize(struct sk_buff *skb, | 2103 | static inline int skb_needs_linearize(struct sk_buff *skb, |
2104 | struct net_device *dev) | 2104 | struct net_device *dev) |
2105 | { | 2105 | { |
2106 | return (skb_has_frags(skb) && !(dev->features & NETIF_F_FRAGLIST)) || | 2106 | return skb_is_nonlinear(skb) && |
2107 | (skb_shinfo(skb)->nr_frags && (!(dev->features & NETIF_F_SG) || | 2107 | ((skb_has_frags(skb) && !(dev->features & NETIF_F_FRAGLIST)) || |
2108 | illegal_highdma(dev, skb))); | 2108 | (skb_shinfo(skb)->nr_frags && (!(dev->features & NETIF_F_SG) || |
2109 | illegal_highdma(dev, skb)))); | ||
2109 | } | 2110 | } |
2110 | 2111 | ||
2111 | /** | 2112 | /** |