From: Olof Johansson <olof@lixom.net>
To: Joel Schopp <jschopp@austin.ibm.com>
Cc: Ingo Molnar <mingo@elte.hu>, lkml <linux-kernel@vger.kernel.org>,
Linus Torvalds <torvalds@osdl.org>, Andrew Morton <akpm@osdl.org>,
Arjan van de Ven <arjan@infradead.org>,
Nicolas Pitre <nico@cam.org>,
Jes Sorensen <jes@trained-monkey.org>,
Al Viro <viro@ftp.linux.org.uk>, Oleg Nesterov <oleg@tv-sign.ru>,
David Howells <dhowells@redhat.com>,
Alan Cox <alan@lxorguk.ukuu.org.uk>,
Christoph Hellwig <hch@infradead.org>, Andi Kleen <ak@suse.de>,
Russell King <rmk+lkml@arm.linux.org.uk>,
Anton Blanchard <anton@samba.org>,
PPC64-dev <linuxppc64-dev@ozlabs.org>
Subject: Re: [patch 00/21] mutex subsystem, -V14
Date: Thu, 5 Jan 2006 18:29:19 -0600 [thread overview]
Message-ID: <20060106002919.GA29190@pb15.lixom.net> (raw)
In-Reply-To: <43BDA672.4090704@austin.ibm.com>
On Thu, Jan 05, 2006 at 05:06:26PM -0600, Joel Schopp wrote:
> Here is a first pass at a powerpc file for the fast paths just as an
> FYI/RFC. It is completely untested, but compiles.
You really should test it, it saves reviewers time. It's not that hard
to at least try booting it.
Besides the isync comments earlier, there's a bunch of whitespace issues
going on. Did you copy and paste the code from somewhere? If so, you
should move the original copyright over too.
All your macros use spaces instead of tabs up to the \, should be
changed.
All tmp variables should be ints, since the atomic_t counter is a 32-bit
variable. If you use longs, and lwarx (loads 32-bit without sign
extend), the comparison with < 0 will never be true.
> Index: 2.6.15-mutex14/include/asm-powerpc/mutex.h
> ===================================================================
> --- 2.6.15-mutex14.orig/include/asm-powerpc/mutex.h 2006-01-04 14:46:31.%N -0600
> +++ 2.6.15-mutex14/include/asm-powerpc/mutex.h 2006-01-05 16:25:41.%N -0600
> @@ -1,9 +1,83 @@
> /*
> - * Pull in the generic implementation for the mutex fastpath.
> + * include/asm-powerpc/mutex.h
No need to keep filenames in files.
> *
> - * TODO: implement optimized primitives instead, or leave the generic
> - * implementation in place, or pick the atomic_xchg() based generic
> - * implementation. (see asm-generic/mutex-xchg.h for details)
> + * PowerPC optimized mutex locking primitives
> + *
> + * Please look into asm-generic/mutex-xchg.h for a formal definition.
> + * Copyright (C) 2006 Joel Schopp <jschopp@austin.ibm.com>, IBM
> */
> +#ifndef _ASM_MUTEX_H
> +#define _ASM_MUTEX_H
> +#define __mutex_fastpath_lock(count, fail_fn)\
> +do{ \
> + long tmp; \
> + __asm__ __volatile__( \
> +"1: lwarx %0,0,%1\n" \
> +" addic %0,%0,-1\n" \
> +" stwcx. %0,0,%1\n" \
> +" bne- 1b\n" \
> +" isync \n" \
> + : "=&r" (tmp) \
> + : "r" (&(count)->counter) \
> + : "cr0", "memory"); \
> + if (unlikely(tmp < 0)) \
> + fail_fn(count); \
> +} while (0)
trailing whitespace
> +
> +#define __mutex_fastpath_unlock(count, fail_fn)\
> +do{ \
> + long tmp; \
> + __asm__ __volatile__(SYNC_ON_SMP \
> +"1: lwarx %0,0,%1\n" \
> +" addic %0,%0,1\n" \
> +" stwcx. %0,0,%1\n" \
> +" bne- 1b\n" \
space vs tab
> + : "=&r" (tmp) \
> + : "r" (&(count)->counter) \
> + : "cr0", "memory"); \
> + if (unlikely(tmp <= 0)) \
> + fail_fn(count); \
> +} while (0)
> +
> +
> +static inline int
trailing whitespace
> +__mutex_fastpath_trylock(atomic_t* count, int (*fail_fn)(atomic_t*))
atomic_t *count
> +{
> + long tmp;
> + __asm__ __volatile__(
> +"1: lwarx %0,0,%1\n"
> +" cmpwi 0,%0,1\n"
> +" bne- 2f\n"
> +" stwcx. %0,0,%1\n"
space vs tab on the above 4 lines
Shouldn't you decrement the counter before the store?
> +" bne- 1b\n"
> +" isync\n"
> +"2:"
> + : "=&r" (tmp)
> + : "r" (&(count)->counter)
> + : "cr0", "memory");
> +
> + return (int)tmp;
> +
> +}
> +
> +#define __mutex_slowpath_needs_to_unlock() 1
>
> -#include <asm-generic/mutex-dec.h>
> +static inline int
trailing whitespace
> +__mutex_fastpath_lock_retval(atomic_t* count, int (*fail_fn)(atomic_t *))
atomic_t *count
> +{
> + long tmp;
counter is a 32-bit variable, so should tmp be otherwise the < 0
comparison can never be true.
> + __asm__ __volatile__(
> +"1: lwarx %0,0,%1\n"
> +" addic %0,%0,-1\n"
> +" stwcx. %0,0,%1\n"
> +" bne- 1b\n"
> +" isync \n"
> + : "=&r" (tmp)
> + : "r" (&(count)->counter)
> + : "cr0", "memory");
> + if (unlikely(tmp < 0))
> + return fail_fn(count);
> + else
> + return 0;
> +}
> +#endif
next prev parent reply other threads:[~2006-01-06 0:30 UTC|newest]
Thread overview: 34+ messages / expand[flat|nested] mbox.gz Atom feed top
2006-01-04 14:41 Ingo Molnar
2006-01-04 23:45 ` Joel Schopp
2006-01-05 2:38 ` Nicolas Pitre
2006-01-05 2:51 ` Linus Torvalds
2006-01-05 3:21 ` Nick Piggin
2006-01-05 3:39 ` Anton Blanchard
2006-01-05 18:04 ` Jesse Barnes
2006-01-05 14:40 ` Ingo Molnar
2006-01-05 16:21 ` Linus Torvalds
2006-01-05 22:03 ` Ingo Molnar
2006-01-05 22:17 ` Linus Torvalds
2006-01-05 22:43 ` Ingo Molnar
2006-01-06 3:49 ` Keith Owens
2006-01-06 7:34 ` Denis Vlasenko
2006-01-05 14:35 ` Ingo Molnar
2006-01-05 16:42 ` Joel Schopp
2006-01-05 22:21 ` Ingo Molnar
2006-01-05 23:06 ` Joel Schopp
2006-01-05 23:26 ` Linus Torvalds
2006-01-05 23:36 ` Joel Schopp
2006-01-05 23:42 ` Ingo Molnar
2006-01-06 0:29 ` Olof Johansson [this message]
2006-01-07 17:49 ` PowerPC fastpaths for mutex subsystem Joel Schopp
2006-01-07 22:37 ` Andrew Morton
2006-01-08 7:43 ` Anton Blanchard
2006-01-08 8:00 ` Andrew Morton
2006-01-08 8:23 ` Anton Blanchard
2006-01-09 11:13 ` David Howells
2006-01-08 9:48 ` Ingo Molnar
2006-01-10 22:31 ` Joel Schopp
2006-01-10 23:09 ` Ingo Molnar
2006-01-11 10:52 ` Ingo Molnar
2006-01-11 17:44 ` Joel Schopp
2006-01-08 10:43 ` Ingo Molnar
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20060106002919.GA29190@pb15.lixom.net \
--to=olof@lixom.net \
--cc=ak@suse.de \
--cc=akpm@osdl.org \
--cc=alan@lxorguk.ukuu.org.uk \
--cc=anton@samba.org \
--cc=arjan@infradead.org \
--cc=dhowells@redhat.com \
--cc=hch@infradead.org \
--cc=jes@trained-monkey.org \
--cc=jschopp@austin.ibm.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linuxppc64-dev@ozlabs.org \
--cc=mingo@elte.hu \
--cc=nico@cam.org \
--cc=oleg@tv-sign.ru \
--cc=rmk+lkml@arm.linux.org.uk \
--cc=torvalds@osdl.org \
--cc=viro@ftp.linux.org.uk \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®