Module Name: src Committed By: riastradh Date: Sun Apr 7 22:59:13 UTC 2024
Modified Files: src/sys/arch/riscv/riscv: clock_machdep.c Log Message: riscv: Schedule next hardclock tick in the future, not the past. If we have missed hardclock ticks, schedule up to one tick interval in the future anyway; don't try to play hardclock catchup by scheduling for when the next hardclock tick _should_ have been, in the past, leading to ticking as fast as possible until we've caught up. as fast as possible until we've caught up. Playing hardclock catchup triggers heartbeat panics when continuing from ddb, if you've been in ddb for >15sec. Other hardclock drivers like x86 lapic don't play hardclock catchup either. PR kern/57920 To generate a diff of this commit: cvs rdiff -u -r1.7 -r1.8 src/sys/arch/riscv/riscv/clock_machdep.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/sys/arch/riscv/riscv/clock_machdep.c diff -u src/sys/arch/riscv/riscv/clock_machdep.c:1.7 src/sys/arch/riscv/riscv/clock_machdep.c:1.8 --- src/sys/arch/riscv/riscv/clock_machdep.c:1.7 Thu Jan 18 07:41:50 2024 +++ src/sys/arch/riscv/riscv/clock_machdep.c Sun Apr 7 22:59:13 2024 @@ -1,4 +1,4 @@ -/* $NetBSD: clock_machdep.c,v 1.7 2024/01/18 07:41:50 skrll Exp $ */ +/* $NetBSD: clock_machdep.c,v 1.8 2024/04/07 22:59:13 riastradh Exp $ */ /*- * Copyright (c) 2014 The NetBSD Foundation, Inc. @@ -31,7 +31,7 @@ #include <sys/cdefs.h> -__RCSID("$NetBSD: clock_machdep.c,v 1.7 2024/01/18 07:41:50 skrll Exp $"); +__RCSID("$NetBSD: clock_machdep.c,v 1.8 2024/04/07 22:59:13 riastradh Exp $"); #include <sys/param.h> #include <sys/cpu.h> @@ -124,6 +124,10 @@ riscv_timer_intr(void *arg) ci->ci_ev_timer.ev_count++; ci->ci_lastintr_scheduled += timer_ticks_per_hz; + while (__predict_false(ci->ci_lastintr_scheduled < now)) { + ci->ci_lastintr_scheduled += timer_ticks_per_hz; + /* XXX count missed timer interrupts */ + } sbi_set_timer(ci->ci_lastintr_scheduled); hardclock(cf);