Print this page
Add boot_hrtime to global and zone kstats.

@@ -22,10 +22,11 @@
 /*        All Rights Reserved   */
 
 /*
  * Copyright (c) 1988, 2010, Oracle and/or its affiliates. All rights reserved.
  * Copyright (c) 2013, Joyent, Inc.  All rights reserved.
+ * Copyright 2016 Garrett D'Amore
  */
 
 #include <sys/param.h>
 #include <sys/t_lock.h>
 #include <sys/types.h>

@@ -312,10 +313,11 @@
 static int fsflushcnt;  /* counter for t_fsflushr */
 int     dosynctodr = 1; /* patchable; enable/disable sync to TOD chip */
 int     tod_needsync = 0;       /* need to sync tod chip with software time */
 static int tod_broken = 0;      /* clock chip doesn't work */
 time_t  boot_time = 0;          /* Boot time in seconds since 1970 */
+hrtime_t boot_hrtime = 0;       /* gethrtime() at boot */
 cyclic_id_t clock_cyclic;       /* clock()'s cyclic_id */
 cyclic_id_t deadman_cyclic;     /* deadman()'s cyclic_id */
 
 extern void     clock_tick_schedule(int);
 

@@ -1901,10 +1903,13 @@
 
         if (!boot_time) {
                 boot_time = ts.tv_sec;
                 set_clock = 1;
         }
+        if (!boot_hrtime) {
+                boot_hrtime = gethrtime();
+        }
 
         if (set_clock)
                 set_hrestime(&ts);
 
         mutex_exit(&tod_lock);