From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S965428AbbJ0Tyx (ORCPT ); Tue, 27 Oct 2015 15:54:53 -0400 Received: from smtp2.provo.novell.com ([137.65.250.81]:36591 "EHLO smtp2.provo.novell.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S965300AbbJ0Tyl (ORCPT ); Tue, 27 Oct 2015 15:54:41 -0400 From: Davidlohr Bueso To: Ingo Molnar , Peter Zijlstra Cc: Thomas Gleixner , Linus Torvalds , "Paul E. McKenney" , dave@stgolabs.net, linux-kernel@vger.kernel.org, x86@kernel.org, Davidlohr Bueso Subject: [PATCH 3/4] x86,asm: Re-work smp_store_mb() Date: Tue, 27 Oct 2015 12:53:50 -0700 Message-Id: <1445975631-17047-4-git-send-email-dave@stgolabs.net> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1445975631-17047-1-git-send-email-dave@stgolabs.net> References: <1445975631-17047-1-git-send-email-dave@stgolabs.net> Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org With the exception of the recent rename of set_mb to smp_store_mb, thus explicitly enforcing SMP ordering, the code is quite stale - going back to 2002, afaict. Specifically, replace the implicit barriers of xchg for more standard smp_mb() call instead. Thus, (i) We need not re-define it for SMP and UP systems. The later already converts the smp_mb() to a compiler barrier. (ii) Like most other archs, avoid using ugly/hacky (void)xchg patterns and simply add the smp_mb() call explicitly after the assignment. Note that this might affect callers that could/would rely on the atomicity semantics, but there are no guarantees of that for smp_store_mb() mentioned anywhere, plus most archs use this anyway. Thus we continue to be consistent with the memory-barriers.txt file, and more importantly, maintain the semantics of the smp_ nature. Cc: x86@kernel.org Signed-off-by: Davidlohr Bueso --- arch/x86/include/asm/barrier.h | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/arch/x86/include/asm/barrier.h b/arch/x86/include/asm/barrier.h index 0681d25..09f817a 100644 --- a/arch/x86/include/asm/barrier.h +++ b/arch/x86/include/asm/barrier.h @@ -35,14 +35,18 @@ #define smp_mb() mb() #define smp_rmb() dma_rmb() #define smp_wmb() barrier() -#define smp_store_mb(var, value) do { (void)xchg(&var, value); } while (0) #else /* !SMP */ #define smp_mb() barrier() #define smp_rmb() barrier() #define smp_wmb() barrier() -#define smp_store_mb(var, value) do { WRITE_ONCE(var, value); barrier(); } while (0) #endif /* SMP */ +#define smp_store_mb(var, val) \ +do { \ + WRITE_ONCE(var, val); \ + smp_mb(); \ +} while (0) + #define read_barrier_depends() do { } while (0) #define smp_read_barrier_depends() do { } while (0) -- 2.1.4