From owner-freebsd-arch@FreeBSD.ORG Fri Aug 24 14:29:52 2007 Return-Path: Delivered-To: freebsd-arch@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 758) id 8B5C616A46B; Fri, 24 Aug 2007 14:29:52 +0000 (UTC) Date: Fri, 24 Aug 2007 14:29:52 +0000 From: Kris Kennaway To: Pawel Jakub Dawidek Message-ID: <20070824142952.GA24469@hub.freebsd.org> References: <20070818120056.GA6498@garage.freebsd.pl> <20070818155041.GY90381@elvis.mu.org> <20070818161449.GE6498@garage.freebsd.pl> <200708211403.29293.jhb@freebsd.org> <20070821191902.GA4187@garage.freebsd.pl> <20070821202136.GB4187@garage.freebsd.pl> <3bbf2fe10708221202h44b3258cyf5ca5e9b867ac0e7@mail.gmail.com> <20070824140927.GC14536@garage.freebsd.pl> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20070824140927.GC14536@garage.freebsd.pl> User-Agent: Mutt/1.4.2.1i Cc: Attilio Rao , Alfred Perlstein , freebsd-arch@freebsd.org Subject: Re: Lockless uidinfo. X-BeenThere: freebsd-arch@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Discussion related to FreeBSD architecture List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 24 Aug 2007 14:29:52 -0000 On Fri, Aug 24, 2007 at 04:09:27PM +0200, Pawel Jakub Dawidek wrote: > On Wed, Aug 22, 2007 at 09:02:53PM +0200, Attilio Rao wrote: > > 2007/8/21, Pawel Jakub Dawidek : > > > > > > New patch is here: > > > > > > http://people.freebsd.org/~pjd/patches/uidinfo_waitfree.patch > > > > --- sys/ia64/include/atomic.h.orig > > +++ sys/ia64/include/atomic.h > > @@ -370,4 +370,15 @@ > > > > #define atomic_fetchadd_int atomic_fetchadd_32 > > > > +static __inline u_long > > +atomic_fetchadd_long(volatile u_long *p, u_long v) > > +{ > > + u_long value; > > + > > + do { > > + value = *p; > > + } while (!atomic_cmpset_64(p, value, value + v)); > > + return (value); > > +} > > + > > > > In cycles like those, as you get spinning, I would arrange things in > > order to do a cpu_spinwait(). Like this: > > > > for (;;) { > > value = *p; > > if (atomic_cmpset_64(p, value, value + v)) > > break; > > cpu_spinwait(); > > } > > In this case there is no difference as this is MI ia64 code and > cpu_spinwait() is defined as /* nothing */ there. As a general rule, > this might be a good idea. Better to still do it in case that changes. Kris