Source-Changes-HG archive

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

[src/trunk]: src/sys/arch/x86/x86 x86: Use atomic_store_release/atomic_load_c...



details:   https://anonhg.NetBSD.org/src/rev/12c4f61aab09
branches:  trunk
changeset: 366121:12c4f61aab09
user:      riastradh <riastradh%NetBSD.org@localhost>
date:      Sun May 15 12:45:33 2022 +0000

description:
x86: Use atomic_store_release/atomic_load_consume for nmi_handlers.

Simplifies things a bit.  No functional change intended.

diffstat:

 sys/arch/x86/x86/nmi.c |  15 +++++++--------
 1 files changed, 7 insertions(+), 8 deletions(-)

diffs (50 lines):

diff -r c61ec11a8396 -r 12c4f61aab09 sys/arch/x86/x86/nmi.c
--- a/sys/arch/x86/x86/nmi.c    Sun May 15 11:47:42 2022 +0000
+++ b/sys/arch/x86/x86/nmi.c    Sun May 15 12:45:33 2022 +0000
@@ -1,4 +1,4 @@
-/*     $Id: nmi.c,v 1.5 2017/06/01 02:45:08 chs Exp $  */
+/*     $Id: nmi.c,v 1.6 2022/05/15 12:45:33 riastradh Exp $    */
 
 /*-
  * Copyright (c)2009,2011 YAMAMOTO Takashi,
@@ -27,7 +27,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: nmi.c,v 1.5 2017/06/01 02:45:08 chs Exp $");
+__KERNEL_RCSID(0, "$NetBSD: nmi.c,v 1.6 2022/05/15 12:45:33 riastradh Exp $");
 
 /*
  * nmi dispatcher.
@@ -82,8 +82,7 @@
 
        mutex_enter(&nmi_list_lock);
        n->n_next = nmi_handlers;
-       membar_producer(); /* n->n_next should be visible before nmi_handlers */
-       nmi_handlers = n; /* atomic store */
+       atomic_store_release(&nmi_handlers, n);
        mutex_exit(&nmi_list_lock);
 
        return n;
@@ -121,7 +120,7 @@
                panic("%s: invalid handle %p", __func__, handle);
        }
 #endif /* defined(DIAGNOSTIC) */
-       *pp = n->n_next; /* atomic store */
+       atomic_store_relaxed(pp, n->n_next);
        mutex_exit(&nmi_list_lock); /* mutex_exit implies a store fence */
 
        /*
@@ -154,9 +153,9 @@
         * we are in a dangerous context. (NMI)
         */
 
-       for (n = nmi_handlers; /* atomic load */
-           n != NULL;
-           membar_consumer(), n = n->n_next) { /* atomic load */
+       for (n = atomic_load_consume(&nmi_handlers);
+            n != NULL;
+            n = atomic_load_relaxed(&n->n_next)) {
                handled |= (*n->n_func)(tf, n->n_arg);
        }
        return handled;



Home | Main Index | Thread Index | Old Index