summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorpluknet <pluknet@FreeBSD.org>2013-12-25 17:11:49 +0000
committerpluknet <pluknet@FreeBSD.org>2013-12-25 17:11:49 +0000
commitba8551c440ea7523bf1b029f3aedb894070e0ee4 (patch)
tree945595d4fbc1bc1d40035db0b32737bc170207de /lib
parent723d6ab041aae81720f6bfc576e458da69f709ff (diff)
downloadFreeBSD-src-ba8551c440ea7523bf1b029f3aedb894070e0ee4.zip
FreeBSD-src-ba8551c440ea7523bf1b029f3aedb894070e0ee4.tar.gz
For vmcore, calculate time relative to device creation upon time_uptime.
Previously it used a clock from live kernel. MFC after: 2 weeks
Diffstat (limited to 'lib')
-rw-r--r--lib/libdevstat/devstat.c15
1 files changed, 11 insertions, 4 deletions
diff --git a/lib/libdevstat/devstat.c b/lib/libdevstat/devstat.c
index 0f313fb..d18f95d 100644
--- a/lib/libdevstat/devstat.c
+++ b/lib/libdevstat/devstat.c
@@ -150,7 +150,9 @@ static const char *namelist[] = {
"_devstat_version",
#define X_DEVICE_STATQ 3
"_device_statq",
-#define X_END 4
+#define X_TIME_UPTIME 4
+ "_time_uptime",
+#define X_END 5
};
/*
@@ -349,10 +351,10 @@ devstat_getdevs(kvm_t *kd, struct statinfo *stats)
oldnumdevs = dinfo->numdevs;
oldgeneration = dinfo->generation;
- clock_gettime(CLOCK_MONOTONIC, &ts);
- stats->snap_time = ts.tv_sec + ts.tv_nsec * 1e-9;
-
if (kd == NULL) {
+ clock_gettime(CLOCK_MONOTONIC, &ts);
+ stats->snap_time = ts.tv_sec + ts.tv_nsec * 1e-9;
+
/* If this is our first time through, mem_ptr will be null. */
if (dinfo->mem_ptr == NULL) {
/*
@@ -433,6 +435,11 @@ devstat_getdevs(kvm_t *kd, struct statinfo *stats)
}
} else {
+ if (KREADNL(kd, X_TIME_UPTIME, ts.tv_sec) == -1)
+ return(-1);
+ else
+ stats->snap_time = ts.tv_sec;
+
/*
* This is of course non-atomic, but since we are working
* on a core dump, the generation is unlikely to change
OpenPOWER on IntegriCloud