Module Name: src
Committed By: riastradh
Date: Fri Mar 18 23:37:14 UTC 2022
Modified Files:
src/sys/kern: kern_clock.c
Log Message:
clockrnd(9): Use atomic_load_relaxed for struct clockrnd::needed.
This may be set concurrently by clockrnd_get, so let's match the
atomic_store_relaxed and avoid the appearance of data races.
To generate a diff of this commit:
cvs rdiff -u -r1.146 -r1.147 src/sys/kern/kern_clock.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/kern/kern_clock.c
diff -u src/sys/kern/kern_clock.c:1.146 src/sys/kern/kern_clock.c:1.147
--- src/sys/kern/kern_clock.c:1.146 Sat Aug 14 21:17:11 2021
+++ src/sys/kern/kern_clock.c Fri Mar 18 23:37:14 2022
@@ -1,4 +1,4 @@
-/* $NetBSD: kern_clock.c,v 1.146 2021/08/14 21:17:11 ryo Exp $ */
+/* $NetBSD: kern_clock.c,v 1.147 2022/03/18 23:37:14 riastradh Exp $ */
/*-
* Copyright (c) 2000, 2004, 2006, 2007, 2008 The NetBSD Foundation, Inc.
@@ -69,7 +69,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: kern_clock.c,v 1.146 2021/08/14 21:17:11 ryo Exp $");
+__KERNEL_RCSID(0, "$NetBSD: kern_clock.c,v 1.147 2022/03/18 23:37:14 riastradh Exp $");
#ifdef _KERNEL_OPT
#include "opt_dtrace.h"
@@ -163,7 +163,7 @@ clockrnd_sample(struct clockrnd *C)
struct cpu_info *ci = curcpu();
/* If there's nothing needed right now, stop here. */
- if (__predict_true(C->needed == 0))
+ if (__predict_true(atomic_load_relaxed(&C->needed) == 0))
return;
/*