Commit 730efb61 authored by Michael Ellerman's avatar Michael Ellerman Committed by Benjamin Herrenschmidt

powerpc/xmon: Don't loop forever in get_output_lock()

If we enter with xmon_speaker != 0 we skip the first cmpxchg(), we also
skip the while loop because xmon_speaker != last_speaker (0) - meaning we
skip the second cmpxchg() also.

Following that code path the compiler sees no memory barriers and so is
within its rights to never reload xmon_speaker. The end result is we loop
forever.

This manifests as all cpus being in xmon ('c' command), but they refuse
to take control when you switch to them ('c x' for cpu # x).

I have seen this deadlock in practice and also checked the generated code to
confirm this is what's happening.

The simplest fix is just to always try the cmpxchg().
Signed-off-by: default avatarMichael Ellerman <michael@ellerman.id.au>
Signed-off-by: default avatarBenjamin Herrenschmidt <benh@kernel.crashing.org>
parent b4d6c06c
...@@ -309,12 +309,12 @@ static void get_output_lock(void) ...@@ -309,12 +309,12 @@ static void get_output_lock(void)
if (xmon_speaker == me) if (xmon_speaker == me)
return; return;
for (;;) { for (;;) {
if (xmon_speaker == 0) { last_speaker = cmpxchg(&xmon_speaker, 0, me);
last_speaker = cmpxchg(&xmon_speaker, 0, me); if (last_speaker == 0)
if (last_speaker == 0) return;
return;
}
timeout = 10000000; timeout = 10000000;
while (xmon_speaker == last_speaker) { while (xmon_speaker == last_speaker) {
if (--timeout > 0) if (--timeout > 0)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment