Source-Changes-HG archive

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

[src/trunk]: src/sys/kern thmap(9): Omit needless fences and use membar_exit ...



details:   https://anonhg.NetBSD.org/src/rev/83b01289106a
branches:  trunk
changeset: 361554:83b01289106a
user:      riastradh <riastradh%NetBSD.org@localhost>
date:      Sun Feb 13 19:20:33 2022 +0000

description:
thmap(9): Omit needless fences and use membar_exit for release fence.

It is the caller's responsibility to arrange that thmap_create, and,
if THMAP_SETROOT is set, thmap_root, happen before any use of the
thmap.  No need for them to issue fences internally.

diffstat:

 sys/kern/subr_thmap.c |  8 +++-----
 1 files changed, 3 insertions(+), 5 deletions(-)

diffs (43 lines):

diff -r 1e330892c5c5 -r 83b01289106a sys/kern/subr_thmap.c
--- a/sys/kern/subr_thmap.c     Sun Feb 13 19:20:23 2022 +0000
+++ b/sys/kern/subr_thmap.c     Sun Feb 13 19:20:33 2022 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: subr_thmap.c,v 1.9 2022/02/08 12:59:16 riastradh Exp $ */
+/*     $NetBSD: subr_thmap.c,v 1.10 2022/02/13 19:20:33 riastradh Exp $        */
 
 /*-
  * Copyright (c) 2018 Mindaugas Rasiukevicius <rmind at noxt eu>
@@ -112,7 +112,7 @@
 #include "utils.h"
 #endif
 
-THMAP_RCSID("$NetBSD: subr_thmap.c,v 1.9 2022/02/08 12:59:16 riastradh Exp $");
+THMAP_RCSID("$NetBSD: subr_thmap.c,v 1.10 2022/02/13 19:20:33 riastradh Exp $");
 
 #include <crypto/blake2/blake2s.h>
 
@@ -121,7 +121,7 @@
  */
 #ifdef _KERNEL
 #define        ASSERT KASSERT
-#define        atomic_thread_fence(x) membar_sync()
+#define        atomic_thread_fence(x) membar_exit() /* only used for release order */
 #define        atomic_compare_exchange_weak_explicit_32(p, e, n, m1, m2) \
     (atomic_cas_32((p), *(e), (n)) == *(e))
 #define        atomic_compare_exchange_weak_explicit_ptr(p, e, n, m1, m2) \
@@ -986,7 +986,6 @@
                        return NULL;
                }
                memset(thmap->root, 0, THMAP_ROOT_LEN);
-               atomic_thread_fence(memory_order_release); /* XXX */
        }
 
        cprng_strong(kern_cprng, thmap->seed, sizeof thmap->seed, 0);
@@ -1001,7 +1000,6 @@
                return -1;
        }
        thmap->root = THMAP_GETPTR(thmap, root_off);
-       atomic_thread_fence(memory_order_release); /* XXX */
        return 0;
 }
 



Home | Main Index | Thread Index | Old Index