From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753918AbcDDNMO (ORCPT ); Mon, 4 Apr 2016 09:12:14 -0400 Received: from bombadil.infradead.org ([198.137.202.9]:36044 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752323AbcDDNMN (ORCPT ); Mon, 4 Apr 2016 09:12:13 -0400 Date: Mon, 4 Apr 2016 15:12:05 +0200 From: Peter Zijlstra To: linux-kernel@vger.kernel.org, will.deacon@arm.com Cc: waiman.long@hpe.com, mingo@redhat.com, paulmck@linux.vnet.ibm.com, boqun.feng@gmail.com, torvalds@linux-foundation.org, dave@stgolabs.net Subject: Re: [RFC][PATCH 3/3] locking,arm64: Introduce cmpwait() Message-ID: <20160404131205.GT3430@twins.programming.kicks-ass.net> References: <20160404122250.340636238@infradead.org> <20160404123633.484451002@infradead.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20160404123633.484451002@infradead.org> 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 Mon, Apr 04, 2016 at 02:22:53PM +0200, Peter Zijlstra wrote: > +#define __CMPWAIT_GEN(w, sz, name) \ +static inline \ > +void __cmpwait_case_##name(volatile void *ptr, unsigned long val) \ > +{ \ > + unsigned long tmp; \ > + \ > + asm volatile( \ > + " ldxr" #sz "\t%" #w "[tmp], %[v]\n" \ > + " eor %" #w "[tmp], %" #w "[tmp], %" #w "[val]\n" \ > + " cbnz %" #w "[tmp], 1f\n" \ > + " wfe\n" \ > + "1:" \ > + : [tmp] "=&r" (tmp), [val] "=&r" (val), \ > + [v] "+Q" (*(unsigned long *)ptr)); \ And this probably wants a "memory" clobber to force reload values after this returns. > +}