From 23b6ff42d6ca32e2ae649ea6e7c3a5b4caeb9a93 Mon Sep 17 00:00:00 2001 From: Christoph Lameter Date: Tue, 6 Nov 2007 11:33:54 -0800 Subject: [PATCH] cpu alloc: neigbour statistics Signed-off-by: Christoph Lameter --- include/net/neighbour.h | 2 +- net/core/neighbour.c | 12 +++++++----- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/include/net/neighbour.h b/include/net/neighbour.h index a4f2618..4fda76c 100644 --- a/include/net/neighbour.h +++ b/include/net/neighbour.h @@ -83,7 +83,7 @@ struct neigh_statistics #define NEIGH_CACHE_STAT_INC(tbl, field) \ do { \ preempt_disable(); \ - (per_cpu_ptr((tbl)->stats, smp_processor_id())->field)++; \ + (THIS_CPU((tbl)->stats)->field)++; \ preempt_enable(); \ } while (0) diff --git a/net/core/neighbour.c b/net/core/neighbour.c index 29b8ee4..59074bb 100644 --- a/net/core/neighbour.c +++ b/net/core/neighbour.c @@ -35,6 +35,7 @@ #include #include #include +#include #define NEIGH_DEBUG 1 @@ -1348,7 +1349,8 @@ void neigh_table_init_no_netlink(struct neigh_table *tbl) kmem_cache_create(tbl->id, tbl->entry_size, 0, SLAB_HWCACHE_ALIGN|SLAB_PANIC, NULL); - tbl->stats = alloc_percpu(struct neigh_statistics); + tbl->stats = CPU_ALLOC(struct neigh_statistics, + GFP_KERNEL | __GFP_ZERO); if (!tbl->stats) panic("cannot create neighbour cache statistics"); @@ -1437,7 +1439,7 @@ int neigh_table_clear(struct neigh_table *tbl) remove_proc_entry(tbl->id, init_net.proc_net_stat); - free_percpu(tbl->stats); + CPU_FREE(tbl->stats); tbl->stats = NULL; kmem_cache_destroy(tbl->kmem_cachep); @@ -1694,7 +1696,7 @@ static int neightbl_fill_info(struct sk_buff *skb, struct neigh_table *tbl, for_each_possible_cpu(cpu) { struct neigh_statistics *st; - st = per_cpu_ptr(tbl->stats, cpu); + st = CPU_PTR(tbl->stats, cpu); ndst.ndts_allocs += st->allocs; ndst.ndts_destroys += st->destroys; ndst.ndts_hash_grows += st->hash_grows; @@ -2343,7 +2345,7 @@ static void *neigh_stat_seq_start(struct seq_file *seq, loff_t *pos) if (!cpu_possible(cpu)) continue; *pos = cpu+1; - return per_cpu_ptr(tbl->stats, cpu); + return CPU_PTR(tbl->stats, cpu); } return NULL; } @@ -2358,7 +2360,7 @@ static void *neigh_stat_seq_next(struct seq_file *seq, void *v, loff_t *pos) if (!cpu_possible(cpu)) continue; *pos = cpu+1; - return per_cpu_ptr(tbl->stats, cpu); + return CPU_PTR(tbl->stats, cpu); } return NULL; } -- 1.5.3.4