From: cheloha Date: Fri, 23 Feb 2024 23:01:15 +0000 (+0000) Subject: timecounting: start system uptime at 0.0 instead of 1.0 X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=127fa8d558c395962f8628e05466a7388994841b;p=openbsd timecounting: start system uptime at 0.0 instead of 1.0 OpenBSD starts the system uptime clock at 1.0 instead of 0.0. We inherited this behavior from FreeBSD when we imported kern_tc.c. patrick@ reports that this causes a problem in sdmmc(4) during boot: the sdmmc_delay() call in sdmmc_init() doesn't block for the full 250ms. This happens because the system hardclock() starts at 0.0 and executes about hz times, rapidly, to "catch up" to 1.0. This instantly expires the first hz timeout ticks, hence the short sleep. Starting the system uptime at 0.0 fixes the problem. Prompted by patrick@. Tested by patrick@. In snaps since Feb 19 2023. Thread: https://marc.info/?l=openbsd-tech&m=170830229732396&w=2 ok patrick@ deraadt@ --- diff --git a/sys/kern/kern_tc.c b/sys/kern/kern_tc.c index 30022930a19..5f52886046f 100644 --- a/sys/kern/kern_tc.c +++ b/sys/kern/kern_tc.c @@ -1,4 +1,4 @@ -/* $OpenBSD: kern_tc.c,v 1.82 2023/02/04 19:19:36 cheloha Exp $ */ +/* $OpenBSD: kern_tc.c,v 1.83 2024/02/23 23:01:15 cheloha Exp $ */ /* * Copyright (c) 2000 Poul-Henning Kamp @@ -96,7 +96,7 @@ static struct timehands th1 = { static struct timehands th0 = { .th_counter = &dummy_timecounter, .th_scale = UINT64_MAX / 1000000, - .th_offset = { .sec = 1, .frac = 0 }, + .th_offset = { .sec = 0, .frac = 0 }, .th_generation = 1, .th_next = &th1 }; @@ -117,7 +117,7 @@ static SLIST_HEAD(, timecounter) tc_list = SLIST_HEAD_INITIALIZER(tc_list); * examining kernel core dumps. */ volatile time_t naptime = 0; -volatile time_t time_second = 1; +volatile time_t time_second = 0; volatile time_t time_uptime = 0; static int timestepwarnings;