--- - branch: MAIN date: Sat Apr 9 23:32:53 UTC 2022 files: - new: '1.4' old: '1.3' path: src/common/lib/libc/arch/aarch64/atomic/membar_ops.S pathrev: src/common/lib/libc/arch/aarch64/atomic/membar_ops.S@1.4 type: modified - new: '1.9' old: '1.8' path: src/common/lib/libc/arch/alpha/atomic/membar_ops.S pathrev: src/common/lib/libc/arch/alpha/atomic/membar_ops.S@1.9 type: modified - new: '1.10' old: '1.9' path: src/common/lib/libc/arch/arm/atomic/membar_ops.S pathrev: src/common/lib/libc/arch/arm/atomic/membar_ops.S@1.10 type: modified - new: '1.3' old: '1.2' path: src/common/lib/libc/arch/hppa/atomic/membar_ops.S pathrev: src/common/lib/libc/arch/hppa/atomic/membar_ops.S@1.3 type: modified - new: '1.35' old: '1.34' path: src/common/lib/libc/arch/i386/atomic/atomic.S pathrev: src/common/lib/libc/arch/i386/atomic/atomic.S@1.35 type: modified - new: '1.7' old: '1.6' path: src/common/lib/libc/arch/ia64/atomic/atomic.S pathrev: src/common/lib/libc/arch/ia64/atomic/atomic.S@1.7 type: modified - new: '1.12' old: '1.11' path: src/common/lib/libc/arch/mips/atomic/membar_ops.S pathrev: src/common/lib/libc/arch/mips/atomic/membar_ops.S@1.12 type: modified - new: '1.2' old: '1.1' path: src/common/lib/libc/arch/or1k/atomic/membar_ops.S pathrev: src/common/lib/libc/arch/or1k/atomic/membar_ops.S@1.2 type: modified - new: '1.6' old: '1.5' path: src/common/lib/libc/arch/powerpc/atomic/membar_ops.S pathrev: src/common/lib/libc/arch/powerpc/atomic/membar_ops.S@1.6 type: modified - new: '1.4' old: '1.3' path: src/common/lib/libc/arch/riscv/atomic/membar_ops.S pathrev: src/common/lib/libc/arch/riscv/atomic/membar_ops.S@1.4 type: modified - new: '1.8' old: '1.7' path: src/common/lib/libc/arch/sparc/atomic/membar_ops.S pathrev: src/common/lib/libc/arch/sparc/atomic/membar_ops.S@1.8 type: modified - new: '1.9' old: '1.8' path: src/common/lib/libc/arch/sparc64/atomic/membar_ops.S pathrev: src/common/lib/libc/arch/sparc64/atomic/membar_ops.S@1.9 type: modified - new: '1.28' old: '1.27' path: src/common/lib/libc/arch/x86_64/atomic/atomic.S pathrev: src/common/lib/libc/arch/x86_64/atomic/atomic.S@1.28 type: modified - new: '1.8' old: '1.7' path: src/common/lib/libc/atomic/membar_ops_nop.c pathrev: src/common/lib/libc/atomic/membar_ops_nop.c@1.8 type: modified - new: '1.2413' old: '1.2412' path: src/distrib/sets/lists/comp/mi pathrev: src/distrib/sets/lists/comp/mi@1.2413 type: modified - new: '1.5' old: '1.4' path: src/lib/libc/atomic/Makefile.inc pathrev: src/lib/libc/atomic/Makefile.inc@1.5 type: modified - new: '1.10' old: '1.9' path: src/lib/libc/atomic/membar_ops.3 pathrev: src/lib/libc/atomic/membar_ops.3@1.10 type: modified - new: '1.7' old: '1.6' path: src/share/man/man9/atomic_loadstore.9 pathrev: src/share/man/man9/atomic_loadstore.9@1.7 type: modified - new: '1.23' old: '1.22' path: src/sys/sys/atomic.h pathrev: src/sys/sys/atomic.h@1.23 type: modified - new: '1.2' old: '1.1' path: src/tests/lib/libc/membar/t_dekker.c pathrev: src/tests/lib/libc/membar/t_dekker.c@1.2 type: modified - new: '1.2' old: '1.1' path: src/tests/lib/libc/membar/t_spinlock.c pathrev: src/tests/lib/libc/membar/t_spinlock.c@1.2 type: modified id: 20220409T233253Z.ba7e3a9b3ff1bdabe0a0fab6cd8a1008c6103e26 log: "Introduce membar_acquire/release. Deprecate membar_enter/exit.\n\nThe names membar_enter/exit were unclear, and the documentation of\nmembar_enter has disagreed with the implementations on sparc,\npowerpc, and even x86(!) for the entire time it has been in NetBSD.\n\nThe terms `acquire' and `release' are ubiquitous in the literature\ntoday, and have been adopted in the C and C++ standards to mean\nload-before-load/store and load/store-before-store, respectively,\nwhich are exactly the orderings required by acquiring and releasing a\nmutex, as well as other useful applications like decrementing a\nreference count and then freeing the underlying object if it went to\nzero.\n\nOriginally I proposed changing one word in the documentation for\nmembar_enter to make it load-before-load/store instead of\nstore-before-load/store, i.e., to make it an acquire barrier. I\nproposed this on the grounds that\n\n(a) all implementations guarantee load-before-load/store,\n(b) some implementations fail to guarantee store-before-load/store,\nand\n(c) all uses in-tree assume load-before-load/store.\n\nI verified parts (a) and (b) (except, for (a), powerpc didn't even\nguarantee load-before-load/store -- isync isn't necessarily enough;\nneed lwsync in general -- but it _almost_ did, and it certainly didn't\nguarantee store-before-load/store).\n\nPart (c) might not be correct, however: under the mistaken assumption\nthat atomic-r/m/w then membar-w/rw is equivalent to atomic-r/m/w then\nmembar-r/rw, I only audited the cases of membar_enter that _aren't_\nimmediately after an atomic-r/m/w. All of those cases assume\nload-before-load/store. But my assumption was wrong -- there are\ncases of atomic-r/m/w then membar-w/rw that would be broken by\nchanging to atomic-r/m/w then membar-r/rw:\n\nhttps://mail-index.netbsd.org/tech-kern/2022/03/29/msg028044.html\n\nFurthermore, the name membar_enter has been adopted in other places\nlike OpenBSD where it actually does follow the documentation and\nguarantee store-before-load/store, even if that order is not useful.\nSo the name membar_enter currently lives in a bad place where it\nmeans either of two things -- r/rw or w/rw.\n\nWith this change, we deprecate membar_enter/exit, introduce\nmembar_acquire/release as better names for the useful pair (r/rw and\nrw/w), and make sure the implementation of membar_enter guarantees\nboth what was documented _and_ what was implemented, making it an\nalias for membar_sync.\n\nWhile here, rework all of the membar_* definitions and aliases. The\nnew logic follows a rule to make it easier to audit:\n\n\tmembar_X is defined as an alias for membar_Y iff membar_X is\n\tguaranteed by membar_Y.\n\nThe `no stronger than' relation is (the transitive closure of):\n\n- membar_consumer (r/r) is guaranteed by membar_acquire (r/rw)\n- membar_producer (w/w) is guaranteed by membar_release (rw/w)\n- membar_acquire (r/rw) is guaranteed by membar_sync (rw/rw)\n- membar_release (rw/w) is guaranteed by membar_sync (rw/rw)\n\nAnd, for the deprecated membars:\n\n- membar_enter (whether r/rw, w/rw, or rw/rw) is guaranteed by\n membar_sync (rw/rw)\n- membar_exit (rw/w) is guaranteed by membar_release (rw/w)\n\n(membar_exit is identical to membar_release, but the name is\ndeprecated.)\n\nFinally, while here, annotate some of the instructions with their\nsemantics. For powerpc, leave an essay with citations on the\nunfortunate but -- as far as I can tell -- necessary decision to use\nlwsync, not isync, for membar_acquire and membar_consumer.\n\nAlso add membar(3) and atomic(3) man page links.\n" module: src subject: 'CVS commit: src' unixtime: '1649547173' user: riastradh