From: Jason Wessel <jason.wessel@windriver.com>
To: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Will Deacon <will.deacon@arm.com>,
Linux Kernel Mailing List <linux-kernel@vger.kernel.org>,
kgdb-bugreport@lists.sourceforge.net, linux-arm@vger.kernel.org,
Russell King - ARM Linux <linux@arm.linux.org.uk>
Subject: Re: [PATCH 4/5] kgdb: Use atomic operators which use barriers
Date: Fri, 02 Apr 2010 14:37:06 -0500 [thread overview]
Message-ID: <4BB64762.6040806@windriver.com> (raw)
In-Reply-To: <alpine.LFD.2.00.1004021205080.3634@i5.linux-foundation.org>
On 04/02/2010 02:12 PM, Linus Torvalds wrote:
>
>
> Hmm. While I absolutely agree that 'cpu_relax()' does not imply a memory
> barrier, I disagree that this change should be needed. If ARM has odd
> semantics where it will never see changes in a busy loop, then ARM is
> buggy, and that has _nothing_ to do with the Linux notion of memory
> barriers.
>
> The _whole_ point of "cpu_relax()" is to have busy loops. And the point of
> busy loops is that they are waiting for something to change. So if this
> loop:
>
>
>> for_each_online_cpu(i) {
>> - while (atomic_read(&cpu_in_kgdb[i]))
>> + while (atomic_add_return(0, &cpu_in_kgdb[i]))
>> cpu_relax();
>> }
>>
>
>
So this part might be overkill, but I don't actually have the hardware,
schematics or reference manuals to ascertain what is going on. The
other changes in this patch should be correct because we really do want
memory barriers which come along with the inc and dec operators.
> can somehow lock up because "cpu_relax()" doesn't work with an infinite
> "while (atomic_read(..))" loop, then the ARM implementation of cpu_relax()
> is buggy.
>
>
Will originally proposed a patch for cpu_relax:
http://lists.infradead.org/pipermail/linux-arm-kernel/2010-March/011076.html
--- The patch ---
+#if __LINUX_ARM_ARCH__ == 6
+#define cpu_relax() smp_mb()
+#else
#define cpu_relax() barrier()
+#endif
---
Russell had this thread:
http://permalink.gmane.org/gmane.linux.ports.arm.kernel/75717
--- clip from url ---
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.
---
> Does ARM have some broken cache coherency model where writes by other
> CPU's _never_ show up unless the reading CPU does some memory sync thing?
> If so, then cpu_relax() obviously does need to do that syncing
> instruction.
>
>
Given your statements, I can just keep the atomic reads as they were
previously, but keep the inc and dec parts. And we can wait for a
further response from either Will or Russell.
Thanks,
Jason.
next prev parent reply other threads:[~2010-04-02 19:38 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-04-02 18:32 [GIT PULL] kgdb fixes for 2.6.34-rc3 Jason Wessel
2010-04-02 18:32 ` [PATCH 1/5] kgdb: have ebin2mem call probe_kernel_write once Jason Wessel
2010-04-02 18:32 ` [PATCH 2/5] kgdbts,sh: Add in breakpoint pc offset for superh Jason Wessel
2010-04-02 18:32 ` [PATCH 3/5] kgdb: eliminate kgdb_wait(), all cpus enter the same way Jason Wessel
2010-04-02 18:32 ` [PATCH 4/5] kgdb: Use atomic operators which use barriers Jason Wessel
2010-04-02 18:32 ` [PATCH 5/5] kgdb: Turn off tracing while in the debugger Jason Wessel
2010-04-02 19:12 ` [PATCH 4/5] kgdb: Use atomic operators which use barriers Linus Torvalds
2010-04-02 19:37 ` Jason Wessel [this message]
2010-04-02 19:43 ` Linus Torvalds
2010-04-02 19:46 ` Linus Torvalds
2010-04-02 20:07 ` Linus Torvalds
2010-04-02 22:25 ` Russell King - ARM Linux
2010-04-02 23:24 ` Linus Torvalds
2010-04-03 16:08 ` Russell King - ARM Linux
2010-04-05 9:21 ` Pavel Machek
2010-04-05 14:56 ` Linus Torvalds
2010-04-02 19:47 ` [Kgdb-bugreport] [PATCH 4/5] kgdb: Use atomic operators whichuse barriers Jason Wessel
2010-04-02 19:47 ` Linus Torvalds
2010-04-02 20:00 ` Jason Wessel
2010-04-08 16:27 ` Dmitry Adamushko
2010-04-19 15:21 ` Will Deacon
[not found] ` <000501cad70a$26ca7e10$745f7a30$@deacon@arm.com>
2010-04-08 14:55 ` [PATCH 4/5] kgdb: Use atomic operators which use barriers Linus Torvalds
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=4BB64762.6040806@windriver.com \
--to=jason.wessel@windriver.com \
--cc=kgdb-bugreport@lists.sourceforge.net \
--cc=linux-arm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux@arm.linux.org.uk \
--cc=torvalds@linux-foundation.org \
--cc=will.deacon@arm.com \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.