From owner-svn-src-all@FreeBSD.ORG Wed Dec 25 17:11:50 2013 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 48A3A1B8; Wed, 25 Dec 2013 17:11:50 +0000 (UTC) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.freebsd.org (Postfix) with ESMTPS id 3013C13A0; Wed, 25 Dec 2013 17:11:50 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.7/8.14.7) with ESMTP id rBPHBoka021405; Wed, 25 Dec 2013 17:11:50 GMT (envelope-from pluknet@svn.freebsd.org) Received: (from pluknet@localhost) by svn.freebsd.org (8.14.7/8.14.7/Submit) id rBPHBoZE021404; Wed, 25 Dec 2013 17:11:50 GMT (envelope-from pluknet@svn.freebsd.org) Message-Id: <201312251711.rBPHBoZE021404@svn.freebsd.org> From: Sergey Kandaurov Date: Wed, 25 Dec 2013 17:11:50 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r259878 - head/lib/libdevstat X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.17 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 25 Dec 2013 17:11:50 -0000 Author: pluknet Date: Wed Dec 25 17:11:49 2013 New Revision: 259878 URL: http://svnweb.freebsd.org/changeset/base/259878 Log: For vmcore, calculate time relative to device creation upon time_uptime. Previously it used a clock from live kernel. MFC after: 2 weeks Modified: head/lib/libdevstat/devstat.c Modified: head/lib/libdevstat/devstat.c ============================================================================== --- head/lib/libdevstat/devstat.c Wed Dec 25 16:58:42 2013 (r259877) +++ head/lib/libdevstat/devstat.c Wed Dec 25 17:11:49 2013 (r259878) @@ -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 statin 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 statin } } 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