diff options
author | hunt <hunt> | 2005-11-28 22:08:39 +0000 |
---|---|---|
committer | hunt <hunt> | 2005-11-28 22:08:39 +0000 |
commit | a432e18a24569804c82f14b36ae7d8dfcc245da7 (patch) | |
tree | a59fbb363f9837117053d54ead454895609c4314 | |
parent | bdf00cf6b089eccd30b5cfec8c06be7b949749d8 (diff) | |
download | systemtap-steved-a432e18a24569804c82f14b36ae7d8dfcc245da7.tar.gz systemtap-steved-a432e18a24569804c82f14b36ae7d8dfcc245da7.tar.xz systemtap-steved-a432e18a24569804c82f14b36ae7d8dfcc245da7.zip |
2005-11-28 Martin Hunt <hunt@redhat.com>
* 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.
-rw-r--r-- | runtime/ChangeLog | 9 | ||||
-rw-r--r-- | runtime/alloc.c | 20 | ||||
-rw-r--r-- | runtime/map-stat.c | 4 | ||||
-rw-r--r-- | runtime/map.c | 8 | ||||
-rw-r--r-- | runtime/pmap-gen.c | 12 | ||||
-rw-r--r-- | runtime/runtime.h | 1 | ||||
-rw-r--r-- | runtime/user/alloc.c | 7 | ||||
-rw-r--r-- | runtime/user/runtime.h | 1 |
8 files changed, 36 insertions, 26 deletions
diff --git a/runtime/ChangeLog b/runtime/ChangeLog index d90cd67d..5d2c0532 100644 --- a/runtime/ChangeLog +++ b/runtime/ChangeLog @@ -1,5 +1,14 @@ 2005-11-28 Martin Hunt <hunt@redhat.com> + * 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. + * map.c (_stp_pmap_del): Use _stp_free_percpu() to free pmaps. 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? diff --git a/runtime/map-stat.c b/runtime/map-stat.c index 51377d00..c9ba4b02 100644 --- a/runtime/map-stat.c +++ b/runtime/map-stat.c @@ -79,7 +79,7 @@ static MAP _stp_pmap_new_hstat_linear (unsigned max_entries, int ksize, int star int i; MAP m; for_each_cpu(i) { - m = per_cpu_ptr (map, i); + m = _stp_per_cpu_ptr (map, i); m->hist.type = HIST_LINEAR; m->hist.start = start; m->hist.stop = stop; @@ -106,7 +106,7 @@ static MAP _stp_pmap_new_hstat_log (unsigned max_entries, int key_size, int buck int i; MAP m; for_each_cpu(i) { - m = per_cpu_ptr (map, i); + m = _stp_per_cpu_ptr (map, i); m->hist.type = HIST_LOG; m->hist.buckets = buckets; } diff --git a/runtime/map.c b/runtime/map.c index 70efd365..556cd85f 100644 --- a/runtime/map.c +++ b/runtime/map.c @@ -249,7 +249,7 @@ static MAP _stp_pmap_new(unsigned max_entries, int type, int key_size, int data_ return NULL; for_each_cpu(i) { - m = per_cpu_ptr (map, i); + m = _stp_per_cpu_ptr (map, i); if (_stp_map_init(m, max_entries, type, key_size, data_size, i)) { failed = i; goto err; @@ -370,7 +370,7 @@ void _stp_pmap_del(MAP map) return; for_each_cpu(i) { - m = per_cpu_ptr (map, i); + m = _stp_per_cpu_ptr (map, i); _stp_vfree(m->membuf); } @@ -711,7 +711,7 @@ void _stp_map_printn (MAP map, int n, const char *fmt) void _stp_pmap_printn_cpu (MAP map, int n, const char *fmt, int cpu) { - MAP m = per_cpu_ptr (map, cpu); + MAP m = _stp_per_cpu_ptr (map, cpu); _stp_map_printn (m, n, fmt); } @@ -826,7 +826,7 @@ MAP _stp_pmap_agg (MAP map) _stp_map_clear (agg); for_each_cpu(i) { - m = per_cpu_ptr (map, i); + m = _stp_per_cpu_ptr (map, i); /* walk the hash chains. */ for (hash = 0; hash < HASH_TABLE_SIZE; hash++) { head = &m->hashes[hash]; diff --git a/runtime/pmap-gen.c b/runtime/pmap-gen.c index 038eba62..a57806d4 100644 --- a/runtime/pmap-gen.c +++ b/runtime/pmap-gen.c @@ -407,7 +407,7 @@ MAP KEYSYM(_stp_pmap_new) (unsigned max_entries) int i; MAP m; for_each_cpu(i) { - m = per_cpu_ptr (map, i); + m = _stp_per_cpu_ptr (map, i); m->get_key = KEYSYM(pmap_get_key); m->copy = KEYSYM(pmap_copy_keys); m->cmp = KEYSYM(pmap_key_cmp); @@ -464,7 +464,7 @@ MAP KEYSYM(_stp_pmap_new) (unsigned max_entries, int htype, ...) int i; MAP m; for_each_cpu(i) { - m = per_cpu_ptr (map, i); + m = _stp_per_cpu_ptr (map, i); m->get_key = KEYSYM(pmap_get_key); m->copy = KEYSYM(pmap_copy_keys); m->cmp = KEYSYM(pmap_key_cmp); @@ -534,7 +534,7 @@ int KEYSYM(__stp_pmap_set) (MAP map, ALLKEYSD(key), VSTYPE val, int add) int KEYSYM(_stp_pmap_set) (MAP map, ALLKEYSD(key), VSTYPE val) { - MAP m = per_cpu_ptr (map, get_cpu()); + MAP m = _stp_per_cpu_ptr (map, get_cpu()); int res = KEYSYM(__stp_pmap_set) (m, ALLKEYS(key), val, 0); put_cpu(); return res; @@ -542,7 +542,7 @@ int KEYSYM(_stp_pmap_set) (MAP map, ALLKEYSD(key), VSTYPE val) int KEYSYM(_stp_pmap_add) (MAP map, ALLKEYSD(key), VSTYPE val) { - MAP m = per_cpu_ptr (map, get_cpu()); + MAP m = _stp_per_cpu_ptr (map, get_cpu()); int res = KEYSYM(__stp_pmap_set) (m, ALLKEYS(key), val, 1); put_cpu(); return res; @@ -561,7 +561,7 @@ VALTYPE KEYSYM(_stp_pmap_get_cpu) (MAP pmap, ALLKEYSD(key)) if (pmap == NULL) return (VALTYPE)0; - map = per_cpu_ptr (pmap, get_cpu()); + map = _stp_per_cpu_ptr (pmap, get_cpu()); hv = KEYSYM(phash) (ALLKEYS(key)); head = &map->hashes[hv]; @@ -639,7 +639,7 @@ VALTYPE KEYSYM(_stp_pmap_get) (MAP pmap, ALLKEYSD(key)) /* now total each cpu */ for_each_cpu(cpu) { - map = per_cpu_ptr (pmap, cpu); + map = _stp_per_cpu_ptr (pmap, cpu); head = &map->hashes[hv]; hlist_for_each(e, head) { n = (struct KEYSYM(pmap_node) *)((long)e - sizeof(struct list_head)); diff --git a/runtime/runtime.h b/runtime/runtime.h index cdae6764..fe176ab0 100644 --- a/runtime/runtime.h +++ b/runtime/runtime.h @@ -63,6 +63,7 @@ static struct #include "arith.c" #include "copy.c" #include "sym.h" +#include "alloc.c" /************* Module Stuff ********************/ diff --git a/runtime/user/alloc.c b/runtime/user/alloc.c index 9c7fa5c0..2691a36a 100644 --- a/runtime/user/alloc.c +++ b/runtime/user/alloc.c @@ -78,6 +78,13 @@ void *_stp_valloc(size_t len) #define _stp_valloc_percpu(type) \ ((type *)(__stp_valloc_percpu(sizeof(type), __alignof__(type)))) #define _stp_percpu_dptr(ptr) (((struct percpu_data *)~(unsigned long)(ptr))->blkp) +#define _stp_per_cpu_ptr(ptr, cpu) \ +({ \ + struct percpu_data *__p = (struct 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 */ diff --git a/runtime/user/runtime.h b/runtime/user/runtime.h index 725147a4..79a9dc22 100644 --- a/runtime/user/runtime.h +++ b/runtime/user/runtime.h @@ -51,5 +51,6 @@ void exit(int status); #include "print.c" #include "string.c" #include "arith.c" +#include "alloc.c" #endif /* _RUNTIME_H_ */ |