public inbox for linux-arch@vger.kernel.org
 help / color / mirror / Atom feed
From: Benjamin Herrenschmidt <benh@kernel.crashing.org>
To: Linus Torvalds <torvalds@osdl.org>
Cc: David Howells <dhowells@redhat.com>,
	akpm@osdl.org, mingo@redhat.com, jblunck@suse.de,
	bcrl@linux.intel.com, matthew@wil.cx,
	linux-kernel@vger.kernel.org, linux-arch@vger.kernel.org,
	linuxppc64-dev@ozlabs.org
Subject: Re: Memory barriers and spin_unlock safety
Date: Sat, 04 Mar 2006 08:06:05 +1100	[thread overview]
Message-ID: <1141419966.3888.67.camel@localhost.localdomain> (raw)
In-Reply-To: <Pine.LNX.4.64.0603030823200.22647@g5.osdl.org>


> PPC has an absolutely _horrible_ memory ordering implementation, as far as 
> I can tell. The thing is broken. I think it's just implementation 
> breakage, not anything really fundamental, but the fact that their write 
> barriers are expensive is a big sign that they are doing something bad. 

Are they ? read barriers and full barriers are, write barriers should be
fairly cheap (but then, I haven't measured).

> For example, their write buffers may not have a way to serialize in the 
> buffers, and at that point from an _implementation_ standpoint, you just 
> have to serialize the whole core to make sure that writes don't pass each 
> other. 

The main problem I've had in the past with the ppc barriers is more a
subtle thing in the spec that unfortunately was taken to the word by
implementors, and is that the simple write barrier (eieio) will only
order within the same storage space, that is will not order between
cacheable and non-cacheable storage. That means IOs could leak out of
locks etc... Which is why we use expensive barriers in MMIO wrappers for
now (though we might investigate the use of mmioXb instead in the
future).

> No. Issuing a read barrier on one CPU will do absolutely _nothing_ on the 
> other CPU. All barriers are purely local to one CPU, and do not generate 
> any bus traffic what-so-ever. They only potentially affect the order of 
> bus traffic due to the instructions around them (obviously).

Actually, the ppc's full barrier (sync) will generate bus traffic, and I
think in some case eieio barriers can propagate to the chipset to
enforce ordering there too depending on some voodoo settings and wether
the storage space is cacheable or not.

> So a read barrier on one CPU _has_ to be paired with a write barrier on 
> the other side in order to make sense (although the write barrier can 
> obviously be of the implied kind, ie a lock/unlock event, or just 
> architecture-specific knowledge of write behaviour, ie for example knowing 
> that writes are always seen in-order on x86).
> 
> 		Linus
> -
> To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> Please read the FAQ at  http://www.tux.org/lkml/


  parent reply	other threads:[~2006-03-03 21:06 UTC|newest]

Thread overview: 32+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-03-03 16:03 Memory barriers and spin_unlock safety David Howells
2006-03-03 16:45 ` David Howells
2006-03-03 17:03   ` Linus Torvalds
2006-03-03 20:17     ` David Howells
2006-03-03 21:34       ` Linus Torvalds
2006-03-03 21:51         ` Benjamin LaHaise
2006-03-03 22:21           ` Linus Torvalds
2006-03-03 22:36             ` Linus Torvalds
2006-03-07 17:36       ` David Howells
2006-03-07 17:40         ` Matthew Wilcox
2006-03-07 17:56           ` Jesse Barnes
2006-03-07 18:18         ` Alan Cox
2006-03-07 18:28           ` Linus Torvalds
2006-03-07 18:55             ` Alan Cox
2006-03-07 20:21               ` Linus Torvalds
2006-03-03 20:02   ` Arjan van de Ven
2006-03-03 16:55 ` Linus Torvalds
2006-03-03 20:15   ` David Howells
2006-03-03 21:31     ` Linus Torvalds
2006-03-03 21:06   ` Benjamin Herrenschmidt [this message]
2006-03-03 21:18     ` Hollis Blanchard
2006-03-03 21:52       ` David S. Miller
2006-03-03 22:04     ` Linus Torvalds
2006-03-04 10:58     ` Paul Mackerras
2006-03-04 22:49       ` Benjamin Herrenschmidt
2006-03-04 10:58   ` Paul Mackerras
2006-03-04 17:28     ` Linus Torvalds
2006-03-08  3:20       ` Paul Mackerras
2006-03-08  3:54         ` Linus Torvalds
2006-03-08 13:12           ` Alan Cox
2006-03-08 15:30             ` Linus Torvalds
2006-03-05  2:04     ` Michael Buesch

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=1141419966.3888.67.camel@localhost.localdomain \
    --to=benh@kernel.crashing.org \
    --cc=akpm@osdl.org \
    --cc=bcrl@linux.intel.com \
    --cc=dhowells@redhat.com \
    --cc=jblunck@suse.de \
    --cc=linux-arch@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linuxppc64-dev@ozlabs.org \
    --cc=matthew@wil.cx \
    --cc=mingo@redhat.com \
    --cc=torvalds@osdl.org \
    /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