From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753516AbbLKIlp (ORCPT ); Fri, 11 Dec 2015 03:41:45 -0500 Received: from bombadil.infradead.org ([198.137.202.9]:48880 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751887AbbLKIln (ORCPT ); Fri, 11 Dec 2015 03:41:43 -0500 Date: Fri, 11 Dec 2015 09:41:33 +0100 From: Peter Zijlstra To: Andrew Pinski Cc: Will Deacon , Davidlohr Bueso , Thomas Gleixner , "Paul E. McKenney" , Ingo Molnar , Linux Kernel Mailing List , "linux-arm-kernel@lists.infradead.org" Subject: Re: FW: Commit 81a43adae3b9 (locking/mutex: Use acquire/release semantics) causing failures on arm64 (ThunderX) Message-ID: <20151211084133.GE6356@twins.programming.kicks-ass.net> References: <5669D5F2.5050004@caviumnetworks.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.21 (2012-12-30) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Dec 10, 2015 at 08:51:34PM -0800, Andrew Pinski wrote: > So looking further I think I understand what is going wrong and why > c55a6ffa6285e29f874ed403979472631ec70bff is incorrect. The osq_wait_next() call in osq_lock() is when we fail the lock. This is effectively trylock() semantics and like for cmpxchg a failed trylock has no implied barrier semantics. So from that POV osq_wait_next() does not need to provide ACQUIRE semantics. In osq_unlock() there's an xchg() in front, which implies full barriers and thereby provides RELEASE semantics for that part of osq_unlock(), so again, from this POV osq_wait_next() does not need to provide RELEASE semantics. > The compare and swap inside osq_lock needs to be both release and > acquire semantics memory barriers because the stores (to node) need to > be visible to the other cores before the setting of lock->tail > happens. I'm a wee bit confused on what exactly you mean. Both stores to @node: 1) osq_wait_next(): next = xchg(&node->next, NULL) 2) osq_unlock(): next = xchg(&node->next, NULL) are xchg() calls which imply full ordering (sequential consistency). Similarly the store before osq_wait_next() in osq_lock(), namely: cmpxchg(&prev->node, node, NULL) is fully ordered. So I cannot see any store being delayed past the atomic_cmpxchg_acquire(). Now you mention 'compare and swap inside osq_lock' which I take to be the latter; and it _is_ fully ordered.