From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753356AbdHIPPk (ORCPT ); Wed, 9 Aug 2017 11:15:40 -0400 Received: from merlin.infradead.org ([205.233.59.134]:54598 "EHLO merlin.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751995AbdHIPPj (ORCPT ); Wed, 9 Aug 2017 11:15:39 -0400 Date: Wed, 9 Aug 2017 17:15:33 +0200 From: Peter Zijlstra To: Waiman Long Cc: Ingo Molnar , linux-kernel@vger.kernel.org, Pan Xinhui , Boqun Feng , Andrea Parri , Will Deacon , Paul McKenney Subject: Re: [RESEND PATCH v5] locking/pvqspinlock: Relax cmpxchg's to improve performance on some archs Message-ID: <20170809151533.ipzeu7vmwi5ttcab@hirez.programming.kicks-ass.net> References: <1495633108-12818-1-git-send-email-longman@redhat.com> <20170809150603.6z43zkxnz3hew3jb@hirez.programming.kicks-ass.net> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20170809150603.6z43zkxnz3hew3jb@hirez.programming.kicks-ass.net> User-Agent: NeoMutt/20170609 (1.8.3) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Aug 09, 2017 at 05:06:03PM +0200, Peter Zijlstra wrote: > Now, ARM64 for instance plays funny games, it does something along the > lines of: > > cmpxchg(ptr, old, new) > { > do { > r = LL(ptr); > if (r != old) > return r; /* no barriers */ > r = new > } while (SC_release(ptr, r)); > smp_mb(); > return r; > } > > Thereby ordering things relative to the store on ptr, but the load can > very much escape. The thinking is that if success, we must observe the > latest value of ptr, but even in that case the load is not ordered and > could happen before. > > However, since we're guaranteed to observe the latest value of ptr (on > success) it doesn't matter if we reordered the load, there is no newer > value possible. > > So heaps of tricky, but correct afaict. Will? And could not PPC do something similar: cmpxchg(ptr, old, new) { lwsync(); dp { r = LL(ptr); if (r != old) return; r = new; } while (SC(ptr, r)); sync(); return r; } ? the lwsync would make it store-release on SC with similar reasoning as above. And lwsync allows 'stores reordered after loads', which allows the prior smp_store_release() to leak past. Or is the reason this doesn't work on PPC that its RCpc?