linux-arch.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Nick Piggin <npiggin@suse.de>
To: Jamie Lokier <jamie@shareable.org>
Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>,
	Ralf Baechle <ralf@linux-mips.org>,
	Catalin Marinas <catalin.marinas@arm.com>,
	Paul Mackerras <paulus@samba.org>,
	linux-arch@vger.kernel.org, Russell King <rmk@arm.linux.org.uk>,
	Francois Romieu <romieu@fr.zoreil.com>
Subject: Re: SMP barriers semantics
Date: Tue, 23 Mar 2010 14:42:36 +1100	[thread overview]
Message-ID: <20100323034236.GN26495@laptop> (raw)
In-Reply-To: <20100322120203.GL17637@laptop>

On Mon, Mar 22, 2010 at 11:02:03PM +1100, Nick Piggin wrote:
> On Wed, Mar 17, 2010 at 01:42:43PM +0000, Jamie Lokier wrote:
> > Benjamin Herrenschmidt wrote:
> > > Maybe we can agree on a set of relaxed accessors defined specifically
> > > with those semantics (more relaxed implies use of raw_*) :
> > > 
> > >   - order is guaranteed between MMIOs
> > >   - no order is guaranteed between MMIOs and spinlocks
> > 
> > No order between MMIOs and spinlocks will be fun :-)
> 
> There isn't anyway, and things are pretty messed up in this area
> already. We have mmiowb. Some architectures do a bit of mmio vs
> lock synchronization. Eg. powerpc. But it doesn't do barriers on
> some other locks like bit spinlocks or mutexes or rwsems or
> semaphores blah blah.
> 
> When this came up I grepped a couple of drivers and found possible
> problems straight away.

Ie. with drivers using a mutex to synchronise mmios, which breaks on
powerpc (even though spinlocks would work due to their hack in there).

And on some other architectures the driver would be broken whether it
uses spinlocks or not because it is not using the right barriers.

I think we have basically everything we need right now except to
have things clearly documented and consistent over architectures, and
to have mmio acquire/release to be paired with _any_ locking function
(bitops, atomics, spinlocks, mutexes, etc).

If we enforce *strong* ordering with cacheable accesses and other IO
for regular IO accessors, then a driver would not have to do anything
special for ios or locks or anything. This can be very expensive on
some archs, but IMO it is the best default because any driver that would
work on x86 using these will work on any other arch.

It is much easier for a powerpc or altix developer to take a working
but underperforming driver, identify some of the critical ios and relax
them than it is for them to try to fix a strangely broken driver (and
where the driver developer and 99% of driver testers doesn't have their
hardware).

For relaxed accessors, I think acquire/release (versus cacheable), and
then traditional mb, rmb, wmb should be pretty good start.

Anyone disagree? I would volunteer to post some patches if not...

  reply	other threads:[~2010-03-23  3:42 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-03-02 10:52 SMP barriers semantics Catalin Marinas
2010-03-03  0:55 ` Paul Mackerras
2010-03-03 12:03   ` Catalin Marinas
2010-03-12 12:31     ` Ralf Baechle
2010-03-12 20:38       ` Jamie Lokier
2010-03-17  2:25       ` Benjamin Herrenschmidt
2010-03-17 10:31         ` Catalin Marinas
2010-03-17 13:42         ` Jamie Lokier
2010-03-22 12:02           ` Nick Piggin
2010-03-23  3:42             ` Nick Piggin [this message]
2010-03-23 10:24             ` Catalin Marinas
2010-04-06 14:20               ` Nick Piggin
2010-04-06 15:43                 ` Jamie Lokier
2010-04-06 16:04                   ` Nick Piggin
2010-04-23 16:23                 ` Catalin Marinas
2010-04-23 16:56                   ` Jamie Lokier
2010-04-23 17:25                     ` Catalin Marinas
2010-04-24  1:45                       ` Jamie Lokier
2010-04-26  9:21                         ` Catalin Marinas
2010-03-04  2:23   ` David Dillow
2010-03-04  9:33     ` Russell King
2010-03-04  9:48       ` Catalin Marinas

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=20100323034236.GN26495@laptop \
    --to=npiggin@suse.de \
    --cc=benh@kernel.crashing.org \
    --cc=catalin.marinas@arm.com \
    --cc=jamie@shareable.org \
    --cc=linux-arch@vger.kernel.org \
    --cc=paulus@samba.org \
    --cc=ralf@linux-mips.org \
    --cc=rmk@arm.linux.org.uk \
    --cc=romieu@fr.zoreil.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).