linux-arch.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Nick Piggin <npiggin@suse.de>
To: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Cc: Andrew Morton <akpm@linux-foundation.org>,
	Paul Mackerras <paulus@samba.org>,
	tony.luck@intel.com, linux-arch@vger.kernel.org
Subject: Re: [patch] bitops: lock bitops
Date: Mon, 23 Jul 2007 08:16:42 +0200	[thread overview]
Message-ID: <20070723061642.GA7559@wotan.suse.de> (raw)
In-Reply-To: <1185170792.5439.105.camel@localhost.localdomain>

On Mon, Jul 23, 2007 at 04:06:31PM +1000, Benjamin Herrenschmidt wrote:
> On Thu, 2007-07-12 at 05:14 +0200, Nick Piggin wrote:
> > Here is a set of patches that aims to mitigate some of the lock_page
> > overhead on powerpc introduced in the fault path by another set.
> > Fortunately it also improves various other things too :)
> 
>  Some nits...
> 
> > +static __inline__ void clear_bit_unlock(int nr, volatile unsigned long *addr)
> > +{
> > +	unsigned long old;
> > +	unsigned long mask = BITOP_MASK(nr);
> > +	unsigned long *p = ((unsigned long *)addr) + BITOP_WORD(nr);
> > +
> > +	__asm__ __volatile__(
> > +	LWSYNC_ON_SMP
> > +"1:"	PPC_LLARX "%0,0,%3	# clear_bit_unlock\n"
> > +	"andc	%0,%0,%2\n"
> > +	PPC405_ERR77(0,%3)
> > +	PPC_STLCX "%0,0,%3\n"
> > +	"bne-	1b"
> > +	: "=&r" (old), "+m" (*p)
> > +	: "r" (mask), "r" (p)
> > +	: "cc" );
> > +}
> 
> You also want a "memory" clobber on clear_bit_unlock() to tell gcc to
> consider it as a barrier for memory accesses.

Ah good catch, thanks.


> In addition, it's worth documenting that while spin_unlock() provides
> synchronization with outstanding MMIOs (look at the io sync stuff we
> have in spinlock.h), these bitops don't (and I don't want to add that
> here anyway), so drivers abusing bitops for lock might want to use
> mmiowb() explicitely.

OK, I'll mention that in the ppc code... but generic code shouldn't
rely on this anyway, right? (Or was it decided that spinlocks must
fence IO?).

Would _io postfixed locks be a sane way to handle this?


> > +static __inline__ void __clear_bit_unlock(int nr, volatile unsigned long *addr)
> > +{
> > +	__asm__ __volatile__(LWSYNC_ON_SMP);
> > +	__clear_bit(nr, addr);
> > +}
> 
> The above needs a "memory" clobber too.

Yep.

Thanks for taking a look.

  reply	other threads:[~2007-07-23  6:16 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-07-12  3:14 [patch] bitops: lock bitops Nick Piggin
2007-07-12  3:38 ` David Miller
2007-07-12  3:49   ` Nick Piggin
2007-07-12 21:36 ` Ralf Baechle
2007-07-23  6:06 ` Benjamin Herrenschmidt
2007-07-23  6:16   ` Nick Piggin [this message]
2007-07-23  9:50     ` Benjamin Herrenschmidt

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=20070723061642.GA7559@wotan.suse.de \
    --to=npiggin@suse.de \
    --cc=akpm@linux-foundation.org \
    --cc=benh@kernel.crashing.org \
    --cc=linux-arch@vger.kernel.org \
    --cc=paulus@samba.org \
    --cc=tony.luck@intel.com \
    /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;
as well as URLs for NNTP newsgroup(s).