debug: softlockup looping fix

Rafael J. Wysocki reported weird, multi-seconds delays during
suspend/resume and bisected it back to:

commit 82a1fcb90287052aabfa235e7ffc693ea003fe69
Author: Ingo Molnar <mingo@elte.hu>
Date: Fri Jan 25 21:08:02 2008 +0100

softlockup: automatically detect hung TASK_UNINTERRUPTIBLE tasks

fix it:

- restore the old wakeup mechanism
- fix break usage in do_each_thread() { } while_each_thread().
- fix the hotplug switch stmt, a fall-through case was broken.

Bisected-by: Rafael J. Wysocki <rjw@sisk.pl>
Signed-off-by: Peter Zijlstra <a.p.zijlstra@chello.nl>
Tested-by: Rafael J. Wysocki <rjw@sisk.pl>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
Acked-by: Rafael J. Wysocki <rjw@sisk.pl>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>

authored by Peter Zijlstra and committed by Linus Torvalds ed50d6cb aa629992

+20 -10
+20 -10
kernel/softlockup.c
··· 101 102 now = get_timestamp(this_cpu); 103 104 /* Warn about unreasonable delays: */ 105 if (now <= (touch_timestamp + softlockup_thresh)) 106 return; ··· 195 read_lock(&tasklist_lock); 196 do_each_thread(g, t) { 197 if (!--max_count) 198 - break; 199 if (t->state & TASK_UNINTERRUPTIBLE) 200 check_hung_task(t, now); 201 } while_each_thread(g, t); 202 - 203 read_unlock(&tasklist_lock); 204 } 205 ··· 222 * debug-printout triggers in softlockup_tick(). 223 */ 224 while (!kthread_should_stop()) { 225 touch_softlockup_watchdog(); 226 - msleep_interruptible(10000); 227 228 if (this_cpu != check_cpu) 229 continue; 230 231 if (sysctl_hung_task_timeout_secs) 232 check_hung_uninterruptible_tasks(this_cpu); 233 } 234 235 return 0; ··· 268 wake_up_process(per_cpu(watchdog_task, hotcpu)); 269 break; 270 #ifdef CONFIG_HOTPLUG_CPU 271 - case CPU_UP_CANCELED: 272 - case CPU_UP_CANCELED_FROZEN: 273 - if (!per_cpu(watchdog_task, hotcpu)) 274 - break; 275 - /* Unbind so it can run. Fall thru. */ 276 - kthread_bind(per_cpu(watchdog_task, hotcpu), 277 - any_online_cpu(cpu_online_map)); 278 case CPU_DOWN_PREPARE: 279 case CPU_DOWN_PREPARE_FROZEN: 280 if (hotcpu == check_cpu) { ··· 277 check_cpu = any_online_cpu(temp_cpu_online_map); 278 } 279 break; 280 case CPU_DEAD: 281 case CPU_DEAD_FROZEN: 282 p = per_cpu(watchdog_task, hotcpu);
··· 101 102 now = get_timestamp(this_cpu); 103 104 + /* Wake up the high-prio watchdog task every second: */ 105 + if (now > (touch_timestamp + 1)) 106 + wake_up_process(per_cpu(watchdog_task, this_cpu)); 107 + 108 /* Warn about unreasonable delays: */ 109 if (now <= (touch_timestamp + softlockup_thresh)) 110 return; ··· 191 read_lock(&tasklist_lock); 192 do_each_thread(g, t) { 193 if (!--max_count) 194 + goto unlock; 195 if (t->state & TASK_UNINTERRUPTIBLE) 196 check_hung_task(t, now); 197 } while_each_thread(g, t); 198 + unlock: 199 read_unlock(&tasklist_lock); 200 } 201 ··· 218 * debug-printout triggers in softlockup_tick(). 219 */ 220 while (!kthread_should_stop()) { 221 + set_current_state(TASK_INTERRUPTIBLE); 222 touch_softlockup_watchdog(); 223 + schedule(); 224 + 225 + if (kthread_should_stop()) 226 + break; 227 228 if (this_cpu != check_cpu) 229 continue; 230 231 if (sysctl_hung_task_timeout_secs) 232 check_hung_uninterruptible_tasks(this_cpu); 233 + 234 } 235 236 return 0; ··· 259 wake_up_process(per_cpu(watchdog_task, hotcpu)); 260 break; 261 #ifdef CONFIG_HOTPLUG_CPU 262 case CPU_DOWN_PREPARE: 263 case CPU_DOWN_PREPARE_FROZEN: 264 if (hotcpu == check_cpu) { ··· 275 check_cpu = any_online_cpu(temp_cpu_online_map); 276 } 277 break; 278 + 279 + case CPU_UP_CANCELED: 280 + case CPU_UP_CANCELED_FROZEN: 281 + if (!per_cpu(watchdog_task, hotcpu)) 282 + break; 283 + /* Unbind so it can run. Fall thru. */ 284 + kthread_bind(per_cpu(watchdog_task, hotcpu), 285 + any_online_cpu(cpu_online_map)); 286 case CPU_DEAD: 287 case CPU_DEAD_FROZEN: 288 p = per_cpu(watchdog_task, hotcpu);