diff options
Diffstat (limited to 'runtime')
-rw-r--r-- | runtime/ChangeLog | 8 | ||||
-rw-r--r-- | runtime/stat-common.c | 7 | ||||
-rw-r--r-- | runtime/stat.c | 9 |
3 files changed, 19 insertions, 5 deletions
diff --git a/runtime/ChangeLog b/runtime/ChangeLog index 4f4e5524..4be3350b 100644 --- a/runtime/ChangeLog +++ b/runtime/ChangeLog @@ -1,3 +1,11 @@ +2007-07-06 Martin Hunt <hunt@redhat.com> + + * stat-common.c (__stp_stat_add): Fix calculations + for linear histogram buckets. + + * stat.c (_stp_stat_init): Check for interval too + small. + 2007-07-05 Eugene Teo <eteo@redhat.com> * regs.c (_stp_print_regs): #ifdef CONFIG_CPU_CP15 instead. diff --git a/runtime/stat-common.c b/runtime/stat-common.c index 48f8218a..9ca045c9 100644 --- a/runtime/stat-common.c +++ b/runtime/stat-common.c @@ -237,10 +237,9 @@ static void __stp_stat_add (Hist st, stat *sd, int64_t val) sd->histogram[n]++; break; case HIST_LINEAR: - if (val < st->start) - val = st->start; - else - val -= st->start; + val -= st->start; + if (val < 0) + val = 0; do_div (val, st->interval); if (val >= st->buckets) val = st->buckets - 1; diff --git a/runtime/stat.c b/runtime/stat.c index cf224e5e..f4e205aa 100644 --- a/runtime/stat.c +++ b/runtime/stat.c @@ -90,9 +90,16 @@ Stat _stp_stat_init (int type, ...) start = va_arg(ap, int); stop = va_arg(ap, int); interval = va_arg(ap, int); - /* FIXME. check interval != 0 and not too large */ + if (interval == 0) { + _stp_warn("histogram: interval cannot be zero.\n"); + return NULL; + } buckets = (stop - start) / interval; if ((stop - start) % interval) buckets++; + if (buckets > 128) { + _stp_warn("histogram: Interval is too small. Maximum buckets is 128.\n"); + return NULL; + } } va_end (ap); } |