Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/kern clockrnd(9): Use atomic_load_relaxed for struct clo...



details:   https://anonhg.NetBSD.org/src/rev/8f75b2ac327a
branches:  trunk
changeset: 363963:8f75b2ac327a
user:      riastradh <riastradh%NetBSD.org@localhost>
date:      Fri Mar 18 23:37:14 2022 +0000

description:
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.

diffstat:

 sys/kern/kern_clock.c |  6 +++---
 1 files changed, 3 insertions(+), 3 deletions(-)

diffs (27 lines):

diff -r a1775ec2ed96 -r 8f75b2ac327a sys/kern/kern_clock.c
--- a/sys/kern/kern_clock.c     Fri Mar 18 23:37:06 2022 +0000
+++ b/sys/kern/kern_clock.c     Fri Mar 18 23:37:14 2022 +0000
@@ -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 @@
        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;
 
        /*



Home | Main Index | Thread Index | Old Index