Author: trociny
Date: Sat Dec 15 18:19:48 2012
New Revision: 244270
URL: http://svnweb.freebsd.org/changeset/base/244270

Log:
  New devstat metrics for devstat_compute_statistics():
  
    DSM_TOTAL_DURATION
    DSM_TOTAL_DURATION_READ
    DSM_TOTAL_DURATION_WRITE
    DSM_TOTAL_DURATION_FREE
    DSM_TOTAL_DURATION_OTHER
    DSM_TOTAL_BUSY_TIME

Modified:
  head/lib/libdevstat/devstat.3
  head/lib/libdevstat/devstat.c
  head/lib/libdevstat/devstat.h

Modified: head/lib/libdevstat/devstat.3
==============================================================================
--- head/lib/libdevstat/devstat.3       Sat Dec 15 17:54:29 2012        
(r244269)
+++ head/lib/libdevstat/devstat.3       Sat Dec 15 18:19:48 2012        
(r244270)
@@ -27,7 +27,7 @@
 .\"
 .\" $FreeBSD$
 .\"
-.Dd March 18, 2003
+.Dd December 15, 2012
 .Dt DEVSTAT 3
 .Os
 .Sh NAME
@@ -526,6 +526,35 @@ the acquisition of
 .Fa previous
 and
 .Fa current .
+.It Dv DSM_TOTAL_DURATION
+type:
+.Vt "long double *"
+.Pp
+The total duration of transactions, in seconds, between the acquisition of
+.Fa previous
+and
+.Fa current .
+.It Dv DSM_TOTAL_DURATION_OTHER
+.It Dv DSM_TOTAL_DURATION_READ
+.It Dv DSM_TOTAL_DURATION_WRITE
+.It Dv DSM_TOTAL_DURATION_FREE
+type:
+.Vt "long double *"
+.Pp
+The total duration of transactions of the specified type between
+the acquisition of
+.Fa previous
+and
+.Fa current .
+.It Dv DSM_TOTAL_BUSY_TIME
+type:
+.Vt "long double *"
+.Pp
+Total time the device had one or more transactions outstanding
+between the acquisition of
+.Fa previous
+and
+.Fa current .
 .It Dv DSM_TOTAL_BLOCKS
 type:
 .Vt "uint64_t *"

