diff options
author | hunt <hunt> | 2005-11-09 08:24:52 +0000 |
---|---|---|
committer | hunt <hunt> | 2005-11-09 08:24:52 +0000 |
commit | 66f95fac49b0789dbf33026643c015c563b57572 (patch) | |
tree | 146e368636cf39e68a9ce6e127d2d8dc43a992e1 /runtime/map-stat.c | |
parent | df27664107205cccec6eacb890d6800db7ee95cc (diff) | |
download | systemtap-steved-66f95fac49b0789dbf33026643c015c563b57572.tar.gz systemtap-steved-66f95fac49b0789dbf33026643c015c563b57572.tar.xz systemtap-steved-66f95fac49b0789dbf33026643c015c563b57572.zip |
2005-11-09 Martin Hunt <hunt@redhat.com>
* map.h (struct map_root): Delete fields
used by old API.
* map.c: Remove old map API functions.
* map-stat.c (_stp_map_add_stat): Delete.
(_stp_pmap_new_hstat_linear): Move here from map.c.
(_stp_pmap_new_hstat_log): Ditto.
* list.c: Deleted.
* map-keys.c: Deleted.
* map-values.c: Deleted.
* map-int.c: Deleted.
Diffstat (limited to 'runtime/map-stat.c')
-rw-r--r-- | runtime/map-stat.c | 81 |
1 files changed, 55 insertions, 26 deletions
diff --git a/runtime/map-stat.c b/runtime/map-stat.c index fece087c..7d4e72aa 100644 --- a/runtime/map-stat.c +++ b/runtime/map-stat.c @@ -9,36 +9,11 @@ */ /** @file map-stat.c - * @brief Map functions to set and get stats + * @brief Map functions to handle statistics. */ #include "stat-common.c" -/* Adds an int64 to a stats map */ -static int _stp_map_add_stat (MAP map, int64_t val) -{ - stat *d; - - if (map == NULL) - return -2; - - if (map->create) { - struct map_node *m = __stp_map_create (map); - if (!m) - return -1; - - /* set the value */ - d = (stat *)((long)m + map->data_offset); - d->count = 0; - } else { - if (map->key == NULL) - return -2; - d = (stat *)((long)map->key + map->data_offset); - } - __stp_stat_add (&map->hist, d, val); - return 0; -} - static void _stp_map_print_histogram (MAP map, stat *sd) { @@ -88,3 +63,57 @@ static MAP _stp_map_new_hstat_linear (unsigned max_entries, int ksize, int start } return m; } + +static MAP _stp_pmap_new_hstat_linear (unsigned max_entries, int ksize, int start, int stop, int interval) +{ + MAP map; + int size; + int buckets = (stop - start) / interval; + if ((stop - start) % interval) buckets++; + + /* add size for buckets */ + size = buckets * sizeof(int64_t) + sizeof(stat); + + map = _stp_pmap_new (max_entries, STAT, ksize, size); + if (map) { + int i; + MAP m; + for_each_cpu(i) { + m = per_cpu_ptr (map, i); + m->hist.type = HIST_LINEAR; + m->hist.start = start; + m->hist.stop = stop; + m->hist.interval = interval; + m->hist.buckets = buckets; + } + /* now set agg map params */ + m = _stp_percpu_dptr(map); + m->hist.type = HIST_LINEAR; + m->hist.start = start; + m->hist.stop = stop; + m->hist.interval = interval; + m->hist.buckets = buckets; + } + return map; +} + +static MAP _stp_pmap_new_hstat_log (unsigned max_entries, int key_size, int buckets) +{ + /* add size for buckets */ + int size = buckets * sizeof(int64_t) + sizeof(stat); + MAP map = _stp_map_new (max_entries, STAT, key_size, size); + if (map) { + int i; + MAP m; + for_each_cpu(i) { + m = per_cpu_ptr (map, i); + m->hist.type = HIST_LOG; + m->hist.buckets = buckets; + } + /* now set agg map params */ + m = _stp_percpu_dptr(map); + m->hist.type = HIST_LOG; + m->hist.buckets = buckets; + } + return map; +} |