Generic Linux architectural discussions
 help / color / mirror / Atom feed
From: Linus Torvalds <torvalds@linux-foundation.org>
To: akpm@linux-foundation.org
Cc: mm-commits@vger.kernel.org, rmk@arm.linux.org.uk,
	linux-arch@vger.kernel.org, rmk+kernel@arm.linux.org.uk
Subject: Re: + documentation-volatile-considered-harmfultxt-correct-cpu_relax-documentation.patch added to -mm tree
Date: Thu, 18 Mar 2010 14:54:52 -0700 (PDT)	[thread overview]
Message-ID: <alpine.LFD.2.00.1003181447420.18017@i5.linux-foundation.org> (raw)
In-Reply-To: <201003182141.o2ILfgB0017286@imap1.linux-foundation.org>



On Thu, 18 Mar 2010, akpm@linux-foundation.org wrote:
> 
> cpu_relax() is documented in volatile-considered-harmful.txt to be a
> memory barrier.  However, everyone with the exception of Blackfin and
> possibly ia64 defines cpu_relax() to be a compiler barrier.
> 
> Make the documentation reflect the general concensus.
> 
> Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
> Cc: <linux-arch@vger.kernel.org>
> Cc: Linus Torvalds <torvalds@linux-foundation.org>
> Signed-off-by: Andrew Morton <akpm@linux-foundation.org>

Acked-by: Linus Torvalds <torvalds@linux-foundation.org>

I don't think it was ever the intention that it would be seen as anything 
but a compiler barrier, although it is obviously implied that it might 
well perform some per-architecture actions that have "memory barrier-like" 
semantics.

After all, the whole and only point of the "cpu_relax()" thing is to tell 
the CPU that we're busy-looping on some event.

And that "event" might be (and often is) about reading the same memory 
location over and over until it changes to what we want it to be. So it's 
quite possible that on various architectures the "cpu_relax()" could be 
about making sure that such a tight loop on loads doesn't starve cache 
transactions, for example - and as such look a bit like a memory barrier 
from a CPU standpoint.

But it's not meant to have any kind of architectural memory ordering 
semantics as far as the kernel is concerned - those must come from other 
sources.

			Linus

      reply	other threads:[~2010-03-18 21:58 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-03-18 21:41 + documentation-volatile-considered-harmfultxt-correct-cpu_relax-documentation.patch added to -mm tree akpm
2010-03-18 21:54 ` Linus Torvalds [this message]

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=alpine.LFD.2.00.1003181447420.18017@i5.linux-foundation.org \
    --to=torvalds@linux-foundation.org \
    --cc=akpm@linux-foundation.org \
    --cc=linux-arch@vger.kernel.org \
    --cc=mm-commits@vger.kernel.org \
    --cc=rmk+kernel@arm.linux.org.uk \
    --cc=rmk@arm.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