Russell King - ARM Linux | 9 Mar 17:22 2010

Re: [PATCH] ARM: change definition of cpu_relax() for ARM11MPCore

On Tue, Mar 09, 2010 at 04:06:08PM +0000, Will Deacon wrote:
> The cpu_relax() macro is often used in the body of busy-wait loops to ensure
> that the variable being spun on is re-loaded for each iteration.

No, cpu_relax() exists to avoid x86 CPUs overheating - if you spin like


the CPU will overheat, so it's conventional to write:


so that architectures can prevent those kinds of problems occuring.

cpu_relax() is also defined to be a compiler barrier so that the compiler
reloads the variable on every iteration.

> This patch changes the definition of cpu_relax() to smp_mb() for ARMv6 cores,
> forcing a flushing of the write buffer on SMP systems. If the Kernel is not
> compiled for SMP support, this will expand to a barrier() as before.

I don't think this is correct.  You're making a macro do something on ARM
which no other platform, apart from blackfin (which I believe is wrong)
makes it do.