diff options
| author | Andi Kleen <ak@muc.de> | 2003-07-14 03:16:07 -0700 |
|---|---|---|
| committer | David S. Miller <davem@kernel.bkbits.net> | 2003-07-14 03:16:07 -0700 |
| commit | 0612fdbe537e4fc2e3cdc09322d8d04c3768420a (patch) | |
| tree | 2a7e482b0e69969f475cb3d6671b652e929673a2 /include/linux | |
| parent | 6019d2cb59cb2f551fd479d897f0b3a16e2f92a4 (diff) | |
[NET]: Turn softnet_data into per-cpu data.
Diffstat (limited to 'include/linux')
| -rw-r--r-- | include/linux/netdevice.h | 30 |
1 files changed, 13 insertions, 17 deletions
diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h index 3aef822b4493..c28c63ea442d 100644 --- a/include/linux/netdevice.h +++ b/include/linux/netdevice.h @@ -29,6 +29,7 @@ #include <linux/if_ether.h> #include <linux/if_packet.h> #include <linux/device.h> +#include <linux/percpu.h> #include <asm/atomic.h> #include <asm/cache.h> @@ -544,10 +545,9 @@ struct softnet_data struct sk_buff *completion_queue; struct net_device backlog_dev; /* Sorry. 8) */ -} ____cacheline_aligned; - +}; -extern struct softnet_data softnet_data[NR_CPUS]; +DECLARE_PER_CPU(struct softnet_data,softnet_data); #define HAVE_NETIF_QUEUE @@ -555,12 +555,12 @@ static inline void __netif_schedule(struct net_device *dev) { if (!test_and_set_bit(__LINK_STATE_SCHED, &dev->state)) { unsigned long flags; - int cpu; + struct softnet_data *sd; local_irq_save(flags); - cpu = smp_processor_id(); - dev->next_sched = softnet_data[cpu].output_queue; - softnet_data[cpu].output_queue = dev; + sd = &__get_cpu_var(softnet_data); + dev->next_sched = sd->output_queue; + sd->output_queue = dev; raise_softirq_irqoff(NET_TX_SOFTIRQ); local_irq_restore(flags); } @@ -605,13 +605,13 @@ static inline int netif_running(const struct net_device *dev) static inline void dev_kfree_skb_irq(struct sk_buff *skb) { if (atomic_dec_and_test(&skb->users)) { - int cpu; + struct softnet_data *sd; unsigned long flags; local_irq_save(flags); - cpu = smp_processor_id(); - skb->next = softnet_data[cpu].completion_queue; - softnet_data[cpu].completion_queue = skb; + sd = &__get_cpu_var(softnet_data); + skb->next = sd->completion_queue; + sd->completion_queue = skb; raise_softirq_irqoff(NET_TX_SOFTIRQ); local_irq_restore(flags); } @@ -769,12 +769,10 @@ static inline int netif_rx_schedule_prep(struct net_device *dev) static inline void __netif_rx_schedule(struct net_device *dev) { unsigned long flags; - int cpu; local_irq_save(flags); - cpu = smp_processor_id(); dev_hold(dev); - list_add_tail(&dev->poll_list, &softnet_data[cpu].poll_list); + list_add_tail(&dev->poll_list, &__get_cpu_var(softnet_data).poll_list); if (dev->quota < 0) dev->quota += dev->weight; else @@ -798,13 +796,11 @@ static inline int netif_rx_reschedule(struct net_device *dev, int undo) { if (netif_rx_schedule_prep(dev)) { unsigned long flags; - int cpu; dev->quota += undo; local_irq_save(flags); - cpu = smp_processor_id(); - list_add_tail(&dev->poll_list, &softnet_data[cpu].poll_list); + list_add_tail(&dev->poll_list, &__get_cpu_var(softnet_data).poll_list); __raise_softirq_irqoff(NET_RX_SOFTIRQ); local_irq_restore(flags); return 1; |
