Generic Linux architectural discussions
 help / color / mirror / Atom feed
* + documentation-volatile-considered-harmfultxt-correct-cpu_relax-documentation.patch added to -mm tree
@ 2010-03-18 21:41 akpm
  2010-03-18 21:54 ` Linus Torvalds
  0 siblings, 1 reply; 2+ messages in thread
From: akpm @ 2010-03-18 21:41 UTC (permalink / raw)
  To: mm-commits; +Cc: rmk, linux-arch, rmk+kernel, torvalds


The patch titled
     Documentation/volatile-considered-harmful.txt: correct cpu_relax() documentation
has been added to the -mm tree.  Its filename is
     documentation-volatile-considered-harmfultxt-correct-cpu_relax-documentation.patch

Before you just go and hit "reply", please:
   a) Consider who else should be cc'ed
   b) Prefer to cc a suitable mailing list as well
   c) Ideally: find the original patch on the mailing list and do a
      reply-to-all to that, adding suitable additional cc's

*** Remember to use Documentation/SubmitChecklist when testing your code ***

See http://userweb.kernel.org/~akpm/stuff/added-to-mm.txt to find
out what to do about this

The current -mm tree may be found at http://userweb.kernel.org/~akpm/mmotm/

------------------------------------------------------
Subject: Documentation/volatile-considered-harmful.txt: correct cpu_relax() documentation
From: Russell King <rmk@arm.linux.org.uk>

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>
---

 Documentation/volatile-considered-harmful.txt |    6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff -puN Documentation/volatile-considered-harmful.txt~documentation-volatile-considered-harmfultxt-correct-cpu_relax-documentation Documentation/volatile-considered-harmful.txt
--- a/Documentation/volatile-considered-harmful.txt~documentation-volatile-considered-harmfultxt-correct-cpu_relax-documentation
+++ a/Documentation/volatile-considered-harmful.txt
@@ -63,9 +63,9 @@ way to perform a busy wait is:
         cpu_relax();
 
 The cpu_relax() call can lower CPU power consumption or yield to a
-hyperthreaded twin processor; it also happens to serve as a memory barrier,
-so, once again, volatile is unnecessary.  Of course, busy-waiting is
-generally an anti-social act to begin with.
+hyperthreaded twin processor; it also happens to serve as a compiler
+barrier, so, once again, volatile is unnecessary.  Of course, busy-
+waiting is generally an anti-social act to begin with.
 
 There are still a few rare situations where volatile makes sense in the
 kernel:
_

Patches currently in -mm which might be from rmk@arm.linux.org.uk are

origin.patch
documentation-volatile-considered-harmfultxt-correct-cpu_relax-documentation.patch
arm-convert-proc-cpu-aligment-to-seq_file.patch
arch-arm-include-asm-elfh-forward-declare-the-task-struct.patch
bitops-rename-for_each_bit-to-for_each_set_bit-mtd.patch

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: + documentation-volatile-considered-harmfultxt-correct-cpu_relax-documentation.patch added to -mm tree
  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
  0 siblings, 0 replies; 2+ messages in thread
From: Linus Torvalds @ 2010-03-18 21:54 UTC (permalink / raw)
  To: akpm; +Cc: mm-commits, rmk, linux-arch, rmk+kernel



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

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2010-03-18 21:58 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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 is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox