Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

[NET]: Can use __get_cpu_var() instead of per_cpu() in loopback driver.

As BHs are off in loopback_xmit(), preemption cannot occurs, so we can
use __get_cpu_var() instead of per_cpu() (and avoid a
preempt_enable()/preempt_disable() pair)

Signed-off-by: Eric Dumazet <dada1@cosmosbay.com>
Signed-off-by: David S. Miller <davem@davemloft.net>

authored by

Eric Dumazet and committed by
David S. Miller
58f53974 78d79423

+3 -3
+3 -3
drivers/net/loopback.c
··· 153 153 #endif 154 154 dev->last_rx = jiffies; 155 155 156 - lb_stats = &per_cpu(pcpu_lstats, get_cpu()); 156 + /* it's OK to use __get_cpu_var() because BHs are off */ 157 + lb_stats = &__get_cpu_var(pcpu_lstats); 157 158 lb_stats->bytes += skb->len; 158 159 lb_stats->packets++; 159 - put_cpu(); 160 160 161 161 netif_rx(skb); 162 162 163 - return(0); 163 + return 0; 164 164 } 165 165 166 166 static struct net_device_stats loopback_stats;