Modified: head/lib/libdevstat/devstat.c
==============================================================================
--- head/lib/libdevstat/devstat.c       Sat Dec 15 17:54:29 2012        
(r244269)
+++ head/lib/libdevstat/devstat.c       Sat Dec 15 18:19:48 2012        
(r244270)
@@ -133,6 +133,12 @@ struct devstat_args {
        { DSM_MS_PER_TRANSACTION_FREE, DEVSTAT_ARG_LD },
        { DSM_BUSY_PCT, DEVSTAT_ARG_LD },
        { DSM_QUEUE_LENGTH, DEVSTAT_ARG_UINT64 },
+       { DSM_TOTAL_DURATION, DEVSTAT_ARG_LD },
+       { DSM_TOTAL_DURATION_READ, DEVSTAT_ARG_LD },
+       { DSM_TOTAL_DURATION_WRITE, DEVSTAT_ARG_LD },
+       { DSM_TOTAL_DURATION_FREE, DEVSTAT_ARG_LD },
+       { DSM_TOTAL_DURATION_OTHER, DEVSTAT_ARG_LD },
+       { DSM_TOTAL_BUSY_TIME, DEVSTAT_ARG_LD },
 };
 
 static const char *namelist[] = {
@@ -1217,11 +1223,13 @@ devstat_compute_statistics(struct devsta
        u_int64_t totaltransfers, totaltransfersread, totaltransferswrite;
        u_int64_t totaltransfersother, totalblocks, totalblocksread;
        u_int64_t totalblockswrite, totaltransfersfree, totalblocksfree;
+       long double totalduration, totaldurationread, totaldurationwrite;
+       long double totaldurationfree, totaldurationother;
        va_list ap;
        devstat_metric metric;
        u_int64_t *destu64;
        long double *destld;
-       int retval, i;
+       int retval;
 
        retval = 0;
 
@@ -1263,6 +1271,13 @@ devstat_compute_statistics(struct devsta
                totalblocksfree /= 512;
        }
 
+       totaldurationread = DELTA_T(duration[DEVSTAT_READ]);
+       totaldurationwrite = DELTA_T(duration[DEVSTAT_WRITE]);
+       totaldurationfree = DELTA_T(duration[DEVSTAT_FREE]);
+       totaldurationother = DELTA_T(duration[DEVSTAT_NO_DATA]);
+       totalduration = totaldurationread + totaldurationwrite +
+           totaldurationfree + totaldurationother;
+
        va_start(ap, etime);
 
        while ((metric = (devstat_metric)va_arg(ap, devstat_metric)) != 0) {
@@ -1484,9 +1499,7 @@ devstat_compute_statistics(struct devsta
                 */
                case DSM_MS_PER_TRANSACTION:
                        if (totaltransfers > 0) {
-                               *destld = 0;
-                               for (i = 0; i < DEVSTAT_N_TRANS_FLAGS; i++)
-                                       *destld += DELTA_T(duration[i]);
+                               *destld = totalduration;
                                *destld /= totaltransfers;
                                *destld *= 1000;
                        } else
@@ -1499,7 +1512,7 @@ devstat_compute_statistics(struct devsta
                 */
                case DSM_MS_PER_TRANSACTION_READ:
                        if (totaltransfersread > 0) {
-                               *destld = DELTA_T(duration[DEVSTAT_READ]);
+                               *destld = totaldurationread;
                                *destld /= totaltransfersread;
                                *destld *= 1000;
                        } else
@@ -1507,7 +1520,7 @@ devstat_compute_statistics(struct devsta
                        break;
                case DSM_MS_PER_TRANSACTION_WRITE:
                        if (totaltransferswrite > 0) {
-                               *destld = DELTA_T(duration[DEVSTAT_WRITE]);
+                               *destld = totaldurationwrite;
                                *destld /= totaltransferswrite;
                                *destld *= 1000;
                        } else
@@ -1515,7 +1528,7 @@ devstat_compute_statistics(struct devsta
                        break;
                case DSM_MS_PER_TRANSACTION_FREE:
                        if (totaltransfersfree > 0) {
-                               *destld = DELTA_T(duration[DEVSTAT_FREE]);
+                               *destld = totaldurationfree;
                                *destld /= totaltransfersfree;
                                *destld *= 1000;
                        } else
@@ -1523,7 +1536,7 @@ devstat_compute_statistics(struct devsta
                        break;
                case DSM_MS_PER_TRANSACTION_OTHER:
                        if (totaltransfersother > 0) {
-                               *destld = DELTA_T(duration[DEVSTAT_NO_DATA]);
+                               *destld = totaldurationother;
                                *destld /= totaltransfersother;
                                *destld *= 1000;
                        } else
@@ -1541,6 +1554,24 @@ devstat_compute_statistics(struct devsta
                case DSM_QUEUE_LENGTH:
                        *destu64 = current->start_count - current->end_count;
                        break;
+               case DSM_TOTAL_DURATION:
+                       *destld = totalduration;
+                       break;
+               case DSM_TOTAL_DURATION_READ:
+                       *destld = totaldurationread;
+                       break;
+               case DSM_TOTAL_DURATION_WRITE:
+                       *destld = totaldurationwrite;
+                       break;
+               case DSM_TOTAL_DURATION_FREE:
+                       *destld = totaldurationfree;
+                       break;
+               case DSM_TOTAL_DURATION_OTHER:
+                       *destld = totaldurationother;
+                       break;
+               case DSM_TOTAL_BUSY_TIME:
+                       *destld = DELTA_T(busy_time);
+                       break;
 /*
  * XXX: comment out the default block to see if any case's are missing.
  */

Modified: head/lib/libdevstat/devstat.h
==============================================================================
--- head/lib/libdevstat/devstat.h       Sat Dec 15 17:54:29 2012        
(r244269)
+++ head/lib/libdevstat/devstat.h       Sat Dec 15 18:19:48 2012        
(r244270)
@@ -97,6 +97,12 @@ typedef enum {
        DSM_MS_PER_TRANSACTION_FREE,
        DSM_BUSY_PCT,
        DSM_QUEUE_LENGTH,
+       DSM_TOTAL_DURATION,
+       DSM_TOTAL_DURATION_READ,
+       DSM_TOTAL_DURATION_WRITE,
+       DSM_TOTAL_DURATION_FREE,
+       DSM_TOTAL_DURATION_OTHER,
+       DSM_TOTAL_BUSY_TIME,
        DSM_MAX
 } devstat_metric;
 
_______________________________________________
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"

Reply via email to