From ce81117b77a368029b0dbf6f4fdb5b1037e4a2cb Mon Sep 17 00:00:00 2001 From: visa Date: Thu, 4 Mar 2021 15:38:06 +0000 Subject: [PATCH] Update clock interrupt count atomically. This avoids errors that can arise when multiple cores update the variable at the same time. --- sys/arch/mips64/mips64/clock.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/sys/arch/mips64/mips64/clock.c b/sys/arch/mips64/mips64/clock.c index 5fbc090ba28..bd2e01c2d61 100644 --- a/sys/arch/mips64/mips64/clock.c +++ b/sys/arch/mips64/mips64/clock.c @@ -1,4 +1,4 @@ -/* $OpenBSD: clock.c,v 1.42 2020/06/30 14:56:10 visa Exp $ */ +/* $OpenBSD: clock.c,v 1.43 2021/03/04 15:38:06 visa Exp $ */ /* * Copyright (c) 2001-2004 Opsycon AB (www.opsycon.se / www.opsycon.com) @@ -37,6 +37,7 @@ #include #include #include +#include #include #include @@ -149,7 +150,8 @@ cp0_int5(uint32_t mask, struct trapframe *tf) ENABLEIPI(); #endif while (ci->ci_pendingticks) { - cp0_clock_count.ec_count++; + atomic_inc_long( + (unsigned long *)&cp0_clock_count.ec_count); hardclock(tf); ci->ci_pendingticks--; } -- 2.20.1