From a432e18a24569804c82f14b36ae7d8dfcc245da7 Mon Sep 17 00:00:00 2001 From: hunt Date: Mon, 28 Nov 2005 22:08:39 +0000 Subject: 2005-11-28 Martin Hunt * alloc.c (__stp_valloc_percpu): Use same code for up and smp. (_stp_per_cpu_ptr): New macro. * user/alloc.c: Ditto. * map.c: Use _stp_map_cpu_ptr(). * map-stat.c: Ditto. * pmap-gen.c: Ditto. * runtime.h: Include alloc.c * user/runtime.h: Ditto. --- runtime/alloc.c | 20 ++++++-------------- 1 file changed, 6 insertions(+), 14 deletions(-) (limited to 'runtime/alloc.c') diff --git a/runtime/alloc.c b/runtime/alloc.c index b647a532..9f72a65b 100644 --- a/runtime/alloc.c +++ b/runtime/alloc.c @@ -118,7 +118,6 @@ struct _stp_percpu_data { void *data; }; -#ifdef CONFIG_SMP /** * __stp_valloc_percpu - allocate one copy of the object for every present * cpu in the system, using vmalloc and zeroing them. @@ -170,25 +169,18 @@ void _stp_vfree_percpu(const void *objp) } kfree(p); } -#else -static inline void *__stp_valloc_percpu(size_t size, size_t align) -{ - void *ret = kmalloc(size, GFP_KERNEL); - if (ret) - memset(ret, 0, size); - return ret; -} -void _stp_vfree_percpu(const void *ptr) -{ - kfree(ptr); -} -#endif #define _stp_valloc_percpu(type) \ ((type *)(__stp_valloc_percpu(sizeof(type), __alignof__(type)))) #define _stp_percpu_dptr(ptr) (((struct _stp_percpu_data *)~(unsigned long)(ptr))->data) +#define _stp_per_cpu_ptr(ptr, cpu) \ +({ \ + struct _stp_percpu_data *__p = (struct _stp_percpu_data *)~(unsigned long)(ptr); \ + (__typeof__(ptr))__p->ptrs[(cpu)]; \ +}) + /** Frees memory allocated by _stp_alloc or _stp_calloc. * @param ptr pointer to memory to free * @note Not currently used by the runtime. Deprecate? -- cgit