summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVisa Hankala <visa@cvs.openbsd.org>2021-03-04 15:38:07 +0000
committerVisa Hankala <visa@cvs.openbsd.org>2021-03-04 15:38:07 +0000
commit8c3d2e6947f37024afe49ddd4b671287f6ef41f6 (patch)
treef466eb2b945e8a8093d4a256c93a113acb7340ca
parente00a14477c77f626c40b099a81d4c527df158400 (diff)
Update clock interrupt count atomically.
This avoids errors that can arise when multiple cores update the variable at the same time.
-rw-r--r--sys/arch/mips64/mips64/clock.c6
1 files 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 <sys/param.h>
#include <sys/kernel.h>
#include <sys/systm.h>
+#include <sys/atomic.h>
#include <sys/device.h>
#include <sys/evcount.h>
@@ -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--;
}