Index: share/man/man9/time.9 =================================================================== --- share/man/man9/time.9 +++ share/man/man9/time.9 @@ -31,7 +31,7 @@ .\" .\" $FreeBSD$ .\" -.Dd September 17, 2004 +.Dd May 4, 2021 .Dt TIME 9 .Os .Sh NAME @@ -49,6 +49,15 @@ The .Va boottime variable holds the system boot time. +This time is set initially when the system boots. +When the current time is set, adjusted by ntpd, or when a new time is read when +the system resumes, +.Va boottime +is adjusted so that boottime + uptime reflects the new current time. +The +.Xr sysctl 8 +.Va kern.boottime +returns this value. .Pp The .Va time_second @@ -83,6 +92,7 @@ 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 , Index: sys/kern/kern_tc.c =================================================================== --- sys/kern/kern_tc.c +++ sys/kern/kern_tc.c @@ -103,11 +103,18 @@ volatile time_t time_second = 1; volatile time_t time_uptime = 1; +/* + * The system keeps track of it's current time by adding the system uptime to + * the boot time. The timehands track this boot time so that time is consistent + * acround changes to time via clock_settime, settimeofday, and smaller steps + * from ntpd. It's also reset after a suspended system resumes. Boottime vaires + * over the life of the system as these events unfold. + */ 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"); + "System boottime."); SYSCTL_NODE(_kern, OID_AUTO, timecounter, CTLFLAG_RW | CTLFLAG_MPSAFE, 0, "");