Project

General

Profile

Feature #12663

expose boot hrtime for uptime interval calculations

Added by Joshua M. Clulow 3 months ago. Updated 3 months ago.

Status:
New
Priority:
Normal
Assignee:
-
Category:
kernel
Start date:
Due date:
% Done:

0%

Estimated time:
Difficulty:
Medium
Tags:
Gerrit CR:

Description

We currently expose a kstat, unix:0:system_misc:boot_time, which is expressed as the UNIX time in seconds at which the OS booted. This value could be misleading for a number of reasons that affect measurements of wall time: inaccurate or incorrectly set system RTC, NTP adjustments, clock drift, etc.

We provide gethrtime(3C) for user processes to read the current high-resolution time. This time value is not subject to adjustments or drift that the real time clock experiences, but it is also only meaningful when compared with another hrtime reading: that is, it is useful for calculating an interval, but the absolute value of the reading is generally meaningless.

In order to calculate the interval of "time since boot", we should expose as a kstat the hrtime value when the system booted. This would enable a process to calculate the system uptime as an interval between this kstat and a current hrtime reading.

NOTE: Suspend and resume may affect the progression of gethrtime() readings; e.g., hrtime may not advance while the system is asleep. As such this value will need to be used with that knowledge in mind, and is probably not generally suitable for tools like uptime and w.

History

#1

Updated by Joshua M. Clulow 3 months ago

  • Description updated (diff)
#2

Updated by Joshua M. Clulow 3 months ago

  • Subject changed from expose boot time as a hrtime value for uptime interval calculations to expose boot hrtime for uptime interval calculations

Also available in: Atom PDF