x86_64: fix misplaced `continue' in mce.c

Background:
When a userspace application wants to know about machine check events, it
opens /dev/mcelog and does a read(). Usually, we found that this interface
works well, but in some cases, when the system was taking large numbers of
machine check exceptions, the read() would hang. The system would output a
soft-lockup warning, and the daemon reading from /dev/mcelog would suck up
as much of a single CPU as it could spinning in system space.

Description:
This patch fixes this bug. In particular, there was a "continue" inside a
timeout loop that presumably was intended to break out of the outer loop,
but instead caused the inner loop to continue. This patch also makes the
condition for the break-out a little more evident by changing a
!time_before to a time_after_eq.

Result:
The read() no longer hangs in this test case.

Testing:
On my system, I could replicate the bug with the following command:
# for i in `seq 15000`; do ./inject_sbe.sh; done
where inject_sbe.sh contains commands to inject a single-bit error into the
next memory write transaction.

Patch:
This patch is against git f1518a088bde6aea49e7c472ed6ab96178fcba3e.

Signed-off-by: Joshua Wise <jwise@google.com>
Signed-off-by: Tim Hockin <thockin@google.com>
Cc: Andi Kleen <ak@suse.de>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>

authored by Joshua Wise and committed by Linus Torvalds 4f84e4be d8aaf121

+4 -2
+4 -2
arch/x86_64/kernel/mce.c
··· 497 497 for (i = 0; i < next; i++) { 498 498 unsigned long start = jiffies; 499 499 while (!mcelog.entry[i].finished) { 500 - if (!time_before(jiffies, start + 2)) { 500 + if (time_after_eq(jiffies, start + 2)) { 501 501 memset(mcelog.entry + i,0, sizeof(struct mce)); 502 - continue; 502 + goto timeout; 503 503 } 504 504 cpu_relax(); 505 505 } 506 506 smp_rmb(); 507 507 err |= copy_to_user(buf, mcelog.entry + i, sizeof(struct mce)); 508 508 buf += sizeof(struct mce); 509 + timeout: 510 + ; 509 511 } 510 512 511 513 memset(mcelog.entry, 0, next * sizeof(struct mce));