diff --git a/share/man/man9/time.9 b/share/man/man9/time.9 index 4a2b2f7240e1..443608dd3f5b 100644 --- a/share/man/man9/time.9 +++ b/share/man/man9/time.9 @@ -31,7 +31,7 @@ .\" .\" $FreeBSD$ .\" -.Dd September 17, 2004 +.Dd May 4, 2021 .Dt TIME 9 .Os .Sh NAME @@ -48,7 +48,18 @@ .Sh DESCRIPTION The .Va boottime -variable holds the system boot time. +variable holds the estimated system boot time. +This time is initially set when the system boots, either from the RTC, or from a +time estimated from the system's root filesystem. +When the current system time is set, stepped by +.Xr ntpd 8 , +or a new time is read from the RTC as the system resumes, +.Va boottime +is recomputed as new_time - uptime. +The +.Xr sysctl 8 +.Va kern.boottime +returns this value. .Pp The .Va time_second @@ -83,6 +94,7 @@ and in an atomic manner. The .Va boottime variable may be read and written without special precautions. +It is adjusted when the phase of the system time changes. .Sh SEE ALSO .Xr clock_settime 2 , .Xr ntp_adjtime 2 , diff --git a/sys/kern/kern_tc.c b/sys/kern/kern_tc.c index b1dcb18e31be..4d4e20ef1934 100644 --- a/sys/kern/kern_tc.c +++ b/sys/kern/kern_tc.c @@ -103,11 +103,17 @@ int tc_min_ticktock_freq = 1; volatile time_t time_second = 1; volatile time_t time_uptime = 1; +/* + * The system time is always computed by summing the estimated boot time and the + * system uptime. The timehands track boot time, but it changes when the system + * time is set by the user, stepped by ntpd or adjusted when resuming. It + * is set to new_time - uptime. + */ static int sysctl_kern_boottime(SYSCTL_HANDLER_ARGS); SYSCTL_PROC(_kern, KERN_BOOTTIME, boottime, CTLTYPE_STRUCT | CTLFLAG_RD | CTLFLAG_MPSAFE, NULL, 0, sysctl_kern_boottime, "S,timeval", - "System boottime"); + "Estimated system boottime"); SYSCTL_NODE(_kern, OID_AUTO, timecounter, CTLFLAG_RW | CTLFLAG_MPSAFE, 0, "");