From: will.deacon@arm.com (Will Deacon)
To: linux-arm-kernel@lists.infradead.org
Subject: [Kgdb-bugreport] [PATCH] KGDB: add smp_mb() in synchronisation during exception handler exit
Date: Wed, 10 Mar 2010 10:17:09 -0000 [thread overview]
Message-ID: <001101cac03a$d84d4820$88e7d860$@deacon@arm.com> (raw)
In-Reply-To: <4B96B771.9050903@wildturkeyranch.net>
Hi George,
> > diff --git a/kernel/kgdb.c b/kernel/kgdb.c
> > index 761fdd2..ee7694b 100644
> > --- a/kernel/kgdb.c
> > +++ b/kernel/kgdb.c
> > @@ -1537,6 +1537,7 @@ acquirelock:
> > * Wait till all the CPUs have quit
> > * from the debugger.
> > */
> > + smp_mb();
> > for_each_online_cpu(i) {
> > while (atomic_read(&cpu_in_kgdb[i]))
> > cpu_relax();
> >
> Doesn't this have the same issue if this cpu gets to the while prior to
> the other cpu doing its write. I would think the "smp_mb()" should be
> in the while loop not prior to it.
I don't think so. The deadlock in question is caused because the aggressive
reading in the polling loop prevents the write-buffer from being able to drain.
For a dual-core system the setup can be simplified like this:
Initially: x = 1, y = 1;
CPU1 CPU0
==== ====
while (y == 1); y = 0;
x = 0; while (x == 1); /* This loop prevents y from
leaving the store buffer */
So the patch inserts a memory barrier on CPU0 between the two lines,
forcing the update to y to become visible before the reads to x occur.
CPU1 will then trundle along happily and update x. The absence of a further
polling loop means that the update to x will become visible to CPU0 at some
future time.
Cheers,
Will
prev parent reply other threads:[~2010-03-10 10:17 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-03-09 18:20 [PATCH] KGDB: add smp_mb() in synchronisation during exception handler exit Will Deacon
2010-03-09 21:02 ` [Kgdb-bugreport] " George Anzinger
2010-03-10 10:17 ` Will Deacon [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='001101cac03a$d84d4820$88e7d860$@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).