diff options
author | Eric Dumazet <eric.dumazet@gmail.com> | 2010-05-19 18:07:23 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2010-05-31 03:24:01 -0400 |
commit | 27f39c73e63833b4c081a0d681d88b4184a0491d (patch) | |
tree | 49cca2881bcd9212cd99a1e30c83f40a20eefc55 | |
parent | 604c1b1868f16e7b2fc13401d8c9147f167bec0a (diff) |
net: Use __this_cpu_inc() in fast path
This patch saves 224 bytes of text on my machine.
__this_cpu_inc() generates a single instruction, using no scratch
registers :
65 ff 04 25 a8 30 01 00 incl %gs:0x130a8
instead of :
48 c7 c2 80 30 01 00 mov $0x13080,%rdx
65 48 8b 04 25 88 ea 00 00 mov %gs:0xea88,%rax
83 44 10 28 01 addl $0x1,0x28(%rax,%rdx,1)
Signed-off-by: Eric Dumazet <eric.dumazet@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r-- | net/core/dev.c | 3 | ||||
-rw-r--r-- | net/ipv4/route.c | 3 |
2 files changed, 2 insertions, 4 deletions
diff --git a/net/core/dev.c b/net/core/dev.c index 1845b08c624..7d76b056aa3 100644 --- a/net/core/dev.c +++ b/net/core/dev.c | |||
@@ -2822,8 +2822,7 @@ static int __netif_receive_skb(struct sk_buff *skb) | |||
2822 | skb->dev = master; | 2822 | skb->dev = master; |
2823 | } | 2823 | } |
2824 | 2824 | ||
2825 | __get_cpu_var(softnet_data).processed++; | 2825 | __this_cpu_inc(softnet_data.processed); |
2826 | |||
2827 | skb_reset_network_header(skb); | 2826 | skb_reset_network_header(skb); |
2828 | skb_reset_transport_header(skb); | 2827 | skb_reset_transport_header(skb); |
2829 | skb->mac_len = skb->network_header - skb->mac_header; | 2828 | skb->mac_len = skb->network_header - skb->mac_header; |
diff --git a/net/ipv4/route.c b/net/ipv4/route.c index 560acc677ce..8495bceec76 100644 --- a/net/ipv4/route.c +++ b/net/ipv4/route.c | |||
@@ -253,8 +253,7 @@ static unsigned rt_hash_mask __read_mostly; | |||
253 | static unsigned int rt_hash_log __read_mostly; | 253 | static unsigned int rt_hash_log __read_mostly; |
254 | 254 | ||
255 | static DEFINE_PER_CPU(struct rt_cache_stat, rt_cache_stat); | 255 | static DEFINE_PER_CPU(struct rt_cache_stat, rt_cache_stat); |
256 | #define RT_CACHE_STAT_INC(field) \ | 256 | #define RT_CACHE_STAT_INC(field) __this_cpu_inc(rt_cache_stat.field) |
257 | (__raw_get_cpu_var(rt_cache_stat).field++) | ||
258 | 257 | ||
259 | static inline unsigned int rt_hash(__be32 daddr, __be32 saddr, int idx, | 258 | static inline unsigned int rt_hash(__be32 daddr, __be32 saddr, int idx, |
260 | int genid) | 259 | int genid) |