From: will.deacon@arm.com (Will Deacon)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH] ARM: change definition of cpu_relax() for ARM11MPCore
Date: Tue, 9 Mar 2010 16:35:00 -0000 [thread overview]
Message-ID: <000f01cabfa6$76951ac0$63bf5040$@deacon@arm.com> (raw)
In-Reply-To: <20100309162202.GB17251@n2100.arm.linux.org.uk>
Hi Russell,
> 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
> so:
>
> for(;;);
>
> the CPU will overheat, so it's conventional to write:
>
> for(;;)
> cpu_relax();
>
> so that architectures can prevent those kinds of problems occuring.
Ok. I was going by the comments in Documentation/volatile-considered-harmful.txt
where cpu_relax() is also used as a memory barrier.
> 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.
In the KGDB case [where this cropped up], if cpu_relax() is left as it is, then
an smp_mb() is required in the architecture independent code. This also seems wrong
because it's only needed for the ARM11MPCore. There may also potentially be other
situations in the Kernel which are prone to deadlock because it is assumed that the
write buffer will always drain.
Since both solutions to this problem are nasty, it would be good to get some
clarification on the definition of cpu_relax() across the Kernel. If the KGDB guys
don't mind adding an extra memory barrier, we can solve the problem that way instead
and hope that it doesn't occur elsewhere.
Thoughts?
Cheers,
Will
next prev parent reply other threads:[~2010-03-09 16:35 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-03-09 16:06 [PATCH] ARM: change definition of cpu_relax() for ARM11MPCore Will Deacon
2010-03-09 16:22 ` Russell King - ARM Linux
2010-03-09 16:35 ` Will Deacon [this message]
2010-03-09 16:49 ` Russell King - ARM Linux
2010-03-09 17:59 ` Will Deacon
2010-03-10 22:06 ` [Kgdb-bugreport] " Jason Wessel
2010-03-11 2:47 ` DDD
2010-03-11 13:53 ` Will Deacon
2010-03-11 13:29 ` Will Deacon
2010-03-11 14:51 ` Will Deacon
2010-03-16 17:26 ` Will Deacon
2010-03-16 18:52 ` Jason Wessel
-- strict thread matches above, loose matches on Subject: below --
2010-04-12 17:23 Will Deacon
2010-04-12 17:32 ` Russell King - ARM Linux
2010-04-19 14:39 ` Will Deacon
2010-05-27 15:11 Will Deacon
2010-05-27 15:20 ` Shilimkar, Santosh
2010-05-27 16:53 ` Will Deacon
2010-05-28 4:33 ` Shilimkar, Santosh
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='000f01cabfa6$76951ac0$63bf5040$@deacon@arm.com' \
--to=will.deacon@arm.com \
--cc=linux-arm-kernel@lists.infradead.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;
as well as URLs for NNTP newsgroup(s).