Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755630AbaBGM2w (ORCPT ); Fri, 7 Feb 2014 07:28:52 -0500 Received: from merlin.infradead.org ([205.233.59.134]:47105 "EHLO merlin.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752901AbaBGM2s (ORCPT ); Fri, 7 Feb 2014 07:28:48 -0500 Date: Fri, 7 Feb 2014 13:28:37 +0100 From: Peter Zijlstra To: Torsten Duwe Cc: Scott Wood , linux-kernel@vger.kernel.org, Paul Mackerras , Anton Blanchard , Tom Musta , "Paul E. McKenney" , linuxppc-dev@lists.ozlabs.org, Ingo Molnar Subject: Re: [PATCH] Convert powerpc simple spinlocks into ticket locks Message-ID: <20140207122837.GA3104@twins.programming.kicks-ass.net> References: <20140206103736.GA18054@lst.de> <20140206163837.GT2936@laptop.programming.kicks-ass.net> <20140206173727.GA13048@lst.de> <1391717992.6733.232.camel@snotra.buserror.net> <20140207090248.GB26811@lst.de> <20140207103139.GP5002@laptop.programming.kicks-ass.net> <20140207104530.GG5126@laptop.programming.kicks-ass.net> <20140207114949.GA2107@lst.de> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20140207114949.GA2107@lst.de> 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 Fri, Feb 07, 2014 at 12:49:49PM +0100, Torsten Duwe wrote: > On Fri, Feb 07, 2014 at 11:45:30AM +0100, Peter Zijlstra wrote: > > > > That might need to be lhz too, I'm confused on all the load variants. > > ;-) > > > > unlock: > > > lhz %0, 0, &tail > > > addic %0, %0, 1 > > No carry with this one, I'd say. Right you are, add immediate it is. > Besides, unlock increments the head. No, unlock increments the tail, lock increments the head and waits until the tail matches the pre-inc value. That said, why do the atomic_inc() primitives do an carry add? (that's where I borrowed it from). > > > lwsync > > > sth %0, 0, &tail > > > > > Given the beauty and simplicity of this, may I ask Ingo: > you signed off 314cdbefd1fd0a7acf3780e9628465b77ea6a836; > can you explain why head and tail must live on the same cache > line? Or is it just a space saver? I just ported it to ppc, > I didn't think about alternatives. spinlock_t should, ideally, be 32bits. > What about > > atomic_t tail; > volatile int head; ? > > Admittedly, that's usually 8 bytes instead of 4... That still won't straddle a cacheline unless you do weird alignement things which will bloat all the various data structures more still. Anyway, you can do a version with lwarx/stwcx if you're looking get rid of lharx. -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/