]> sourceware.org Git - systemtap.git/commitdiff
2007-07-06 Martin Hunt <hunt@redhat.com>
authorhunt <hunt>
Fri, 6 Jul 2007 18:42:00 +0000 (18:42 +0000)
committerhunt <hunt>
Fri, 6 Jul 2007 18:42:00 +0000 (18:42 +0000)
* stat-common.c (__stp_stat_add): Fix calculations
for linear histogram buckets.

* stat.c (_stp_stat_init): Check for interval too
small.

runtime/ChangeLog
runtime/stat-common.c
runtime/stat.c

index 4f4e5524312e85493996a25b15205689bb3d4e85..4be3350b6b623ca8382f0b060e387395e31be0af 100644 (file)
@@ -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.
index 48f8218a8df87e63a88fd4141d6c585b32cdc856..9ca045c9adb88f30dbb9fc38ec6dd055173e6b23 100644 (file)
@@ -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;
index cf224e5ea2c9e90224acbdced2bcb10890864f4d..f4e205aa7c8ccf3cd7a9cd09dc8209213b126d8b 100644 (file)
@@ -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);
        }
This page took 0.027919 seconds and 5 git commands to generate.