From 8bbe91a80ec97163dfbb1128a4f7ebd743c20c4e Mon Sep 17 00:00:00 2001 From: visa Date: Tue, 4 Apr 2017 12:30:04 +0000 Subject: [PATCH] Issue memory barrier before lock release, not after. This ensures the release write becomes globally visible only after any writes of the critical section are globally visible. In practice, the reordering has not happened because the kernel runs in the total store order mode. Tested by and OK kettenis@ --- sys/arch/sparc64/sparc64/lock_machdep.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/sys/arch/sparc64/sparc64/lock_machdep.c b/sys/arch/sparc64/sparc64/lock_machdep.c index 58470886e59..0cb1d16b66e 100644 --- a/sys/arch/sparc64/sparc64/lock_machdep.c +++ b/sys/arch/sparc64/sparc64/lock_machdep.c @@ -1,4 +1,4 @@ -/* $OpenBSD: lock_machdep.c,v 1.12 2017/03/07 14:41:57 visa Exp $ */ +/* $OpenBSD: lock_machdep.c,v 1.13 2017/04/04 12:30:04 visa Exp $ */ /* * Copyright (c) 2007 Artur Grabowski @@ -130,8 +130,8 @@ __mp_unlock(struct __mp_lock *mpl) s = intr_disable(); if (--cpu->mplc_depth == 0) { - mpl->mpl_ticket++; sparc_membar(StoreStore | LoadStore); + mpl->mpl_ticket++; } intr_restore(s); } @@ -146,8 +146,8 @@ __mp_release_all(struct __mp_lock *mpl) s = intr_disable(); rv = cpu->mplc_depth; cpu->mplc_depth = 0; - mpl->mpl_ticket++; sparc_membar(StoreStore | LoadStore); + mpl->mpl_ticket++; intr_restore(s); return (rv); -- 2.20.1