diff options
author | Jason Wessel <jason.wessel@windriver.com> | 2008-05-27 13:23:29 -0400 |
---|---|---|
committer | Ingo Molnar <mingo@elte.hu> | 2008-06-19 03:45:38 -0400 |
commit | 9c106c119ebedf624fbd682fd2a4d52e3c8c1a67 (patch) | |
tree | cc757dd11c8575110fdd4971fb76303fe500764b | |
parent | afd38009cc3acd36d41f349a669ad5825d695b1f (diff) |
softlockup: fix NMI hangs due to lock race - 2.6.26-rc regression
The touch_nmi_watchdog() routine on x86 ultimately calls
touch_softlockup_watchdog(). The problem is that to touch the
softlockup watchdog, the cpu_clock code has to be called which could
involve multiple cpu locks and can lead to a hard hang if one of the
locks is held by a processor that is not going to return anytime soon
(such as could be the case with kgdb or perhaps even with some other
kind of exception).
This patch causes the public version of the
touch_softlockup_watchdog() to defer the cpu clock access to a later
point.
The test case for this problem is to use the following kernel config
options:
CONFIG_KGDB_TESTS=y
CONFIG_KGDB_TESTS_ON_BOOT=y
CONFIG_KGDB_TESTS_BOOT_STRING="V1F100I100000"
It should be noted that kgdb test suite and these options were not
available until 2.6.26-rc2, so it was necessary to patch the kgdb
test suite during the bisection.
I would consider this patch a regression fix because the problem first
appeared in commit 27ec4407790d075c325e1f4da0a19c56953cce23 when some
logic was added to try to periodically sync the clocks. It was
possible to work around this particular problem by simply not
performing the sync anytime the system was in a critical context.
This was ok until commit 3e51f33fcc7f55e6df25d15b55ed10c8b4da84cd,
which added config option CONFIG_HAVE_UNSTABLE_SCHED_CLOCK and some
multi-cpu locks to sync the clocks. It became clear that accessing
this code from an nmi was the source of the lockups. Avoiding the
access to the low level clock code from an code inside the NMI
processing also fixed the problem with the 27ec44... commit.
Signed-off-by: Jason Wessel <jason.wessel@windriver.com>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
-rw-r--r-- | kernel/softlockup.c | 15 |
1 files changed, 10 insertions, 5 deletions
diff --git a/kernel/softlockup.c b/kernel/softlockup.c index 01b6522fd92b..c828c2339cc9 100644 --- a/kernel/softlockup.c +++ b/kernel/softlockup.c | |||
@@ -49,12 +49,17 @@ static unsigned long get_timestamp(int this_cpu) | |||
49 | return cpu_clock(this_cpu) >> 30LL; /* 2^30 ~= 10^9 */ | 49 | return cpu_clock(this_cpu) >> 30LL; /* 2^30 ~= 10^9 */ |
50 | } | 50 | } |
51 | 51 | ||
52 | void touch_softlockup_watchdog(void) | 52 | static void __touch_softlockup_watchdog(void) |
53 | { | 53 | { |
54 | int this_cpu = raw_smp_processor_id(); | 54 | int this_cpu = raw_smp_processor_id(); |
55 | 55 | ||
56 | __raw_get_cpu_var(touch_timestamp) = get_timestamp(this_cpu); | 56 | __raw_get_cpu_var(touch_timestamp) = get_timestamp(this_cpu); |
57 | } | 57 | } |
58 | |||
59 | void touch_softlockup_watchdog(void) | ||
60 | { | ||
61 | __raw_get_cpu_var(touch_timestamp) = 0; | ||
62 | } | ||
58 | EXPORT_SYMBOL(touch_softlockup_watchdog); | 63 | EXPORT_SYMBOL(touch_softlockup_watchdog); |
59 | 64 | ||
60 | void touch_all_softlockup_watchdogs(void) | 65 | void touch_all_softlockup_watchdogs(void) |
@@ -80,7 +85,7 @@ void softlockup_tick(void) | |||
80 | unsigned long now; | 85 | unsigned long now; |
81 | 86 | ||
82 | if (touch_timestamp == 0) { | 87 | if (touch_timestamp == 0) { |
83 | touch_softlockup_watchdog(); | 88 | __touch_softlockup_watchdog(); |
84 | return; | 89 | return; |
85 | } | 90 | } |
86 | 91 | ||
@@ -95,7 +100,7 @@ void softlockup_tick(void) | |||
95 | 100 | ||
96 | /* do not print during early bootup: */ | 101 | /* do not print during early bootup: */ |
97 | if (unlikely(system_state != SYSTEM_RUNNING)) { | 102 | if (unlikely(system_state != SYSTEM_RUNNING)) { |
98 | touch_softlockup_watchdog(); | 103 | __touch_softlockup_watchdog(); |
99 | return; | 104 | return; |
100 | } | 105 | } |
101 | 106 | ||
@@ -214,7 +219,7 @@ static int watchdog(void *__bind_cpu) | |||
214 | sched_setscheduler(current, SCHED_FIFO, ¶m); | 219 | sched_setscheduler(current, SCHED_FIFO, ¶m); |
215 | 220 | ||
216 | /* initialize timestamp */ | 221 | /* initialize timestamp */ |
217 | touch_softlockup_watchdog(); | 222 | __touch_softlockup_watchdog(); |
218 | 223 | ||
219 | set_current_state(TASK_INTERRUPTIBLE); | 224 | set_current_state(TASK_INTERRUPTIBLE); |
220 | /* | 225 | /* |
@@ -223,7 +228,7 @@ static int watchdog(void *__bind_cpu) | |||
223 | * debug-printout triggers in softlockup_tick(). | 228 | * debug-printout triggers in softlockup_tick(). |
224 | */ | 229 | */ |
225 | while (!kthread_should_stop()) { | 230 | while (!kthread_should_stop()) { |
226 | touch_softlockup_watchdog(); | 231 | __touch_softlockup_watchdog(); |
227 | schedule(); | 232 | schedule(); |
228 | 233 | ||
229 | if (kthread_should_stop()) | 234 | if (kthread_should_stop()) |