From b35b1908924506f197fb3f62a93d1bc268aae5e9 Mon Sep 17 00:00:00 2001 From: Taylor R Campbell Date: Sat, 9 Apr 2022 18:09:07 +0000 Subject: [PATCH] x86: Use atomic_store_release/atomic_load_consume for nmi_handlers. Simplifies things a bit. No functional change intended. --- sys/arch/x86/x86/nmi.c | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/sys/arch/x86/x86/nmi.c b/sys/arch/x86/x86/nmi.c index 74d79ddaf9b2..f0a2ab375b64 100644 --- a/sys/arch/x86/x86/nmi.c +++ b/sys/arch/x86/x86/nmi.c @@ -82,8 +82,7 @@ nmi_establish(int (*func)(const struct trapframe *, void *), void *arg) 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 @@ nmi_disestablish(nmi_handler_t *handle) 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,11 +153,8 @@ nmi_dispatch(const struct trapframe *tf) * 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 = n->n_next) handled |= (*n->n_func)(tf, n->n_arg); - } return handled; }