Module Name:    src
Committed By:   riastradh
Date:           Sun Feb 13 19:20:33 UTC 2022

Modified Files:
        src/sys/kern: subr_thmap.c

Log Message:
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.


To generate a diff of this commit:
cvs rdiff -u -r1.9 -r1.10 src/sys/kern/subr_thmap.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/kern/subr_thmap.c
diff -u src/sys/kern/subr_thmap.c:1.9 src/sys/kern/subr_thmap.c:1.10
--- src/sys/kern/subr_thmap.c:1.9	Tue Feb  8 12:59:16 2022
+++ src/sys/kern/subr_thmap.c	Sun Feb 13 19:20:33 2022
@@ -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 @@ THMAP_RCSID("$NetBSD: subr_thmap.c,v 1.9
  */
 #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 @@ thmap_create(uintptr_t baseptr, const th
 			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 @@ thmap_setroot(thmap_t *thmap, uintptr_t 
 		return -1;
 	}
 	thmap->root = THMAP_GETPTR(thmap, root_off);
-	atomic_thread_fence(memory_order_release); /* XXX */
 	return 0;
 }
 

Reply via email to