summaryrefslogtreecommitdiffstats
path: root/runtime/map-stat.c
diff options
context:
space:
mode:
authorhunt <hunt>2007-09-12 18:37:47 +0000
committerhunt <hunt>2007-09-12 18:37:47 +0000
commit3a18979dd18ba8cdd96367d2ad18c456f26c6f20 (patch)
tree9b345453171b5a796ecf65c59f052f9e9373c87a /runtime/map-stat.c
parent674f70a0371c1f97a83c66268d03332ebbf9e62f (diff)
downloadsystemtap-steved-3a18979dd18ba8cdd96367d2ad18c456f26c6f20.tar.gz
systemtap-steved-3a18979dd18ba8cdd96367d2ad18c456f26c6f20.tar.xz
systemtap-steved-3a18979dd18ba8cdd96367d2ad18c456f26c6f20.zip
2007-09-12 Martin Hunt <hunt@redhat.com>
* map-stat.c (_stp_map_new_hstat_log): Set buckets to HIST_LOG_BUCKETS. (_stp_pmap_new_hstat_log): Ditto. (_stp_map_new_hstat_linear): Call _stp_stat_calc_buckets(). (_stp_pmap_new_hstat_linear): Ditto. * stat.h (STP_MAX_BUCKETS): Define.. (HIST_LOG_BUCKETS): Define. * stat.c (_stp_stat_init): Call _stp_stat_calc_buckets(). * stat-common.c (_stp_stat_calc_buckets): New function. Common bucket calculation and error reporting code. (_stp_bucket_to_val): New function. (_stp_val_to_bucket): Renamed and now handles negative numbers. (_stp_stat_print_histogram): Handle negative values in log histograms. (__stp_stat_add): Cleanup.. * map-gen.c (_stp_map_new): Remove buckets param for HIST_LOG. * pmap-gen.c (_stp_pmap_new): Ditto.
Diffstat (limited to 'runtime/map-stat.c')
-rw-r--r--runtime/map-stat.c40
1 files changed, 15 insertions, 25 deletions
diff --git a/runtime/map-stat.c b/runtime/map-stat.c
index 6634a2b7..dc3fd6ac 100644
--- a/runtime/map-stat.c
+++ b/runtime/map-stat.c
@@ -14,25 +14,19 @@
#include "stat-common.c"
-
static void _stp_map_print_histogram (MAP map, stat *sd)
{
_stp_stat_print_histogram (&map->hist, sd);
}
-static MAP _stp_map_new_hstat_log (unsigned max_entries, int key_size, int buckets)
+static MAP _stp_map_new_hstat_log (unsigned max_entries, int key_size)
{
/* add size for buckets */
- int size = buckets * sizeof(int64_t) + sizeof(stat);
+ int size = HIST_LOG_BUCKETS * sizeof(int64_t) + sizeof(stat);
MAP m = _stp_map_new (max_entries, STAT, key_size, size);
if (m) {
m->hist.type = HIST_LOG;
- m->hist.buckets = buckets;
- if (buckets < 1 || buckets > 64) {
- _stp_warn("histogram: Bad number of buckets. Must be between 1 and 64\n");
- m->hist.type = HIST_NONE;
- return m;
- }
+ m->hist.buckets = HIST_LOG_BUCKETS;
}
return m;
}
@@ -41,12 +35,13 @@ static MAP _stp_map_new_hstat_linear (unsigned max_entries, int ksize, int start
{
MAP m;
int size;
- int buckets = (stop - start) / interval;
- if ((stop - start) % interval) buckets++;
-
+ int buckets = _stp_stat_calc_buckets(stop, start, interval);
+ if (!buckets)
+ return NULL;
+
/* add size for buckets */
size = buckets * sizeof(int64_t) + sizeof(stat);
-
+
m = _stp_map_new (max_entries, STAT, ksize, size);
if (m) {
m->hist.type = HIST_LINEAR;
@@ -54,12 +49,6 @@ static MAP _stp_map_new_hstat_linear (unsigned max_entries, int ksize, int start
m->hist.stop = stop;
m->hist.interval = interval;
m->hist.buckets = buckets;
- if (m->hist.buckets <= 0) {
- _stp_warn("histogram: bad stop, start and/or interval\n");
- m->hist.type = HIST_NONE;
- return m;
- }
-
}
return m;
}
@@ -68,8 +57,9 @@ static PMAP _stp_pmap_new_hstat_linear (unsigned max_entries, int ksize, int sta
{
PMAP pmap;
int size;
- int buckets = (stop - start) / interval;
- if ((stop - start) % interval) buckets++;
+ int buckets = _stp_stat_calc_buckets(stop, start, interval);
+ if (!buckets)
+ return NULL;
/* add size for buckets */
size = buckets * sizeof(int64_t) + sizeof(stat);
@@ -97,10 +87,10 @@ static PMAP _stp_pmap_new_hstat_linear (unsigned max_entries, int ksize, int sta
return pmap;
}
-static PMAP _stp_pmap_new_hstat_log (unsigned max_entries, int key_size, int buckets)
+static PMAP _stp_pmap_new_hstat_log (unsigned max_entries, int key_size)
{
/* add size for buckets */
- int size = buckets * sizeof(int64_t) + sizeof(stat);
+ int size = HIST_LOG_BUCKETS * sizeof(int64_t) + sizeof(stat);
PMAP pmap = _stp_pmap_new (max_entries, STAT, key_size, size);
if (pmap) {
int i;
@@ -108,12 +98,12 @@ static PMAP _stp_pmap_new_hstat_log (unsigned max_entries, int key_size, int buc
for_each_cpu(i) {
m = (MAP)per_cpu_ptr (pmap->map, i);
m->hist.type = HIST_LOG;
- m->hist.buckets = buckets;
+ m->hist.buckets = HIST_LOG_BUCKETS;
}
/* now set agg map params */
m = &pmap->agg;
m->hist.type = HIST_LOG;
- m->hist.buckets = buckets;
+ m->hist.buckets = HIST_LOG_BUCKETS;
}
return pmap;
}