watchdog.c 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676
  1. /*
  2. * Detect hard and soft lockups on a system
  3. *
  4. * started by Don Zickus, Copyright (C) 2010 Red Hat, Inc.
  5. *
  6. * Note: Most of this code is borrowed heavily from the original softlockup
  7. * detector, so thanks to Ingo for the initial implementation.
  8. * Some chunks also taken from the old x86-specific nmi watchdog code, thanks
  9. * to those contributors as well.
  10. */
  11. #define pr_fmt(fmt) "NMI watchdog: " fmt
  12. #include <linux/mm.h>
  13. #include <linux/cpu.h>
  14. #include <linux/nmi.h>
  15. #include <linux/init.h>
  16. #include <linux/delay.h>
  17. #include <linux/freezer.h>
  18. #include <linux/kthread.h>
  19. #include <linux/lockdep.h>
  20. #include <linux/notifier.h>
  21. #include <linux/module.h>
  22. #include <linux/sysctl.h>
  23. #include <asm/irq_regs.h>
  24. #include <linux/perf_event.h>
  25. int watchdog_enabled = 1;
  26. int __read_mostly watchdog_thresh = 10;
  27. static DEFINE_PER_CPU(unsigned long, watchdog_touch_ts);
  28. static DEFINE_PER_CPU(struct task_struct *, softlockup_watchdog);
  29. static DEFINE_PER_CPU(struct hrtimer, watchdog_hrtimer);
  30. static DEFINE_PER_CPU(bool, softlockup_touch_sync);
  31. static DEFINE_PER_CPU(bool, soft_watchdog_warn);
  32. #ifdef CONFIG_HARDLOCKUP_DETECTOR
  33. static DEFINE_PER_CPU(bool, hard_watchdog_warn);
  34. static DEFINE_PER_CPU(bool, watchdog_nmi_touch);
  35. static DEFINE_PER_CPU(unsigned long, hrtimer_interrupts);
  36. static DEFINE_PER_CPU(unsigned long, hrtimer_interrupts_saved);
  37. #endif
  38. #ifdef CONFIG_HARDLOCKUP_DETECTOR_NMI
  39. static DEFINE_PER_CPU(struct perf_event *, watchdog_ev);
  40. #endif
  41. /* boot commands */
  42. /*
  43. * Should we panic when a soft-lockup or hard-lockup occurs:
  44. */
  45. #ifdef CONFIG_HARDLOCKUP_DETECTOR
  46. static int hardlockup_panic =
  47. CONFIG_BOOTPARAM_HARDLOCKUP_PANIC_VALUE;
  48. static int __init hardlockup_panic_setup(char *str)
  49. {
  50. if (!strncmp(str, "panic", 5))
  51. hardlockup_panic = 1;
  52. else if (!strncmp(str, "nopanic", 7))
  53. hardlockup_panic = 0;
  54. else if (!strncmp(str, "0", 1))
  55. watchdog_enabled = 0;
  56. return 1;
  57. }
  58. __setup("nmi_watchdog=", hardlockup_panic_setup);
  59. #endif
  60. unsigned int __read_mostly softlockup_panic =
  61. CONFIG_BOOTPARAM_SOFTLOCKUP_PANIC_VALUE;
  62. static int __init softlockup_panic_setup(char *str)
  63. {
  64. softlockup_panic = simple_strtoul(str, NULL, 0);
  65. return 1;
  66. }
  67. __setup("softlockup_panic=", softlockup_panic_setup);
  68. static int __init nowatchdog_setup(char *str)
  69. {
  70. watchdog_enabled = 0;
  71. return 1;
  72. }
  73. __setup("nowatchdog", nowatchdog_setup);
  74. /* deprecated */
  75. static int __init nosoftlockup_setup(char *str)
  76. {
  77. watchdog_enabled = 0;
  78. return 1;
  79. }
  80. __setup("nosoftlockup", nosoftlockup_setup);
  81. /* */
  82. /*
  83. * Hard-lockup warnings should be triggered after just a few seconds. Soft-
  84. * lockups can have false positives under extreme conditions. So we generally
  85. * want a higher threshold for soft lockups than for hard lockups. So we couple
  86. * the thresholds with a factor: we make the soft threshold twice the amount of
  87. * time the hard threshold is.
  88. */
  89. static int get_softlockup_thresh(void)
  90. {
  91. return watchdog_thresh * 2;
  92. }
  93. /*
  94. * Returns seconds, approximately. We don't need nanosecond
  95. * resolution, and we don't need to waste time with a big divide when
  96. * 2^30ns == 1.074s.
  97. */
  98. static unsigned long get_timestamp(int this_cpu)
  99. {
  100. return cpu_clock(this_cpu) >> 30LL; /* 2^30 ~= 10^9 */
  101. }
  102. static u64 get_sample_period(void)
  103. {
  104. /*
  105. * convert watchdog_thresh from seconds to ns
  106. * the divide by 5 is to give hrtimer several chances (two
  107. * or three with the current relation between the soft
  108. * and hard thresholds) to increment before the
  109. * hardlockup detector generates a warning
  110. */
  111. return get_softlockup_thresh() * ((u64)NSEC_PER_SEC / 5);
  112. }
  113. /* Commands for resetting the watchdog */
  114. static void __touch_watchdog(void)
  115. {
  116. int this_cpu = raw_smp_processor_id();
  117. __this_cpu_write(watchdog_touch_ts, get_timestamp(this_cpu));
  118. }
  119. void touch_softlockup_watchdog(void)
  120. {
  121. __this_cpu_write(watchdog_touch_ts, 0);
  122. }
  123. EXPORT_SYMBOL(touch_softlockup_watchdog);
  124. void touch_all_softlockup_watchdogs(void)
  125. {
  126. int cpu;
  127. /*
  128. * this is done lockless
  129. * do we care if a 0 races with a timestamp?
  130. * all it means is the softlock check starts one cycle later
  131. */
  132. for_each_online_cpu(cpu)
  133. per_cpu(watchdog_touch_ts, cpu) = 0;
  134. }
  135. #ifdef CONFIG_HARDLOCKUP_DETECTOR
  136. void touch_nmi_watchdog(void)
  137. {
  138. /*
  139. * Using __raw here because some code paths have
  140. * preemption enabled. If preemption is enabled
  141. * then interrupts should be enabled too, in which
  142. * case we shouldn't have to worry about the watchdog
  143. * going off.
  144. */
  145. __raw_get_cpu_var(watchdog_nmi_touch) = true;
  146. touch_softlockup_watchdog();
  147. }
  148. EXPORT_SYMBOL(touch_nmi_watchdog);
  149. #endif
  150. void touch_softlockup_watchdog_sync(void)
  151. {
  152. __raw_get_cpu_var(softlockup_touch_sync) = true;
  153. __raw_get_cpu_var(watchdog_touch_ts) = 0;
  154. }
  155. #ifdef CONFIG_HARDLOCKUP_DETECTOR_NMI
  156. /* watchdog detector functions */
  157. static int is_hardlockup(void)
  158. {
  159. unsigned long hrint = __this_cpu_read(hrtimer_interrupts);
  160. if (__this_cpu_read(hrtimer_interrupts_saved) == hrint)
  161. return 1;
  162. __this_cpu_write(hrtimer_interrupts_saved, hrint);
  163. return 0;
  164. }
  165. #endif
  166. #ifdef CONFIG_HARDLOCKUP_DETECTOR_OTHER_CPU
  167. static int is_hardlockup_other_cpu(int cpu)
  168. {
  169. unsigned long hrint = per_cpu(hrtimer_interrupts, cpu);
  170. if (per_cpu(hrtimer_interrupts_saved, cpu) == hrint)
  171. return 1;
  172. per_cpu(hrtimer_interrupts_saved, cpu) = hrint;
  173. return 0;
  174. }
  175. static void watchdog_check_hardlockup_other_cpu(void)
  176. {
  177. int cpu;
  178. /*
  179. * Test for hardlockups every 3 samples. The sample period is
  180. * watchdog_thresh * 2 / 5, so 3 samples gets us back to slightly over
  181. * watchdog_thresh (over by 20%).
  182. */
  183. if (__this_cpu_read(hrtimer_interrupts) % 3 != 0)
  184. return;
  185. /* check for a hardlockup on the next cpu */
  186. cpu = cpumask_next(smp_processor_id(), cpu_online_mask);
  187. if (cpu >= nr_cpu_ids)
  188. cpu = cpumask_first(cpu_online_mask);
  189. if (cpu == smp_processor_id())
  190. return;
  191. if (per_cpu(watchdog_nmi_touch, cpu) == true) {
  192. per_cpu(watchdog_nmi_touch, cpu) = false;
  193. return;
  194. }
  195. if (is_hardlockup_other_cpu(cpu)) {
  196. /* only warn once */
  197. if (per_cpu(hard_watchdog_warn, cpu) == true)
  198. return;
  199. if (hardlockup_panic)
  200. panic("Watchdog detected hard LOCKUP on cpu %d", cpu);
  201. else
  202. WARN(1, "Watchdog detected hard LOCKUP on cpu %d", cpu);
  203. per_cpu(hard_watchdog_warn, cpu) = true;
  204. } else {
  205. per_cpu(hard_watchdog_warn, cpu) = false;
  206. }
  207. }
  208. #else
  209. static inline void watchdog_check_hardlockup_other_cpu(void) { return; }
  210. #endif
  211. static int is_softlockup(unsigned long touch_ts)
  212. {
  213. unsigned long now = get_timestamp(smp_processor_id());
  214. /* Warn about unreasonable delays: */
  215. if (time_after(now, touch_ts + get_softlockup_thresh()))
  216. return now - touch_ts;
  217. return 0;
  218. }
  219. #ifdef CONFIG_HARDLOCKUP_DETECTOR_NMI
  220. static struct perf_event_attr wd_hw_attr = {
  221. .type = PERF_TYPE_HARDWARE,
  222. .config = PERF_COUNT_HW_CPU_CYCLES,
  223. .size = sizeof(struct perf_event_attr),
  224. .pinned = 1,
  225. .disabled = 1,
  226. };
  227. /* Callback function for perf event subsystem */
  228. static void watchdog_overflow_callback(struct perf_event *event,
  229. struct perf_sample_data *data,
  230. struct pt_regs *regs)
  231. {
  232. /* Ensure the watchdog never gets throttled */
  233. event->hw.interrupts = 0;
  234. if (__this_cpu_read(watchdog_nmi_touch) == true) {
  235. __this_cpu_write(watchdog_nmi_touch, false);
  236. return;
  237. }
  238. /* check for a hardlockup
  239. * This is done by making sure our timer interrupt
  240. * is incrementing. The timer interrupt should have
  241. * fired multiple times before we overflow'd. If it hasn't
  242. * then this is a good indication the cpu is stuck
  243. */
  244. if (is_hardlockup()) {
  245. int this_cpu = smp_processor_id();
  246. /* only print hardlockups once */
  247. if (__this_cpu_read(hard_watchdog_warn) == true)
  248. return;
  249. if (hardlockup_panic)
  250. panic("Watchdog detected hard LOCKUP on cpu %d", this_cpu);
  251. else
  252. WARN(1, "Watchdog detected hard LOCKUP on cpu %d", this_cpu);
  253. __this_cpu_write(hard_watchdog_warn, true);
  254. return;
  255. }
  256. __this_cpu_write(hard_watchdog_warn, false);
  257. return;
  258. }
  259. #endif
  260. #ifdef CONFIG_HARDLOCKUP_DETECTOR
  261. static void watchdog_interrupt_count(void)
  262. {
  263. __this_cpu_inc(hrtimer_interrupts);
  264. }
  265. #else
  266. static inline void watchdog_interrupt_count(void) { return; }
  267. #endif /* CONFIG_HARDLOCKUP_DETECTOR */
  268. /* watchdog kicker functions */
  269. static enum hrtimer_restart watchdog_timer_fn(struct hrtimer *hrtimer)
  270. {
  271. unsigned long touch_ts = __this_cpu_read(watchdog_touch_ts);
  272. struct pt_regs *regs = get_irq_regs();
  273. int duration;
  274. /* kick the hardlockup detector */
  275. watchdog_interrupt_count();
  276. /* test for hardlockups on the next cpu */
  277. watchdog_check_hardlockup_other_cpu();
  278. /* kick the softlockup detector */
  279. wake_up_process(__this_cpu_read(softlockup_watchdog));
  280. /* .. and repeat */
  281. hrtimer_forward_now(hrtimer, ns_to_ktime(get_sample_period()));
  282. if (touch_ts == 0) {
  283. if (unlikely(__this_cpu_read(softlockup_touch_sync))) {
  284. /*
  285. * If the time stamp was touched atomically
  286. * make sure the scheduler tick is up to date.
  287. */
  288. __this_cpu_write(softlockup_touch_sync, false);
  289. sched_clock_tick();
  290. }
  291. __touch_watchdog();
  292. return HRTIMER_RESTART;
  293. }
  294. /* check for a softlockup
  295. * This is done by making sure a high priority task is
  296. * being scheduled. The task touches the watchdog to
  297. * indicate it is getting cpu time. If it hasn't then
  298. * this is a good indication some task is hogging the cpu
  299. */
  300. duration = is_softlockup(touch_ts);
  301. if (unlikely(duration)) {
  302. /* only warn once */
  303. if (__this_cpu_read(soft_watchdog_warn) == true)
  304. return HRTIMER_RESTART;
  305. printk(KERN_EMERG "BUG: soft lockup - CPU#%d stuck for %us! [%s:%d]\n",
  306. smp_processor_id(), duration,
  307. current->comm, task_pid_nr(current));
  308. print_modules();
  309. print_irqtrace_events(current);
  310. if (regs)
  311. show_regs(regs);
  312. else
  313. dump_stack();
  314. if (softlockup_panic)
  315. panic("softlockup: hung tasks");
  316. __this_cpu_write(soft_watchdog_warn, true);
  317. } else
  318. __this_cpu_write(soft_watchdog_warn, false);
  319. return HRTIMER_RESTART;
  320. }
  321. /*
  322. * The watchdog thread - touches the timestamp.
  323. */
  324. static int watchdog(void *unused)
  325. {
  326. struct sched_param param = { .sched_priority = 0 };
  327. struct hrtimer *hrtimer = &__raw_get_cpu_var(watchdog_hrtimer);
  328. /* initialize timestamp */
  329. __touch_watchdog();
  330. /* kick off the timer for the hardlockup detector */
  331. /* done here because hrtimer_start can only pin to smp_processor_id() */
  332. hrtimer_start(hrtimer, ns_to_ktime(get_sample_period()),
  333. HRTIMER_MODE_REL_PINNED);
  334. set_current_state(TASK_INTERRUPTIBLE);
  335. /*
  336. * Run briefly (kicked by the hrtimer callback function) once every
  337. * get_sample_period() seconds (4 seconds by default) to reset the
  338. * softlockup timestamp. If this gets delayed for more than
  339. * 2*watchdog_thresh seconds then the debug-printout triggers in
  340. * watchdog_timer_fn().
  341. */
  342. while (!kthread_should_stop()) {
  343. __touch_watchdog();
  344. schedule();
  345. if (kthread_should_stop())
  346. break;
  347. set_current_state(TASK_INTERRUPTIBLE);
  348. }
  349. /*
  350. * Drop the policy/priority elevation during thread exit to avoid a
  351. * scheduling latency spike.
  352. */
  353. __set_current_state(TASK_RUNNING);
  354. sched_setscheduler(current, SCHED_NORMAL, &param);
  355. return 0;
  356. }
  357. #ifdef CONFIG_HARDLOCKUP_DETECTOR_NMI
  358. static int watchdog_nmi_enable(int cpu)
  359. {
  360. struct perf_event_attr *wd_attr;
  361. struct perf_event *event = per_cpu(watchdog_ev, cpu);
  362. /* is it already setup and enabled? */
  363. if (event && event->state > PERF_EVENT_STATE_OFF)
  364. goto out;
  365. /* it is setup but not enabled */
  366. if (event != NULL)
  367. goto out_enable;
  368. wd_attr = &wd_hw_attr;
  369. wd_attr->sample_period = hw_nmi_get_sample_period(watchdog_thresh);
  370. /* Try to register using hardware perf events */
  371. event = perf_event_create_kernel_counter(wd_attr, cpu, NULL, watchdog_overflow_callback, NULL);
  372. if (!IS_ERR(event)) {
  373. pr_info("enabled, takes one hw-pmu counter.\n");
  374. goto out_save;
  375. }
  376. /* vary the KERN level based on the returned errno */
  377. if (PTR_ERR(event) == -EOPNOTSUPP)
  378. pr_info("disabled (cpu%i): not supported (no LAPIC?)\n", cpu);
  379. else if (PTR_ERR(event) == -ENOENT)
  380. pr_warning("disabled (cpu%i): hardware events not enabled\n",
  381. cpu);
  382. else
  383. pr_err("disabled (cpu%i): unable to create perf event: %ld\n",
  384. cpu, PTR_ERR(event));
  385. return PTR_ERR(event);
  386. /* success path */
  387. out_save:
  388. per_cpu(watchdog_ev, cpu) = event;
  389. out_enable:
  390. perf_event_enable(per_cpu(watchdog_ev, cpu));
  391. out:
  392. return 0;
  393. }
  394. static void watchdog_nmi_disable(int cpu)
  395. {
  396. struct perf_event *event = per_cpu(watchdog_ev, cpu);
  397. if (event) {
  398. perf_event_disable(event);
  399. per_cpu(watchdog_ev, cpu) = NULL;
  400. /* should be in cleanup, but blocks oprofile */
  401. perf_event_release_kernel(event);
  402. }
  403. return;
  404. }
  405. #else
  406. static int watchdog_nmi_enable(int cpu) { return 0; }
  407. static void watchdog_nmi_disable(int cpu) { return; }
  408. #endif /* CONFIG_HARDLOCKUP_DETECTOR */
  409. /* prepare/enable/disable routines */
  410. static void watchdog_prepare_cpu(int cpu)
  411. {
  412. struct hrtimer *hrtimer = &per_cpu(watchdog_hrtimer, cpu);
  413. WARN_ON(per_cpu(softlockup_watchdog, cpu));
  414. hrtimer_init(hrtimer, CLOCK_MONOTONIC, HRTIMER_MODE_REL);
  415. hrtimer->function = watchdog_timer_fn;
  416. #ifdef CONFIG_HARDLOCKUP_DETECTOR_OTHER_CPU
  417. /*
  418. * The new cpu will be marked online before the first hrtimer interrupt
  419. * runs on it. If another cpu tests for a hardlockup on the new cpu
  420. * before it has run its first hrtimer, it will get a false positive.
  421. * Touch the watchdog on the new cpu to delay the first check for at
  422. * least 3 sampling periods to guarantee one hrtimer has run on the new
  423. * cpu.
  424. */
  425. per_cpu(watchdog_nmi_touch, cpu) = true;
  426. #endif
  427. }
  428. static int watchdog_enable(int cpu)
  429. {
  430. struct task_struct *p = per_cpu(softlockup_watchdog, cpu);
  431. int err = 0;
  432. /* enable the perf event */
  433. err = watchdog_nmi_enable(cpu);
  434. /* Regardless of err above, fall through and start softlockup */
  435. /* create the watchdog thread */
  436. if (!p) {
  437. struct sched_param param = { .sched_priority = MAX_RT_PRIO-1 };
  438. p = kthread_create_on_node(watchdog, NULL, cpu_to_node(cpu), "watchdog/%d", cpu);
  439. if (IS_ERR(p)) {
  440. pr_err("softlockup watchdog for %i failed\n", cpu);
  441. if (!err) {
  442. /* if hardlockup hasn't already set this */
  443. err = PTR_ERR(p);
  444. /* and disable the perf event */
  445. watchdog_nmi_disable(cpu);
  446. }
  447. goto out;
  448. }
  449. sched_setscheduler(p, SCHED_FIFO, &param);
  450. kthread_bind(p, cpu);
  451. per_cpu(watchdog_touch_ts, cpu) = 0;
  452. per_cpu(softlockup_watchdog, cpu) = p;
  453. wake_up_process(p);
  454. }
  455. out:
  456. return err;
  457. }
  458. static void watchdog_disable(int cpu)
  459. {
  460. struct task_struct *p = per_cpu(softlockup_watchdog, cpu);
  461. struct hrtimer *hrtimer = &per_cpu(watchdog_hrtimer, cpu);
  462. /*
  463. * cancel the timer first to stop incrementing the stats
  464. * and waking up the kthread
  465. */
  466. hrtimer_cancel(hrtimer);
  467. /* disable the perf event */
  468. watchdog_nmi_disable(cpu);
  469. /* stop the watchdog thread */
  470. if (p) {
  471. per_cpu(softlockup_watchdog, cpu) = NULL;
  472. kthread_stop(p);
  473. }
  474. }
  475. /* sysctl functions */
  476. #ifdef CONFIG_SYSCTL
  477. static void watchdog_enable_all_cpus(void)
  478. {
  479. int cpu;
  480. watchdog_enabled = 0;
  481. for_each_online_cpu(cpu)
  482. if (!watchdog_enable(cpu))
  483. /* if any cpu succeeds, watchdog is considered
  484. enabled for the system */
  485. watchdog_enabled = 1;
  486. if (!watchdog_enabled)
  487. pr_err("failed to be enabled on some cpus\n");
  488. }
  489. static void watchdog_disable_all_cpus(void)
  490. {
  491. int cpu;
  492. for_each_online_cpu(cpu)
  493. watchdog_disable(cpu);
  494. /* if all watchdogs are disabled, then they are disabled for the system */
  495. watchdog_enabled = 0;
  496. }
  497. /*
  498. * proc handler for /proc/sys/kernel/nmi_watchdog,watchdog_thresh
  499. */
  500. int proc_dowatchdog(struct ctl_table *table, int write,
  501. void __user *buffer, size_t *lenp, loff_t *ppos)
  502. {
  503. int ret;
  504. ret = proc_dointvec_minmax(table, write, buffer, lenp, ppos);
  505. if (ret || !write)
  506. goto out;
  507. if (watchdog_enabled && watchdog_thresh)
  508. watchdog_enable_all_cpus();
  509. else
  510. watchdog_disable_all_cpus();
  511. out:
  512. return ret;
  513. }
  514. #endif /* CONFIG_SYSCTL */
  515. /*
  516. * Create/destroy watchdog threads as CPUs come and go:
  517. */
  518. static int __cpuinit
  519. cpu_callback(struct notifier_block *nfb, unsigned long action, void *hcpu)
  520. {
  521. int hotcpu = (unsigned long)hcpu;
  522. switch (action) {
  523. case CPU_UP_PREPARE:
  524. case CPU_UP_PREPARE_FROZEN:
  525. watchdog_prepare_cpu(hotcpu);
  526. break;
  527. case CPU_ONLINE:
  528. case CPU_ONLINE_FROZEN:
  529. if (watchdog_enabled)
  530. watchdog_enable(hotcpu);
  531. break;
  532. #ifdef CONFIG_HOTPLUG_CPU
  533. case CPU_UP_CANCELED:
  534. case CPU_UP_CANCELED_FROZEN:
  535. watchdog_disable(hotcpu);
  536. break;
  537. case CPU_DEAD:
  538. case CPU_DEAD_FROZEN:
  539. watchdog_disable(hotcpu);
  540. break;
  541. #endif /* CONFIG_HOTPLUG_CPU */
  542. }
  543. /*
  544. * hardlockup and softlockup are not important enough
  545. * to block cpu bring up. Just always succeed and
  546. * rely on printk output to flag problems.
  547. */
  548. return NOTIFY_OK;
  549. }
  550. static struct notifier_block __cpuinitdata cpu_nfb = {
  551. .notifier_call = cpu_callback
  552. };
  553. void __init lockup_detector_init(void)
  554. {
  555. void *cpu = (void *)(long)smp_processor_id();
  556. int err;
  557. err = cpu_callback(&cpu_nfb, CPU_UP_PREPARE, cpu);
  558. WARN_ON(notifier_to_errno(err));
  559. cpu_callback(&cpu_nfb, CPU_ONLINE, cpu);
  560. register_cpu_notifier(&cpu_nfb);
  561. return;
  562. }