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 add relaxed atomics, ok ad@ riastradh@



details:   https://anonhg.NetBSD.org/src/rev/f468fb4b23c4
branches:  trunk
changeset: 745095:f468fb4b23c4
user:      maxv <maxv%NetBSD.org@localhost>
date:      Sat Feb 22 20:12:40 2020 +0000

description:
add relaxed atomics, ok ad@ riastradh@

diffstat:

 sys/arch/x86/x86/x86_tlb.c |  14 +++++++-------
 1 files changed, 7 insertions(+), 7 deletions(-)

diffs (63 lines):

diff -r a179c0555e3b -r f468fb4b23c4 sys/arch/x86/x86/x86_tlb.c
--- a/sys/arch/x86/x86/x86_tlb.c        Sat Feb 22 20:08:39 2020 +0000
+++ b/sys/arch/x86/x86/x86_tlb.c        Sat Feb 22 20:12:40 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: x86_tlb.c,v 1.15 2020/01/15 13:22:03 ad Exp $  */
+/*     $NetBSD: x86_tlb.c,v 1.16 2020/02/22 20:12:40 maxv Exp $        */
 
 /*-
  * Copyright (c) 2008-2020 The NetBSD Foundation, Inc.
@@ -40,7 +40,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: x86_tlb.c,v 1.15 2020/01/15 13:22:03 ad Exp $");
+__KERNEL_RCSID(0, "$NetBSD: x86_tlb.c,v 1.16 2020/02/22 20:12:40 maxv Exp $");
 
 #include <sys/param.h>
 #include <sys/kernel.h>
@@ -90,7 +90,7 @@
 #define        TP_GET_COUNT(tp)        ((tp)->tp_store[TP_COUNT] & PAGE_MASK)
 #define        TP_GET_USERPMAP(tp)     ((tp)->tp_store[TP_USERPMAP] & 1)
 #define        TP_GET_GLOBAL(tp)       ((tp)->tp_store[TP_GLOBAL] & 1)
-#define        TP_GET_DONE(tp)         ((tp)->tp_store[TP_DONE] & 1)
+#define        TP_GET_DONE(tp)         (atomic_load_relaxed(&(tp)->tp_store[TP_DONE]) & 1)
 #define        TP_GET_VA(tp, i)        ((tp)->tp_store[(i)] & ~PAGE_MASK)
 
 #define        TP_INC_COUNT(tp)        ((tp)->tp_store[TP_COUNT]++)
@@ -99,7 +99,7 @@
 
 #define        TP_SET_USERPMAP(tp)     ((tp)->tp_store[TP_USERPMAP] |= 1)
 #define        TP_SET_GLOBAL(tp)       ((tp)->tp_store[TP_GLOBAL] |= 1)
-#define        TP_SET_DONE(tp)         ((tp)->tp_store[TP_DONE] |= 1)
+#define        TP_SET_DONE(tp)         atomic_store_relaxed(&(tp)->tp_store[TP_DONE], 1)
 
 #define        TP_CLEAR(tp)            memset(__UNVOLATILE(tp), 0, sizeof(*(tp)));
 
@@ -409,7 +409,7 @@
        KASSERT(TP_GET_DONE(ts) == 0);
        while (atomic_cas_ptr(&pmap_tlb_packet, NULL,
            __UNVOLATILE(ts)) != NULL) {
-               KASSERT(pmap_tlb_packet != ts);
+               KASSERT(atomic_load_relaxed(&pmap_tlb_packet) != ts);
                /*
                 * Don't bother with exponentional backoff, as the pointer
                 * is in a dedicated cache line and only updated twice per
@@ -419,7 +419,7 @@
                splx(s);
                do {
                        x86_pause();
-               } while (pmap_tlb_packet != NULL);
+               } while (atomic_load_relaxed(&pmap_tlb_packet) != NULL);
                s = splvm();
 
                /*
@@ -509,7 +509,7 @@
         * seemingly active.
         */
        if (atomic_dec_uint_nv(&pmap_tlb_pendcount) == 0) {
-               pmap_tlb_packet = NULL;
+               atomic_store_relaxed(&pmap_tlb_packet, NULL);
                __insn_barrier();
                TP_SET_DONE(source);
        }



Home | Main Index | Thread Index | Old Index