[patch] powerpc: implement optimised mutex fastpaths
Paul Mackerras
paulus at samba.org
Thu Nov 6 15:09:08 EST 2008
Nick Piggin writes:
> On Sun, Oct 12, 2008 at 07:47:32AM +0200, Nick Piggin wrote:
> >
> > Implement a more optimal mutex fastpath for powerpc, making use of acquire
> > and release barrier semantics. This takes the mutex lock+unlock benchmark
> > from 203 to 173 cycles on a G5.
> >
> > +static inline int
> > +__mutex_fastpath_trylock(atomic_t *count, int (*fail_fn)(atomic_t *))
> > +{
> > + if (likely(__mutex_cmpxchg_lock(count, 1, 0) == 1))
> > + return 1;
>
> Oops, I must have sent the wrong version. This needs a return 0 here.
Are you going to send the right version? (or did you send it and I
missed it?)
Also I note that the comment you added just before that routine says:
+ * Change the count from 1 to a value lower than 1, and return 0 (failure)
+ * if it wasn't 1 originally, or return 1 (success) otherwise. This function
+ * MUST leave the value lower than 1 even when the "1" assertion wasn't true.
yet just doing a __mutex_cmpxchg_lock isn't going to do that. So
please fix either the comment or the code (or both :).
Paul.
More information about the Linuxppc-dev
mailing list