summaryrefslogtreecommitdiffstats
path: root/usr.bin
diff options
context:
space:
mode:
authorphk <phk@FreeBSD.org>2003-03-15 21:59:06 +0000
committerphk <phk@FreeBSD.org>2003-03-15 21:59:06 +0000
commitf432014308d6b21386e15affbbca62043615671d (patch)
treec322a33c0275fefd9ca33cd377e3d6f459cb9a8c /usr.bin
parentd16675cd85efe1cde6bf077376276f3de06f0263 (diff)
downloadFreeBSD-src-f432014308d6b21386e15affbbca62043615671d.zip
FreeBSD-src-f432014308d6b21386e15affbbca62043615671d.tar.gz
Run a revision of the devstat interface:
Kernel: Change statistics to use the *uptime() timescale (ie: relative to boottime) rather than the UTC aligned timescale. This makes the device statistics code oblivious to clock steps. Change timestamps to bintime format, they are cheaper. Remove the "busy_count", and replace it with two counter fields: "start_count" and "end_count", which are updated in the down and up paths respectively. This removes the locking constraint on devstat. Add a timestamp argument to devstat_start_transaction(), this will normally be a timestamp set by the *_bio() function in bp->bio_t0. Use this field to calculate duration of I/O operations. Add two timestamp arguments to devstat_end_transaction(), one is the current time, a NULL pointer means "take timestamp yourself", the other is the timestamp of when this transaction started (see above). Change calculation of busy_time to operate on "the salami principle": Only when we are idle, which we can determine by the start+end counts being identical, do we update the "busy_from" field in the down path. In the up path we accumulate the timeslice in busy_time and update busy_from. Change the byte_* and num_* fields into two arrays: bytes[] and operations[]. Userland: Change the misleading "busy_time" name to be called "snap_time" and make the time long double since that is what most users need anyway, fill it using clock_gettime(CLOCK_MONOTONIC) to put it on the same timescale as the kernel fields. Change devstat_compute_etime() to operate on struct bintime. Remove the version 2 legacy interface: the change to bintime makes compatibility far too expensive. Fix a bug in systat's "vm" page where boot relative busy times would be bogus. Bump __FreeBSD_version to 500107 Review & Collaboration by: ken
Diffstat (limited to 'usr.bin')
-rw-r--r--usr.bin/systat/iostat.c4
-rw-r--r--usr.bin/systat/vmstat.c26
-rw-r--r--usr.bin/vmstat/vmstat.c4
3 files changed, 17 insertions, 17 deletions
diff --git a/usr.bin/systat/iostat.c b/usr.bin/systat/iostat.c
index ba39f3e..a54bb6d 100644
--- a/usr.bin/systat/iostat.c
+++ b/usr.bin/systat/iostat.c
@@ -148,8 +148,6 @@ fetchiostat()
last.dinfo = cur.dinfo;
cur.dinfo = tmp_dinfo;
- last.busy_time = cur.busy_time;
-
/*
* Here what we want to do is refresh our device stats.
* getdevs() returns 1 when the device list has changed.
@@ -322,7 +320,7 @@ devstats(row, _col, dn)
di = dev_select[dn].position;
- busy_seconds = devstat_compute_etime(cur.busy_time, last.busy_time);
+ busy_seconds = cur.snap_time - last.snap_time;
if (devstat_compute_statistics(&cur.dinfo->devices[di],
&last.dinfo->devices[di], busy_seconds,
diff --git a/usr.bin/systat/vmstat.c b/usr.bin/systat/vmstat.c
index 5fc1985..ff7a37b 100644
--- a/usr.bin/systat/vmstat.c
+++ b/usr.bin/systat/vmstat.c
@@ -798,7 +798,7 @@ getinfo(ls)
last.dinfo = cur.dinfo;
cur.dinfo = tmp_dinfo;
- last.busy_time = cur.busy_time;
+ last.snap_time = cur.snap_time;
switch (devstat_getdevs(NULL, &cur)) {
case -1:
errx(1, "%s", devstat_errbuf);
@@ -852,12 +852,19 @@ dinfo(dn, lc, now, then)
di = dev_select[dn].position;
- elapsed_time = devstat_compute_etime(now->busy_time,
- then ? then->busy_time : now->dinfo->devices[di].dev_creation_time);
-
- device_busy = devstat_compute_etime(now->dinfo->devices[di].busy_time,
- then ? then->dinfo->devices[di].busy_time :
- now->dinfo->devices[di].dev_creation_time);
+ if (then != NULL) {
+ /* Calculate relative to previous sample */
+ elapsed_time = now->snap_time - then->snap_time;
+ device_busy = devstat_compute_etime(
+ &now->dinfo->devices[di].busy_time,
+ &then->dinfo->devices[di].busy_time);
+ } else {
+ /* Calculate relative to device creation */
+ elapsed_time = now->snap_time - devstat_compute_etime(
+ &now->dinfo->devices[di].creation_time, NULL);
+ device_busy = devstat_compute_etime(
+ &now->dinfo->devices[di].busy_time, NULL);
+ }
if (devstat_compute_statistics(&now->dinfo->devices[di], then ?
&then->dinfo->devices[di] : NULL, elapsed_time,
@@ -866,11 +873,6 @@ dinfo(dn, lc, now, then)
DSM_NONE) != 0)
errx(1, "%s", devstat_errbuf);
- if ((device_busy == 0) && (transfers_per_second > 5))
- /* the device has been 100% busy, fake it because
- * as long as the device is 100% busy the busy_time
- * field in the devstat struct is not updated */
- device_busy = elapsed_time;
if (device_busy > elapsed_time)
/* this normally happens after one or more periods
* where the device has been 100% busy, correct it */
diff --git a/usr.bin/vmstat/vmstat.c b/usr.bin/vmstat/vmstat.c
index fb99b2c..88c1d21 100644
--- a/usr.bin/vmstat/vmstat.c
+++ b/usr.bin/vmstat/vmstat.c
@@ -428,7 +428,7 @@ dovmstat(interval, reps)
tmp_dinfo = last.dinfo;
last.dinfo = cur.dinfo;
cur.dinfo = tmp_dinfo;
- last.busy_time = cur.busy_time;
+ last.snap_time = cur.snap_time;
/*
* Here what we want to do is refresh our device stats.
@@ -680,7 +680,7 @@ devstats()
last.cp_time[state] = tmp;
}
- busy_seconds = devstat_compute_etime(cur.busy_time, last.busy_time);
+ busy_seconds = cur.snap_time - last.snap_time;
for (dn = 0; dn < num_devices; dn++) {
int di;
OpenPOWER on IntegriCloud