From cabc89bed5cb0c59a140dd68127c40c4a4605021 Mon Sep 17 00:00:00 2001 From: cheloha Date: Tue, 20 Oct 2020 15:59:18 +0000 Subject: alpha, loongson, sh, sparc64: recompute tick, tick_nsec when hz(9) is reset Normally we set hz(9) at compile-time in sys/conf/param.c to the value of HZ. HZ is one of the fundamental compilation options(4). However, sometimes we need to reset hz(9) at runtime. Whenever we reset hz(9) we need to recompute tick and tick_nsec. Otherwise a variety of "time stuff" in the kernel will not work correctly. For example, most timeouts will expire "too slow" or "too fast". There are a bunch of other places we use tick and tick_nsec that will exhibit similar problems. Test-compiled by deraadt@. --- sys/arch/sh/sh/clock.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'sys/arch/sh') diff --git a/sys/arch/sh/sh/clock.c b/sys/arch/sh/sh/clock.c index 00a66e35d5d..f403f15c7a1 100644 --- a/sys/arch/sh/sh/clock.c +++ b/sys/arch/sh/sh/clock.c @@ -1,4 +1,4 @@ -/* $OpenBSD: clock.c,v 1.10 2020/05/11 13:27:38 kettenis Exp $ */ +/* $OpenBSD: clock.c,v 1.11 2020/10/20 15:59:17 cheloha Exp $ */ /* $NetBSD: clock.c,v 1.32 2006/09/05 11:09:36 uwe Exp $ */ /*- @@ -259,6 +259,7 @@ cpu_initclocks(void) /* Set global variables. */ hz = HZ; tick = 1000000 / hz; + tick_nsec = 1000000000 / hz; /* * Use TMU channel 0 as hard clock -- cgit v1.2.3