diff options
author | hunt <hunt> | 2005-11-08 19:48:23 +0000 |
---|---|---|
committer | hunt <hunt> | 2005-11-08 19:48:23 +0000 |
commit | 7ba70af105ed918b5b07e5bba8b5d27a8d911249 (patch) | |
tree | b33bcea26aa98488bfa987a62764837ae0c39bad /runtime/map-gen.c | |
parent | 4893e4b2858af12d916c3915a97336cdb0c8236b (diff) | |
download | systemtap-steved-7ba70af105ed918b5b07e5bba8b5d27a8d911249.tar.gz systemtap-steved-7ba70af105ed918b5b07e5bba8b5d27a8d911249.tar.xz systemtap-steved-7ba70af105ed918b5b07e5bba8b5d27a8d911249.zip |
2005-11-08 Martin Hunt <hunt@redhat.com>
* map.c (_stp_map_init): New function. Extracted from _stp_map_new()
so it can be used in _stp_pmap_new().
(_stp_map_new): Call _stp_map_init().
(_stp_pmap_new): New function.
(_stp_pmap_new_hstat_linear): New function.
(_stp_pmap_new_hstat_log): New function.
(_stp_pmap_del): New function.
(_stp_pmap_printn_cpu): New function.
(_stp_pmap_printn): New function.
(_stp_new_agg): New function.
(_stp_add_agg): New function.
(_stp_pmap_agg): New function.
(_new_map_clear_node): New function.
* map.h (struct map_root): Add Hist struct. Add copy
and cmp function pointers for pmaps.
* stat.h: Remove Stat struct. Replace with Hist struct
that is limited to only histogram params.
* map-stat.c: Fix up references to histogram params in map_root.
* stat-common.c: Ditto.
* stat.c: Ditto.
* pmap-gen.c: New file. Implements per-cpu maps.
* map-gen.c: Minor bug fixes. Use new VAL_IS_ZERO() macro.
* alloc.c (vmalloc_node): For NUMA, provide a vmalloc that
does node-local allocations.
(_stp_alloc_cpu): A version of _stp_alloc() that does
node-local allocations.
(_stp_valloc): A version of _stp_valloc() that does
node-local allocations.
(__stp_valloc_percpu): New function. Like alloc_percpu()
except uses _stp_valloc().
(_stp_vfree_percpu): New function. Like free_percpu().
Diffstat (limited to 'runtime/map-gen.c')
-rw-r--r-- | runtime/map-gen.c | 47 |
1 files changed, 18 insertions, 29 deletions
diff --git a/runtime/map-gen.c b/runtime/map-gen.c index 1034b5fb..c6acb781 100644 --- a/runtime/map-gen.c +++ b/runtime/map-gen.c @@ -40,6 +40,7 @@ #define VALN s #define MAP_SET_VAL(a,b,c,d) _new_map_set_str(a,b,c,d) #define MAP_GET_VAL(n) _stp_get_str(n) +#define VAL_IS_ZERO(val,add) (val == 0 || *val == 0) #elif VALUE_TYPE == INT64 #define VALTYPE int64_t #define VSTYPE int64_t @@ -47,6 +48,7 @@ #define VALN i #define MAP_SET_VAL(a,b,c,d) _new_map_set_int64(a,b,c,d) #define MAP_GET_VAL(n) _stp_get_int64(n) +#define VAL_IS_ZERO(val,add) (val == 0) #elif VALUE_TYPE == STAT #define VALTYPE stat* #define VSTYPE int64_t @@ -54,6 +56,7 @@ #define VALN x #define MAP_SET_VAL(a,b,c,d) _new_map_set_stat(a,b,c,d) #define MAP_GET_VAL(n) _stp_get_stat(n) +#define VAL_IS_ZERO(val,add) (val == 0 && !add) #else #error Need to define VALUE_TYPE as STRING, STAT, or INT64 #endif /* VALUE_TYPE */ @@ -333,18 +336,10 @@ static unsigned int KEYSYM(hash) (ALLKEYSD(key)) } -#if VALUE_TYPE == INT64 +#if VALUE_TYPE == INT64 || VALUE_TYPE == STRING MAP KEYSYM(_stp_map_new) (unsigned max_entries) { - MAP m = _stp_map_new (max_entries, INT64, sizeof(struct KEYSYM(map_node)), 0); - if (m) - m->get_key = KEYSYM(map_get_key); - return m; -} -#elif VALUE_TYPE == STRING -MAP KEYSYM(_stp_map_new) (unsigned max_entries) -{ - MAP m = _stp_map_new (max_entries, STRING, sizeof(struct KEYSYM(map_node)), 0); + MAP m = _stp_map_new (max_entries, VALUE_TYPE, sizeof(struct KEYSYM(map_node)), 0); if (m) m->get_key = KEYSYM(map_get_key); return m; @@ -415,8 +410,9 @@ int KEYSYM(__stp_map_set) (MAP map, ALLKEYSD(key), VSTYPE val, int add) head = &map->hashes[hv]; hlist_for_each(e, head) { - n = (struct KEYSYM(map_node) *)((long)e - sizeof(struct hlist_node)); - dbug ("n=%lx key1=%ld n->key1=%ld\n", (long)n, key1, n->key1); + n = (struct KEYSYM(map_node) *)((long)e - sizeof(struct list_head)); + dbug("map_node =%lx\n", (long)n); + //dbug ("n=%lx key1=%ld n->key1=%ld\n", (long)n, key1, n->key1); if (KEY1_EQ_P(n->key1, key1) #if KEY_ARITY > 1 && KEY2_EQ_P(n->key2, key2) @@ -431,32 +427,25 @@ int KEYSYM(__stp_map_set) (MAP map, ALLKEYSD(key), VSTYPE val, int add) #endif #endif ) { -#if VALUE_TYPE == STAT - return _new_map_set_stat(map,(struct map_node *)n, val, add, 0); -#else + if VAL_IS_ZERO(val,add) { + if (!add) + _new_map_del_node(map,(struct map_node *)n); + return 0; + + } return MAP_SET_VAL(map,(struct map_node *)n, val, add); -#endif } } /* key not found */ dbug("key not found\n"); -#if VALUE_TYPE == STRING - if ((val == 0 || *val == 0) && !add) - return 0; -#else - if (val == 0 && !add) + if VAL_IS_ZERO(val,add) return 0; -#endif n = (struct KEYSYM(map_node)*)_new_map_create (map, head); if (n == NULL) return -1; KEYCPY(n); -#if VALUE_TYPE == STAT - return _new_map_set_stat(map,(struct map_node *)n, val, add, 1); -#else return MAP_SET_VAL(map,(struct map_node *)n, val, 0); -#endif } int KEYSYM(_stp_map_set) (MAP map, ALLKEYSD(key), VSTYPE val) @@ -484,8 +473,8 @@ VALTYPE KEYSYM(_stp_map_get) (MAP map, ALLKEYSD(key)) head = &map->hashes[hv]; hlist_for_each(e, head) { - n = (struct KEYSYM(map_node) *)((long)e - sizeof(struct hlist_node)); -// dbug ("n =%lx key=" EACHKEY(%ld) "\n", (long)n, n->key1.val, n->key2.val); + n = (struct KEYSYM(map_node) *)((long)e - sizeof(struct list_head)); + dbug("map_node =%lx\n", (long)n); if (KEY1_EQ_P(n->key1, key1) #if KEY_ARITY > 1 && KEY2_EQ_P(n->key2, key2) @@ -561,5 +550,5 @@ VALTYPE KEYSYM(_stp_map_get) (MAP map, ALLKEYSD(key)) #undef MAP_SET_VAL #undef MAP_GET_VAL - +#undef VAL_IS_ZERO |