[rfc 24/45] cpu alloc: convert loopback statistics

From: clameter
Date: Mon Nov 19 2007 - 20:22:20 EST


Signed-off-by: Christoph Lameter <clameter@xxxxxxx>
---
drivers/net/loopback.c | 14 ++++++--------
1 file changed, 6 insertions(+), 8 deletions(-)

Index: linux-2.6/drivers/net/loopback.c
===================================================================
--- linux-2.6.orig/drivers/net/loopback.c 2007-11-18 14:38:23.621283530 -0800
+++ linux-2.6/drivers/net/loopback.c 2007-11-18 22:04:47.399082691 -0800
@@ -134,7 +134,7 @@ static void emulate_large_send_offload(s
*/
static int loopback_xmit(struct sk_buff *skb, struct net_device *dev)
{
- struct pcpu_lstats *pcpu_lstats, *lb_stats;
+ struct pcpu_lstats *pcpu_lstats;

skb_orphan(skb);

@@ -154,11 +154,9 @@ static int loopback_xmit(struct sk_buff
#endif
dev->last_rx = jiffies;

- /* it's OK to use per_cpu_ptr() because BHs are off */
pcpu_lstats = netdev_priv(dev);
- lb_stats = per_cpu_ptr(pcpu_lstats, smp_processor_id());
- lb_stats->bytes += skb->len;
- lb_stats->packets++;
+ __CPU_ADD(pcpu_lstats->bytes, skb->len);
+ __CPU_INC(pcpu_lstats->packets);

netif_rx(skb);

@@ -177,7 +175,7 @@ static struct net_device_stats *get_stat
for_each_possible_cpu(i) {
const struct pcpu_lstats *lb_stats;

- lb_stats = per_cpu_ptr(pcpu_lstats, i);
+ lb_stats = CPU_PTR(pcpu_lstats, i);
bytes += lb_stats->bytes;
packets += lb_stats->packets;
}
@@ -205,7 +203,7 @@ static int loopback_dev_init(struct net_
{
struct pcpu_lstats *lstats;

- lstats = alloc_percpu(struct pcpu_lstats);
+ lstats = CPU_ALLOC(struct pcpu_lstats, GFP_KERNEL | __GFP_ZERO);
if (!lstats)
return -ENOMEM;

@@ -217,7 +215,7 @@ static void loopback_dev_free(struct net
{
struct pcpu_lstats *lstats = netdev_priv(dev);

- free_percpu(lstats);
+ CPU_FREE(lstats);
free_netdev(dev);
}


--
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/