[patch 14/41] cpu alloc: Neigbour statistics

Christoph Lameter
2008-05-30T04:04:47Z

[-- Attachment #1: cpu_alloc_neighbor_statistics_conversion --]
[-- Type: text/plain, Size: 2301 bytes --]

Convert neighbor stats to cpu alloc.

Signed-off-by: Christoph Lameter <clameter@sgi.com>
---
include/net/neighbour.h | 6 +-----
net/core/neighbour.c | 11 ++++++-----
2 files changed, 7 insertions(+), 10 deletions(-)

Index: linux-2.6/include/net/neighbour.h
===================================================================
--- linux-2.6.orig/include/net/neighbour.h 2008-05-21 23:59:14.000000000 -0700
+++ linux-2.6/include/net/neighbour.h 2008-05-22 07:40:37.000000000 -0700
@@ -87,12 +87,7 @@
unsigned long forced_gc_runs; /* number of forced GC runs */
};

-#define NEIGH_CACHE_STAT_INC(tbl, field) \
- do { \
- preempt_disable(); \
- (per_cpu_ptr((tbl)->stats, smp_processor_id())->field)++; \
- preempt_enable(); \
- } while (0)
+#define NEIGH_CACHE_STAT_INC(tbl, field) _CPU_INC((tbl)->stats->field)

struct neighbour
{
Index: linux-2.6/net/core/neighbour.c
===================================================================
--- linux-2.6.orig/net/core/neighbour.c 2008-05-21 23:59:14.000000000 -0700
+++ linux-2.6/net/core/neighbour.c 2008-05-22 00:00:06.000000000 -0700
@@ -1425,7 +1425,8 @@
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");

@@ -1511,7 +1512,7 @@

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);
@@ -1769,7 +1770,7 @@
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;
@@ -2429,7 +2430,7 @@
if (!cpu_possible(cpu))
continue;
*pos = cpu+1;
- return per_cpu_ptr(tbl->stats, cpu);
+ return CPU_PTR(tbl->stats, cpu);
}
return NULL;
}
@@ -2444,7 +2445,7 @@
if (!cpu_possible(cpu))
continue;
*pos = cpu+1;
- return per_cpu_ptr(tbl->stats, cpu);
+ return CPU_PTR(tbl->stats, cpu);
}
return NULL;
}

--