From 7ba70af105ed918b5b07e5bba8b5d27a8d911249 Mon Sep 17 00:00:00 2001 From: hunt Date: Tue, 8 Nov 2005 19:48:23 +0000 Subject: 2005-11-08 Martin Hunt * 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(). --- runtime/map.h | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) (limited to 'runtime/map.h') diff --git a/runtime/map.h b/runtime/map.h index 7dcb0e41..a0bb5521 100644 --- a/runtime/map.h +++ b/runtime/map.h @@ -102,6 +102,9 @@ struct map_root { /* space. */ void (*copy_keys)(struct map_root *, struct map_node *); key_data (*get_key)(struct map_node *mn, int n, int *type); + void (*copy)(struct map_node *dst, struct map_node *src); + int (*cmp)(struct map_node *dst, struct map_node *src); + int data_offset; /* this is the creation data saved between the key functions and the @@ -117,11 +120,7 @@ struct map_root { void *membuf; /* used if this map's nodes contain stats */ - enum histtype hist_type; - int hist_start; - int hist_stop; - int hist_int; - int hist_buckets; + struct _Hist hist; }; /** All maps are of this type. */ @@ -218,7 +217,7 @@ void int64_add(void *dest, int64_t val); int64_t int64_get(void *ptr); void stat_copy(void *dest, stat *src); void stat_add(void *dest, stat *src); -stat * stat_get(void *ptr); +stat *stat_get(void *ptr); int64_t _stp_key_get_int64(struct map_node *mn, int n); char * _stp_key_get_str(struct map_node *mn, int n); unsigned int int64_hash(const int64_t v); @@ -228,9 +227,10 @@ void str_add(void *dest, char *val); int str_eq_p(char *key1, char *key2); int64_t _stp_get_int64(struct map_node *m); char * _stp_get_str(struct map_node *m); -stat * _stp_get_stat(struct map_node *m); +stat *_stp_get_stat(struct map_node *m); unsigned int str_hash(const char *key1); static MAP _stp_map_new(unsigned max_entries, int type, int key_size, int data_size); +static MAP _stp_pmap_new(unsigned max_entries, int type, int key_size, int data_size); static int msb64(int64_t x); static MAP _stp_map_new_hstat_log(unsigned max_entries, int key_size, int buckets); static MAP _stp_map_new_hstat_linear(unsigned max_entries, int ksize, int start, int stop, int interval); @@ -248,7 +248,11 @@ static int64_t _new_map_get_int64 (MAP map, struct map_node *n); static char *_new_map_get_str (MAP map, struct map_node *n); static int _new_map_set_str (MAP map, struct map_node *n, char *val, int add); static stat *_new_map_get_stat (MAP map, struct map_node *n); -static int _new_map_set_stat (MAP map, struct map_node *n, int64_t val, int add, int new); +static int _new_map_set_stat (MAP map, struct map_node *n, int64_t val, int add); +static void _new_map_clear_node (struct map_node *); +static void _new_map_del_node (MAP map, struct map_node *n); +static MAP _stp_pmap_new_hstat_linear (unsigned max_entries, int ksize, int start, int stop, int interval); +static MAP _stp_pmap_new_hstat_log (unsigned max_entries, int key_size, int buckets); /* these prototypes suppress warnings from macros */ void _stp_map_key_str(MAP, char *); @@ -261,6 +265,7 @@ void _stp_map_key_int64(MAP, int64_t); void _stp_map_set_int64(MAP, int64_t); int64_t _stp_map_get_int64(MAP); + unsigned _stp_map_entry_exists(MAP); /** @endcond */ #endif /* _MAP_H_ */ -- cgit