blob: dd1fd59683c52dab6e150a7624704c0f979a46cc [file] [log] [blame]
Don Zickus58687ac2010-05-07 17:11:44 -04001/*
2 * Detect hard and soft lockups on a system
3 *
4 * started by Don Zickus, Copyright (C) 2010 Red Hat, Inc.
5 *
Fernando Luis Vázquez Cao86f5e6a2012-02-09 17:42:22 -05006 * 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
Don Zickus58687ac2010-05-07 17:11:44 -04009 * to those contributors as well.
10 */
11
Kefeng Wang5f92a7b2017-07-14 14:49:46 -070012#define pr_fmt(fmt) "watchdog: " fmt
Andrew Morton45019802012-03-23 15:01:55 -070013
Don Zickus58687ac2010-05-07 17:11:44 -040014#include <linux/mm.h>
15#include <linux/cpu.h>
16#include <linux/nmi.h>
17#include <linux/init.h>
Don Zickus58687ac2010-05-07 17:11:44 -040018#include <linux/module.h>
19#include <linux/sysctl.h>
Thomas Gleixnerbcd951c2012-07-16 10:42:38 +000020#include <linux/smpboot.h>
Clark Williams8bd75c72013-02-07 09:47:07 -060021#include <linux/sched/rt.h>
Ingo Molnarae7e81c2017-02-01 18:07:51 +010022#include <uapi/linux/sched/types.h>
Chris Metcalffe4ba3c2015-06-24 16:55:45 -070023#include <linux/tick.h>
Tejun Heo82607adc2015-12-08 11:28:04 -050024#include <linux/workqueue.h>
Ingo Molnare6017572017-02-01 16:36:40 +010025#include <linux/sched/clock.h>
Ingo Molnarb17b0152017-02-08 18:51:35 +010026#include <linux/sched/debug.h>
Don Zickus58687ac2010-05-07 17:11:44 -040027
28#include <asm/irq_regs.h>
Eric B Munson5d1c0f42012-03-10 14:37:28 -050029#include <linux/kvm_para.h>
Ulrich Obergfell81a4bee2015-09-04 15:45:15 -070030#include <linux/kthread.h>
Don Zickus58687ac2010-05-07 17:11:44 -040031
Thomas Gleixner946d1972017-09-12 21:37:01 +020032static DEFINE_MUTEX(watchdog_mutex);
Peter Zijlstraab992dc2015-05-18 11:31:50 +020033
Nicholas Piggin05a4a952017-07-12 14:35:46 -070034int __read_mostly nmi_watchdog_enabled;
35
36#if defined(CONFIG_HARDLOCKUP_DETECTOR) || defined(CONFIG_HAVE_NMI_WATCHDOG)
37unsigned long __read_mostly watchdog_enabled = SOFT_WATCHDOG_ENABLED |
38 NMI_WATCHDOG_ENABLED;
Ulrich Obergfell84d56e62015-04-14 15:43:55 -070039#else
Babu Moger249e52e2016-12-14 15:06:21 -080040unsigned long __read_mostly watchdog_enabled = SOFT_WATCHDOG_ENABLED;
Ulrich Obergfell84d56e62015-04-14 15:43:55 -070041#endif
Nicholas Piggin05a4a952017-07-12 14:35:46 -070042
43#ifdef CONFIG_HARDLOCKUP_DETECTOR
44/* boot commands */
45/*
46 * Should we panic when a soft-lockup or hard-lockup occurs:
47 */
48unsigned int __read_mostly hardlockup_panic =
49 CONFIG_BOOTPARAM_HARDLOCKUP_PANIC_VALUE;
50/*
51 * We may not want to enable hard lockup detection by default in all cases,
52 * for example when running the kernel as a guest on a hypervisor. In these
53 * cases this function can be called to disable hard lockup detection. This
54 * function should only be executed once by the boot processor before the
55 * kernel command line parameters are parsed, because otherwise it is not
56 * possible to override this in hardlockup_panic_setup().
57 */
Thomas Gleixner7a355822017-09-12 21:37:02 +020058void __init hardlockup_detector_disable(void)
Nicholas Piggin05a4a952017-07-12 14:35:46 -070059{
60 watchdog_enabled &= ~NMI_WATCHDOG_ENABLED;
61}
62
63static int __init hardlockup_panic_setup(char *str)
64{
65 if (!strncmp(str, "panic", 5))
66 hardlockup_panic = 1;
67 else if (!strncmp(str, "nopanic", 7))
68 hardlockup_panic = 0;
69 else if (!strncmp(str, "0", 1))
70 watchdog_enabled &= ~NMI_WATCHDOG_ENABLED;
71 else if (!strncmp(str, "1", 1))
72 watchdog_enabled |= NMI_WATCHDOG_ENABLED;
73 return 1;
74}
75__setup("nmi_watchdog=", hardlockup_panic_setup);
76
77#endif
78
79#ifdef CONFIG_SOFTLOCKUP_DETECTOR
Ulrich Obergfell84d56e62015-04-14 15:43:55 -070080int __read_mostly soft_watchdog_enabled;
Nicholas Piggin05a4a952017-07-12 14:35:46 -070081#endif
82
Ulrich Obergfell84d56e62015-04-14 15:43:55 -070083int __read_mostly watchdog_user_enabled;
Mandeep Singh Baines4eec42f2011-05-22 22:10:23 -070084int __read_mostly watchdog_thresh = 10;
Ulrich Obergfell84d56e62015-04-14 15:43:55 -070085
Aaron Tomlined235872014-06-23 13:22:05 -070086#ifdef CONFIG_SMP
87int __read_mostly sysctl_softlockup_all_cpu_backtrace;
Jiri Kosina55537872015-11-05 18:44:41 -080088int __read_mostly sysctl_hardlockup_all_cpu_backtrace;
Aaron Tomlined235872014-06-23 13:22:05 -070089#endif
Nicholas Piggin05a4a952017-07-12 14:35:46 -070090struct cpumask watchdog_cpumask __read_mostly;
Chris Metcalffe4ba3c2015-06-24 16:55:45 -070091unsigned long *watchdog_cpumask_bits = cpumask_bits(&watchdog_cpumask);
92
Ulrich Obergfellec6a9062015-09-04 15:45:28 -070093/*
94 * The 'watchdog_running' variable is set to 1 when the watchdog threads
95 * are registered/started and is set to 0 when the watchdog threads are
96 * unregistered/stopped, so it is an indicator whether the threads exist.
97 */
Frederic Weisbecker3c00ea82013-05-19 20:45:15 +020098static int __read_mostly watchdog_running;
Nicholas Piggin05a4a952017-07-12 14:35:46 -070099
100/*
101 * These functions can be overridden if an architecture implements its
102 * own hardlockup detector.
Nicholas Piggina10a8422017-07-12 14:35:49 -0700103 *
104 * watchdog_nmi_enable/disable can be implemented to start and stop when
105 * softlockup watchdog threads start and stop. The arch must select the
106 * SOFTLOCKUP_DETECTOR Kconfig.
Nicholas Piggin05a4a952017-07-12 14:35:46 -0700107 */
108int __weak watchdog_nmi_enable(unsigned int cpu)
109{
110 return 0;
111}
Thomas Gleixner941154b2017-09-12 21:37:04 +0200112
Nicholas Piggin05a4a952017-07-12 14:35:46 -0700113void __weak watchdog_nmi_disable(unsigned int cpu)
114{
Thomas Gleixner941154b2017-09-12 21:37:04 +0200115 hardlockup_detector_perf_disable();
Nicholas Piggin05a4a952017-07-12 14:35:46 -0700116}
117
Nicholas Piggina10a8422017-07-12 14:35:49 -0700118/*
119 * watchdog_nmi_reconfigure can be implemented to be notified after any
120 * watchdog configuration change. The arch hardlockup watchdog should
121 * respond to the following variables:
122 * - nmi_watchdog_enabled
123 * - watchdog_thresh
124 * - watchdog_cpumask
125 * - sysctl_hardlockup_all_cpu_backtrace
126 * - hardlockup_panic
Nicholas Piggina10a8422017-07-12 14:35:49 -0700127 */
128void __weak watchdog_nmi_reconfigure(void)
129{
130}
131
132
Nicholas Piggin05a4a952017-07-12 14:35:46 -0700133#ifdef CONFIG_SOFTLOCKUP_DETECTOR
134
135/* Helper for online, unparked cpus. */
136#define for_each_watchdog_cpu(cpu) \
137 for_each_cpu_and((cpu), cpu_online_mask, &watchdog_cpumask)
138
139atomic_t watchdog_park_in_progress = ATOMIC_INIT(0);
Ulrich Obergfellec6a9062015-09-04 15:45:28 -0700140
Chuansheng Liu0f34c402012-12-17 15:59:50 -0800141static u64 __read_mostly sample_period;
Don Zickus58687ac2010-05-07 17:11:44 -0400142
143static DEFINE_PER_CPU(unsigned long, watchdog_touch_ts);
144static DEFINE_PER_CPU(struct task_struct *, softlockup_watchdog);
145static DEFINE_PER_CPU(struct hrtimer, watchdog_hrtimer);
146static DEFINE_PER_CPU(bool, softlockup_touch_sync);
Don Zickus58687ac2010-05-07 17:11:44 -0400147static DEFINE_PER_CPU(bool, soft_watchdog_warn);
Thomas Gleixnerbcd951c2012-07-16 10:42:38 +0000148static DEFINE_PER_CPU(unsigned long, hrtimer_interrupts);
149static DEFINE_PER_CPU(unsigned long, soft_lockup_hrtimer_cnt);
chai wenb1a8de12014-10-09 15:25:17 -0700150static DEFINE_PER_CPU(struct task_struct *, softlockup_task_ptr_saved);
Don Zickus58687ac2010-05-07 17:11:44 -0400151static DEFINE_PER_CPU(unsigned long, hrtimer_interrupts_saved);
Aaron Tomlined235872014-06-23 13:22:05 -0700152static unsigned long soft_lockup_nmi_warn;
Don Zickus58687ac2010-05-07 17:11:44 -0400153
Don Zickus58687ac2010-05-07 17:11:44 -0400154unsigned int __read_mostly softlockup_panic =
155 CONFIG_BOOTPARAM_SOFTLOCKUP_PANIC_VALUE;
156
157static int __init softlockup_panic_setup(char *str)
158{
159 softlockup_panic = simple_strtoul(str, NULL, 0);
160
161 return 1;
162}
163__setup("softlockup_panic=", softlockup_panic_setup);
164
165static int __init nowatchdog_setup(char *str)
166{
Ulrich Obergfell195daf62015-04-14 15:44:13 -0700167 watchdog_enabled = 0;
Don Zickus58687ac2010-05-07 17:11:44 -0400168 return 1;
169}
170__setup("nowatchdog", nowatchdog_setup);
171
Don Zickus58687ac2010-05-07 17:11:44 -0400172static int __init nosoftlockup_setup(char *str)
173{
Ulrich Obergfell195daf62015-04-14 15:44:13 -0700174 watchdog_enabled &= ~SOFT_WATCHDOG_ENABLED;
Don Zickus58687ac2010-05-07 17:11:44 -0400175 return 1;
176}
177__setup("nosoftlockup", nosoftlockup_setup);
Ulrich Obergfell195daf62015-04-14 15:44:13 -0700178
Aaron Tomlined235872014-06-23 13:22:05 -0700179#ifdef CONFIG_SMP
180static int __init softlockup_all_cpu_backtrace_setup(char *str)
181{
182 sysctl_softlockup_all_cpu_backtrace =
183 !!simple_strtol(str, NULL, 0);
184 return 1;
185}
186__setup("softlockup_all_cpu_backtrace=", softlockup_all_cpu_backtrace_setup);
Nicholas Piggin05a4a952017-07-12 14:35:46 -0700187#ifdef CONFIG_HARDLOCKUP_DETECTOR
Jiri Kosina55537872015-11-05 18:44:41 -0800188static int __init hardlockup_all_cpu_backtrace_setup(char *str)
189{
190 sysctl_hardlockup_all_cpu_backtrace =
191 !!simple_strtol(str, NULL, 0);
192 return 1;
193}
194__setup("hardlockup_all_cpu_backtrace=", hardlockup_all_cpu_backtrace_setup);
Aaron Tomlined235872014-06-23 13:22:05 -0700195#endif
Nicholas Piggin05a4a952017-07-12 14:35:46 -0700196#endif
Don Zickus58687ac2010-05-07 17:11:44 -0400197
Thomas Gleixner941154b2017-09-12 21:37:04 +0200198static void __lockup_detector_cleanup(void);
199
Mandeep Singh Baines4eec42f2011-05-22 22:10:23 -0700200/*
201 * Hard-lockup warnings should be triggered after just a few seconds. Soft-
202 * lockups can have false positives under extreme conditions. So we generally
203 * want a higher threshold for soft lockups than for hard lockups. So we couple
204 * the thresholds with a factor: we make the soft threshold twice the amount of
205 * time the hard threshold is.
206 */
Ingo Molnar6e9101a2011-05-24 05:43:18 +0200207static int get_softlockup_thresh(void)
Mandeep Singh Baines4eec42f2011-05-22 22:10:23 -0700208{
209 return watchdog_thresh * 2;
210}
Don Zickus58687ac2010-05-07 17:11:44 -0400211
212/*
213 * Returns seconds, approximately. We don't need nanosecond
214 * resolution, and we don't need to waste time with a big divide when
215 * 2^30ns == 1.074s.
216 */
Namhyung Kimc06b4f12012-12-27 11:49:44 +0900217static unsigned long get_timestamp(void)
Don Zickus58687ac2010-05-07 17:11:44 -0400218{
Cyril Bur545a2bf2015-02-12 15:01:24 -0800219 return running_clock() >> 30LL; /* 2^30 ~= 10^9 */
Don Zickus58687ac2010-05-07 17:11:44 -0400220}
221
Chuansheng Liu0f34c402012-12-17 15:59:50 -0800222static void set_sample_period(void)
Don Zickus58687ac2010-05-07 17:11:44 -0400223{
224 /*
Mandeep Singh Baines586692a2011-05-22 22:10:22 -0700225 * convert watchdog_thresh from seconds to ns
Fernando Luis Vázquez Cao86f5e6a2012-02-09 17:42:22 -0500226 * the divide by 5 is to give hrtimer several chances (two
227 * or three with the current relation between the soft
228 * and hard thresholds) to increment before the
229 * hardlockup detector generates a warning
Don Zickus58687ac2010-05-07 17:11:44 -0400230 */
Chuansheng Liu0f34c402012-12-17 15:59:50 -0800231 sample_period = get_softlockup_thresh() * ((u64)NSEC_PER_SEC / 5);
Thomas Gleixner7edaeb62017-08-15 09:50:13 +0200232 watchdog_update_hrtimer_threshold(sample_period);
Don Zickus58687ac2010-05-07 17:11:44 -0400233}
234
235/* Commands for resetting the watchdog */
236static void __touch_watchdog(void)
237{
Namhyung Kimc06b4f12012-12-27 11:49:44 +0900238 __this_cpu_write(watchdog_touch_ts, get_timestamp());
Don Zickus58687ac2010-05-07 17:11:44 -0400239}
240
Tejun Heo03e0d462015-12-08 11:28:04 -0500241/**
242 * touch_softlockup_watchdog_sched - touch watchdog on scheduler stalls
243 *
244 * Call when the scheduler may have stalled for legitimate reasons
245 * preventing the watchdog task from executing - e.g. the scheduler
246 * entering idle state. This should only be used for scheduler events.
247 * Use touch_softlockup_watchdog() for everything else.
248 */
249void touch_softlockup_watchdog_sched(void)
Don Zickus58687ac2010-05-07 17:11:44 -0400250{
Andrew Morton78611442014-04-18 15:07:12 -0700251 /*
252 * Preemption can be enabled. It doesn't matter which CPU's timestamp
253 * gets zeroed here, so use the raw_ operation.
254 */
255 raw_cpu_write(watchdog_touch_ts, 0);
Don Zickus58687ac2010-05-07 17:11:44 -0400256}
Tejun Heo03e0d462015-12-08 11:28:04 -0500257
258void touch_softlockup_watchdog(void)
259{
260 touch_softlockup_watchdog_sched();
Tejun Heo82607adc2015-12-08 11:28:04 -0500261 wq_watchdog_touch(raw_smp_processor_id());
Tejun Heo03e0d462015-12-08 11:28:04 -0500262}
Ingo Molnar0167c782010-05-13 08:53:33 +0200263EXPORT_SYMBOL(touch_softlockup_watchdog);
Don Zickus58687ac2010-05-07 17:11:44 -0400264
Don Zickus332fbdb2010-05-07 17:11:45 -0400265void touch_all_softlockup_watchdogs(void)
Don Zickus58687ac2010-05-07 17:11:44 -0400266{
267 int cpu;
268
269 /*
270 * this is done lockless
271 * do we care if a 0 races with a timestamp?
272 * all it means is the softlock check starts one cycle later
273 */
Chris Metcalffe4ba3c2015-06-24 16:55:45 -0700274 for_each_watchdog_cpu(cpu)
Don Zickus58687ac2010-05-07 17:11:44 -0400275 per_cpu(watchdog_touch_ts, cpu) = 0;
Tejun Heo82607adc2015-12-08 11:28:04 -0500276 wq_watchdog_touch(-1);
Don Zickus58687ac2010-05-07 17:11:44 -0400277}
278
Don Zickus58687ac2010-05-07 17:11:44 -0400279void touch_softlockup_watchdog_sync(void)
280{
Christoph Lameterf7f66b02014-08-17 12:30:34 -0500281 __this_cpu_write(softlockup_touch_sync, true);
282 __this_cpu_write(watchdog_touch_ts, 0);
Don Zickus58687ac2010-05-07 17:11:44 -0400283}
284
Don Zickus26e09c62010-05-17 18:06:04 -0400285static int is_softlockup(unsigned long touch_ts)
Don Zickus58687ac2010-05-07 17:11:44 -0400286{
Namhyung Kimc06b4f12012-12-27 11:49:44 +0900287 unsigned long now = get_timestamp();
Don Zickus58687ac2010-05-07 17:11:44 -0400288
Ulrich Obergfell39d2da22015-11-05 18:44:56 -0800289 if ((watchdog_enabled & SOFT_WATCHDOG_ENABLED) && watchdog_thresh){
Ulrich Obergfell195daf62015-04-14 15:44:13 -0700290 /* Warn about unreasonable delays. */
291 if (time_after(now, touch_ts + get_softlockup_thresh()))
292 return now - touch_ts;
293 }
Don Zickus58687ac2010-05-07 17:11:44 -0400294 return 0;
295}
296
Nicholas Piggin05a4a952017-07-12 14:35:46 -0700297/* watchdog detector functions */
298bool is_hardlockup(void)
299{
300 unsigned long hrint = __this_cpu_read(hrtimer_interrupts);
301
302 if (__this_cpu_read(hrtimer_interrupts_saved) == hrint)
303 return true;
304
305 __this_cpu_write(hrtimer_interrupts_saved, hrint);
306 return false;
307}
308
Don Zickus58687ac2010-05-07 17:11:44 -0400309static void watchdog_interrupt_count(void)
310{
Christoph Lameter909ea962010-12-08 16:22:55 +0100311 __this_cpu_inc(hrtimer_interrupts);
Don Zickus58687ac2010-05-07 17:11:44 -0400312}
Thomas Gleixnerbcd951c2012-07-16 10:42:38 +0000313
Ulrich Obergfell58cf6902015-11-05 18:44:30 -0800314static int watchdog_enable_all_cpus(void);
315static void watchdog_disable_all_cpus(void);
316
Don Zickus58687ac2010-05-07 17:11:44 -0400317/* watchdog kicker functions */
318static enum hrtimer_restart watchdog_timer_fn(struct hrtimer *hrtimer)
319{
Christoph Lameter909ea962010-12-08 16:22:55 +0100320 unsigned long touch_ts = __this_cpu_read(watchdog_touch_ts);
Don Zickus58687ac2010-05-07 17:11:44 -0400321 struct pt_regs *regs = get_irq_regs();
322 int duration;
Aaron Tomlined235872014-06-23 13:22:05 -0700323 int softlockup_all_cpu_backtrace = sysctl_softlockup_all_cpu_backtrace;
Don Zickus58687ac2010-05-07 17:11:44 -0400324
Thomas Gleixner6554fd82017-09-12 21:36:57 +0200325 if (!watchdog_enabled ||
326 atomic_read(&watchdog_park_in_progress) != 0)
Don Zickusb94f5112017-01-24 15:17:53 -0800327 return HRTIMER_NORESTART;
328
Don Zickus58687ac2010-05-07 17:11:44 -0400329 /* kick the hardlockup detector */
330 watchdog_interrupt_count();
331
332 /* kick the softlockup detector */
Christoph Lameter909ea962010-12-08 16:22:55 +0100333 wake_up_process(__this_cpu_read(softlockup_watchdog));
Don Zickus58687ac2010-05-07 17:11:44 -0400334
335 /* .. and repeat */
Chuansheng Liu0f34c402012-12-17 15:59:50 -0800336 hrtimer_forward_now(hrtimer, ns_to_ktime(sample_period));
Don Zickus58687ac2010-05-07 17:11:44 -0400337
338 if (touch_ts == 0) {
Christoph Lameter909ea962010-12-08 16:22:55 +0100339 if (unlikely(__this_cpu_read(softlockup_touch_sync))) {
Don Zickus58687ac2010-05-07 17:11:44 -0400340 /*
341 * If the time stamp was touched atomically
342 * make sure the scheduler tick is up to date.
343 */
Christoph Lameter909ea962010-12-08 16:22:55 +0100344 __this_cpu_write(softlockup_touch_sync, false);
Don Zickus58687ac2010-05-07 17:11:44 -0400345 sched_clock_tick();
346 }
Eric B Munson5d1c0f42012-03-10 14:37:28 -0500347
348 /* Clear the guest paused flag on watchdog reset */
349 kvm_check_and_clear_guest_paused();
Don Zickus58687ac2010-05-07 17:11:44 -0400350 __touch_watchdog();
351 return HRTIMER_RESTART;
352 }
353
354 /* check for a softlockup
355 * This is done by making sure a high priority task is
356 * being scheduled. The task touches the watchdog to
357 * indicate it is getting cpu time. If it hasn't then
358 * this is a good indication some task is hogging the cpu
359 */
Don Zickus26e09c62010-05-17 18:06:04 -0400360 duration = is_softlockup(touch_ts);
Don Zickus58687ac2010-05-07 17:11:44 -0400361 if (unlikely(duration)) {
Eric B Munson5d1c0f42012-03-10 14:37:28 -0500362 /*
363 * If a virtual machine is stopped by the host it can look to
364 * the watchdog like a soft lockup, check to see if the host
365 * stopped the vm before we issue the warning
366 */
367 if (kvm_check_and_clear_guest_paused())
368 return HRTIMER_RESTART;
369
Don Zickus58687ac2010-05-07 17:11:44 -0400370 /* only warn once */
chai wenb1a8de12014-10-09 15:25:17 -0700371 if (__this_cpu_read(soft_watchdog_warn) == true) {
372 /*
373 * When multiple processes are causing softlockups the
374 * softlockup detector only warns on the first one
375 * because the code relies on a full quiet cycle to
376 * re-arm. The second process prevents the quiet cycle
377 * and never gets reported. Use task pointers to detect
378 * this.
379 */
380 if (__this_cpu_read(softlockup_task_ptr_saved) !=
381 current) {
382 __this_cpu_write(soft_watchdog_warn, false);
383 __touch_watchdog();
384 }
Don Zickus58687ac2010-05-07 17:11:44 -0400385 return HRTIMER_RESTART;
chai wenb1a8de12014-10-09 15:25:17 -0700386 }
Don Zickus58687ac2010-05-07 17:11:44 -0400387
Aaron Tomlined235872014-06-23 13:22:05 -0700388 if (softlockup_all_cpu_backtrace) {
389 /* Prevent multiple soft-lockup reports if one cpu is already
390 * engaged in dumping cpu back traces
391 */
392 if (test_and_set_bit(0, &soft_lockup_nmi_warn)) {
393 /* Someone else will report us. Let's give up */
394 __this_cpu_write(soft_watchdog_warn, true);
395 return HRTIMER_RESTART;
396 }
397 }
398
Fabian Frederick656c3b72014-08-06 16:04:03 -0700399 pr_emerg("BUG: soft lockup - CPU#%d stuck for %us! [%s:%d]\n",
Don Zickus26e09c62010-05-17 18:06:04 -0400400 smp_processor_id(), duration,
Don Zickus58687ac2010-05-07 17:11:44 -0400401 current->comm, task_pid_nr(current));
chai wenb1a8de12014-10-09 15:25:17 -0700402 __this_cpu_write(softlockup_task_ptr_saved, current);
Don Zickus58687ac2010-05-07 17:11:44 -0400403 print_modules();
404 print_irqtrace_events(current);
405 if (regs)
406 show_regs(regs);
407 else
408 dump_stack();
409
Aaron Tomlined235872014-06-23 13:22:05 -0700410 if (softlockup_all_cpu_backtrace) {
411 /* Avoid generating two back traces for current
412 * given that one is already made above
413 */
414 trigger_allbutself_cpu_backtrace();
415
416 clear_bit(0, &soft_lockup_nmi_warn);
417 /* Barrier to sync with other cpus */
418 smp_mb__after_atomic();
419 }
420
Josh Hunt69361ee2014-08-08 14:22:31 -0700421 add_taint(TAINT_SOFTLOCKUP, LOCKDEP_STILL_OK);
Don Zickus58687ac2010-05-07 17:11:44 -0400422 if (softlockup_panic)
423 panic("softlockup: hung tasks");
Christoph Lameter909ea962010-12-08 16:22:55 +0100424 __this_cpu_write(soft_watchdog_warn, true);
Don Zickus58687ac2010-05-07 17:11:44 -0400425 } else
Christoph Lameter909ea962010-12-08 16:22:55 +0100426 __this_cpu_write(soft_watchdog_warn, false);
Don Zickus58687ac2010-05-07 17:11:44 -0400427
428 return HRTIMER_RESTART;
429}
430
Thomas Gleixnerbcd951c2012-07-16 10:42:38 +0000431static void watchdog_set_prio(unsigned int policy, unsigned int prio)
Don Zickus58687ac2010-05-07 17:11:44 -0400432{
Thomas Gleixnerbcd951c2012-07-16 10:42:38 +0000433 struct sched_param param = { .sched_priority = prio };
434
435 sched_setscheduler(current, policy, &param);
436}
437
438static void watchdog_enable(unsigned int cpu)
439{
Christoph Lameterf7f66b02014-08-17 12:30:34 -0500440 struct hrtimer *hrtimer = raw_cpu_ptr(&watchdog_hrtimer);
Don Zickus58687ac2010-05-07 17:11:44 -0400441
Bjørn Mork3935e8952012-12-19 20:51:31 +0100442 /* kick off the timer for the hardlockup detector */
443 hrtimer_init(hrtimer, CLOCK_MONOTONIC, HRTIMER_MODE_REL);
444 hrtimer->function = watchdog_timer_fn;
445
Thomas Gleixnerbcd951c2012-07-16 10:42:38 +0000446 /* Enable the perf event */
447 watchdog_nmi_enable(cpu);
Don Zickus58687ac2010-05-07 17:11:44 -0400448
Don Zickus58687ac2010-05-07 17:11:44 -0400449 /* done here because hrtimer_start can only pin to smp_processor_id() */
Chuansheng Liu0f34c402012-12-17 15:59:50 -0800450 hrtimer_start(hrtimer, ns_to_ktime(sample_period),
Don Zickus58687ac2010-05-07 17:11:44 -0400451 HRTIMER_MODE_REL_PINNED);
452
Thomas Gleixnerbcd951c2012-07-16 10:42:38 +0000453 /* initialize timestamp */
454 watchdog_set_prio(SCHED_FIFO, MAX_RT_PRIO - 1);
455 __touch_watchdog();
Don Zickus58687ac2010-05-07 17:11:44 -0400456}
457
Thomas Gleixnerbcd951c2012-07-16 10:42:38 +0000458static void watchdog_disable(unsigned int cpu)
459{
Christoph Lameterf7f66b02014-08-17 12:30:34 -0500460 struct hrtimer *hrtimer = raw_cpu_ptr(&watchdog_hrtimer);
Thomas Gleixnerbcd951c2012-07-16 10:42:38 +0000461
462 watchdog_set_prio(SCHED_NORMAL, 0);
463 hrtimer_cancel(hrtimer);
464 /* disable the perf event */
465 watchdog_nmi_disable(cpu);
466}
467
Frederic Weisbeckerb8900bc2013-06-06 15:42:53 +0200468static void watchdog_cleanup(unsigned int cpu, bool online)
469{
470 watchdog_disable(cpu);
471}
472
Thomas Gleixnerbcd951c2012-07-16 10:42:38 +0000473static int watchdog_should_run(unsigned int cpu)
474{
475 return __this_cpu_read(hrtimer_interrupts) !=
476 __this_cpu_read(soft_lockup_hrtimer_cnt);
477}
478
479/*
480 * The watchdog thread function - touches the timestamp.
481 *
Chuansheng Liu0f34c402012-12-17 15:59:50 -0800482 * It only runs once every sample_period seconds (4 seconds by
Thomas Gleixnerbcd951c2012-07-16 10:42:38 +0000483 * default) to reset the softlockup timestamp. If this gets delayed
484 * for more than 2*watchdog_thresh seconds then the debug-printout
485 * triggers in watchdog_timer_fn().
486 */
487static void watchdog(unsigned int cpu)
488{
489 __this_cpu_write(soft_lockup_hrtimer_cnt,
490 __this_cpu_read(hrtimer_interrupts));
491 __touch_watchdog();
492}
Don Zickus58687ac2010-05-07 17:11:44 -0400493
Frederic Weisbeckerb8900bc2013-06-06 15:42:53 +0200494static struct smp_hotplug_thread watchdog_threads = {
495 .store = &softlockup_watchdog,
496 .thread_should_run = watchdog_should_run,
497 .thread_fn = watchdog,
498 .thread_comm = "watchdog/%u",
499 .setup = watchdog_enable,
500 .cleanup = watchdog_cleanup,
501 .park = watchdog_disable,
502 .unpark = watchdog_enable,
503};
504
Ulrich Obergfell81a4bee2015-09-04 15:45:15 -0700505/*
506 * park all watchdog threads that are specified in 'watchdog_cpumask'
Ulrich Obergfellee7fed52015-11-05 18:44:39 -0800507 *
508 * This function returns an error if kthread_park() of a watchdog thread
509 * fails. In this situation, the watchdog threads of some CPUs can already
510 * be parked and the watchdog threads of other CPUs can still be runnable.
511 * Callers are expected to handle this special condition as appropriate in
512 * their context.
Ulrich Obergfella2a45b82015-11-05 18:44:53 -0800513 *
514 * This function may only be called in a context that is protected against
515 * races with CPU hotplug - for example, via get_online_cpus().
Ulrich Obergfell81a4bee2015-09-04 15:45:15 -0700516 */
517static int watchdog_park_threads(void)
518{
519 int cpu, ret = 0;
520
Don Zickusb94f5112017-01-24 15:17:53 -0800521 atomic_set(&watchdog_park_in_progress, 1);
522
Ulrich Obergfell81a4bee2015-09-04 15:45:15 -0700523 for_each_watchdog_cpu(cpu) {
524 ret = kthread_park(per_cpu(softlockup_watchdog, cpu));
525 if (ret)
526 break;
527 }
Ulrich Obergfell81a4bee2015-09-04 15:45:15 -0700528
Don Zickusb94f5112017-01-24 15:17:53 -0800529 atomic_set(&watchdog_park_in_progress, 0);
530
Ulrich Obergfell81a4bee2015-09-04 15:45:15 -0700531 return ret;
532}
533
534/*
535 * unpark all watchdog threads that are specified in 'watchdog_cpumask'
Ulrich Obergfella2a45b82015-11-05 18:44:53 -0800536 *
537 * This function may only be called in a context that is protected against
538 * races with CPU hotplug - for example, via get_online_cpus().
Ulrich Obergfell81a4bee2015-09-04 15:45:15 -0700539 */
540static void watchdog_unpark_threads(void)
541{
542 int cpu;
543
Ulrich Obergfell81a4bee2015-09-04 15:45:15 -0700544 for_each_watchdog_cpu(cpu)
545 kthread_unpark(per_cpu(softlockup_watchdog, cpu));
Ulrich Obergfell81a4bee2015-09-04 15:45:15 -0700546}
547
Ulrich Obergfellb43cb432015-11-05 18:44:33 -0800548static int update_watchdog_all_cpus(void)
Michal Hocko9809b182013-09-24 15:27:30 -0700549{
Ulrich Obergfellb43cb432015-11-05 18:44:33 -0800550 int ret;
551
552 ret = watchdog_park_threads();
553 if (ret)
554 return ret;
555
Ulrich Obergfelld4bdd0b212015-09-04 15:45:21 -0700556 watchdog_unpark_threads();
Ulrich Obergfellb43cb432015-11-05 18:44:33 -0800557
558 return 0;
Michal Hocko9809b182013-09-24 15:27:30 -0700559}
560
Ulrich Obergfellb2f57c32015-04-14 15:44:16 -0700561static int watchdog_enable_all_cpus(void)
Frederic Weisbeckerb8900bc2013-06-06 15:42:53 +0200562{
563 int err = 0;
564
Frederic Weisbecker3c00ea82013-05-19 20:45:15 +0200565 if (!watchdog_running) {
Frederic Weisbecker230ec932015-09-04 15:45:06 -0700566 err = smpboot_register_percpu_thread_cpumask(&watchdog_threads,
567 &watchdog_cpumask);
Frederic Weisbeckerb8900bc2013-06-06 15:42:53 +0200568 if (err)
569 pr_err("Failed to create watchdog threads, disabled\n");
Frederic Weisbecker230ec932015-09-04 15:45:06 -0700570 else
Frederic Weisbecker3c00ea82013-05-19 20:45:15 +0200571 watchdog_running = 1;
Ulrich Obergfellb2f57c32015-04-14 15:44:16 -0700572 } else {
573 /*
574 * Enable/disable the lockup detectors or
575 * change the sample period 'on the fly'.
576 */
Ulrich Obergfellb43cb432015-11-05 18:44:33 -0800577 err = update_watchdog_all_cpus();
578
579 if (err) {
580 watchdog_disable_all_cpus();
581 pr_err("Failed to update lockup detectors, disabled\n");
582 }
Frederic Weisbeckerb8900bc2013-06-06 15:42:53 +0200583 }
584
Ulrich Obergfellb43cb432015-11-05 18:44:33 -0800585 if (err)
586 watchdog_enabled = 0;
587
Frederic Weisbeckerb8900bc2013-06-06 15:42:53 +0200588 return err;
589}
590
Don Zickus58687ac2010-05-07 17:11:44 -0400591static void watchdog_disable_all_cpus(void)
592{
Frederic Weisbecker3c00ea82013-05-19 20:45:15 +0200593 if (watchdog_running) {
594 watchdog_running = 0;
Frederic Weisbeckerb8900bc2013-06-06 15:42:53 +0200595 smpboot_unregister_percpu_thread(&watchdog_threads);
Thomas Gleixnerbcd951c2012-07-16 10:42:38 +0000596 }
Don Zickus58687ac2010-05-07 17:11:44 -0400597}
598
Nicholas Piggina10a8422017-07-12 14:35:49 -0700599#ifdef CONFIG_SYSCTL
600static int watchdog_update_cpus(void)
601{
602 return smpboot_update_cpumask_percpu_thread(
603 &watchdog_threads, &watchdog_cpumask);
604}
605#endif
606
Nicholas Piggin05a4a952017-07-12 14:35:46 -0700607#else /* SOFTLOCKUP */
608static int watchdog_park_threads(void)
609{
610 return 0;
611}
612
613static void watchdog_unpark_threads(void)
614{
615}
616
617static int watchdog_enable_all_cpus(void)
618{
619 return 0;
620}
621
622static void watchdog_disable_all_cpus(void)
623{
624}
625
Nicholas Piggina10a8422017-07-12 14:35:49 -0700626#ifdef CONFIG_SYSCTL
627static int watchdog_update_cpus(void)
628{
629 return 0;
630}
631#endif
632
Nicholas Piggin05a4a952017-07-12 14:35:46 -0700633static void set_sample_period(void)
634{
635}
636#endif /* SOFTLOCKUP */
637
Thomas Gleixner941154b2017-09-12 21:37:04 +0200638static void __lockup_detector_cleanup(void)
639{
640 lockdep_assert_held(&watchdog_mutex);
641 hardlockup_detector_perf_cleanup();
642}
643
644/**
645 * lockup_detector_cleanup - Cleanup after cpu hotplug or sysctl changes
646 *
647 * Caller must not hold the cpu hotplug rwsem.
648 */
649void lockup_detector_cleanup(void)
650{
651 mutex_lock(&watchdog_mutex);
652 __lockup_detector_cleanup();
653 mutex_unlock(&watchdog_mutex);
654}
655
Thomas Gleixner6554fd82017-09-12 21:36:57 +0200656/**
657 * lockup_detector_soft_poweroff - Interface to stop lockup detector(s)
658 *
659 * Special interface for parisc. It prevents lockup detector warnings from
660 * the default pm_poweroff() function which busy loops forever.
661 */
662void lockup_detector_soft_poweroff(void)
663{
664 watchdog_enabled = 0;
665}
666
Ulrich Obergfell58cf6902015-11-05 18:44:30 -0800667#ifdef CONFIG_SYSCTL
668
Don Zickus58687ac2010-05-07 17:11:44 -0400669/*
Ulrich Obergfella0c9cbb2015-04-14 15:43:58 -0700670 * Update the run state of the lockup detectors.
Don Zickus58687ac2010-05-07 17:11:44 -0400671 */
Ulrich Obergfella0c9cbb2015-04-14 15:43:58 -0700672static int proc_watchdog_update(void)
Don Zickus58687ac2010-05-07 17:11:44 -0400673{
Ulrich Obergfella0c9cbb2015-04-14 15:43:58 -0700674 int err = 0;
675
676 /*
677 * Watchdog threads won't be started if they are already active.
678 * The 'watchdog_running' variable in watchdog_*_all_cpus() takes
679 * care of this. If those threads are already active, the sample
680 * period will be updated and the lockup detectors will be enabled
681 * or disabled 'on the fly'.
682 */
683 if (watchdog_enabled && watchdog_thresh)
Ulrich Obergfellb2f57c32015-04-14 15:44:16 -0700684 err = watchdog_enable_all_cpus();
Ulrich Obergfella0c9cbb2015-04-14 15:43:58 -0700685 else
686 watchdog_disable_all_cpus();
687
Nicholas Piggina10a8422017-07-12 14:35:49 -0700688 watchdog_nmi_reconfigure();
689
Thomas Gleixner941154b2017-09-12 21:37:04 +0200690 __lockup_detector_cleanup();
691
Ulrich Obergfella0c9cbb2015-04-14 15:43:58 -0700692 return err;
693
694}
695
696/*
Ulrich Obergfellef246a22015-04-14 15:44:05 -0700697 * common function for watchdog, nmi_watchdog and soft_watchdog parameter
698 *
699 * caller | table->data points to | 'which' contains the flag(s)
700 * -------------------|-----------------------|-----------------------------
701 * proc_watchdog | watchdog_user_enabled | NMI_WATCHDOG_ENABLED or'ed
702 * | | with SOFT_WATCHDOG_ENABLED
703 * -------------------|-----------------------|-----------------------------
704 * proc_nmi_watchdog | nmi_watchdog_enabled | NMI_WATCHDOG_ENABLED
705 * -------------------|-----------------------|-----------------------------
706 * proc_soft_watchdog | soft_watchdog_enabled | SOFT_WATCHDOG_ENABLED
707 */
708static int proc_watchdog_common(int which, struct ctl_table *table, int write,
709 void __user *buffer, size_t *lenp, loff_t *ppos)
710{
711 int err, old, new;
712 int *watchdog_param = (int *)table->data;
Don Zickus58687ac2010-05-07 17:11:44 -0400713
Thomas Gleixnerb7a34982017-09-12 21:37:00 +0200714 cpu_hotplug_disable();
Thomas Gleixner946d1972017-09-12 21:37:01 +0200715 mutex_lock(&watchdog_mutex);
Thomas Gleixnerbcd951c2012-07-16 10:42:38 +0000716
Ulrich Obergfellef246a22015-04-14 15:44:05 -0700717 /*
718 * If the parameter is being read return the state of the corresponding
719 * bit(s) in 'watchdog_enabled', else update 'watchdog_enabled' and the
720 * run state of the lockup detectors.
721 */
722 if (!write) {
723 *watchdog_param = (watchdog_enabled & which) != 0;
724 err = proc_dointvec_minmax(table, write, buffer, lenp, ppos);
725 } else {
726 err = proc_dointvec_minmax(table, write, buffer, lenp, ppos);
727 if (err)
728 goto out;
729
730 /*
731 * There is a race window between fetching the current value
732 * from 'watchdog_enabled' and storing the new value. During
733 * this race window, watchdog_nmi_enable() can sneak in and
734 * clear the NMI_WATCHDOG_ENABLED bit in 'watchdog_enabled'.
735 * The 'cmpxchg' detects this race and the loop retries.
736 */
737 do {
738 old = watchdog_enabled;
739 /*
740 * If the parameter value is not zero set the
741 * corresponding bit(s), else clear it(them).
742 */
743 if (*watchdog_param)
744 new = old | which;
745 else
746 new = old & ~which;
747 } while (cmpxchg(&watchdog_enabled, old, new) != old);
748
749 /*
Ulrich Obergfellb43cb432015-11-05 18:44:33 -0800750 * Update the run state of the lockup detectors. There is _no_
751 * need to check the value returned by proc_watchdog_update()
752 * and to restore the previous value of 'watchdog_enabled' as
753 * both lockup detectors are disabled if proc_watchdog_update()
754 * returns an error.
Ulrich Obergfellef246a22015-04-14 15:44:05 -0700755 */
Joshua Hunta1ee1932016-03-17 14:17:23 -0700756 if (old == new)
757 goto out;
758
Ulrich Obergfellef246a22015-04-14 15:44:05 -0700759 err = proc_watchdog_update();
Ulrich Obergfellef246a22015-04-14 15:44:05 -0700760 }
761out:
Thomas Gleixner946d1972017-09-12 21:37:01 +0200762 mutex_unlock(&watchdog_mutex);
Thomas Gleixnerb7a34982017-09-12 21:37:00 +0200763 cpu_hotplug_enable();
Ulrich Obergfellef246a22015-04-14 15:44:05 -0700764 return err;
765}
766
767/*
Ulrich Obergfell83a80a32015-04-14 15:44:08 -0700768 * /proc/sys/kernel/watchdog
769 */
770int proc_watchdog(struct ctl_table *table, int write,
771 void __user *buffer, size_t *lenp, loff_t *ppos)
772{
773 return proc_watchdog_common(NMI_WATCHDOG_ENABLED|SOFT_WATCHDOG_ENABLED,
774 table, write, buffer, lenp, ppos);
775}
776
777/*
778 * /proc/sys/kernel/nmi_watchdog
779 */
780int proc_nmi_watchdog(struct ctl_table *table, int write,
781 void __user *buffer, size_t *lenp, loff_t *ppos)
782{
783 return proc_watchdog_common(NMI_WATCHDOG_ENABLED,
784 table, write, buffer, lenp, ppos);
785}
786
787/*
788 * /proc/sys/kernel/soft_watchdog
789 */
790int proc_soft_watchdog(struct ctl_table *table, int write,
791 void __user *buffer, size_t *lenp, loff_t *ppos)
792{
793 return proc_watchdog_common(SOFT_WATCHDOG_ENABLED,
794 table, write, buffer, lenp, ppos);
795}
796
797/*
798 * /proc/sys/kernel/watchdog_thresh
799 */
800int proc_watchdog_thresh(struct ctl_table *table, int write,
801 void __user *buffer, size_t *lenp, loff_t *ppos)
802{
Joshua Hunta1ee1932016-03-17 14:17:23 -0700803 int err, old, new;
Ulrich Obergfell83a80a32015-04-14 15:44:08 -0700804
Thomas Gleixnerb7a34982017-09-12 21:37:00 +0200805 cpu_hotplug_disable();
Thomas Gleixner946d1972017-09-12 21:37:01 +0200806 mutex_lock(&watchdog_mutex);
Ulrich Obergfell83a80a32015-04-14 15:44:08 -0700807
808 old = ACCESS_ONCE(watchdog_thresh);
Frederic Weisbeckerb8900bc2013-06-06 15:42:53 +0200809 err = proc_dointvec_minmax(table, write, buffer, lenp, ppos);
Ulrich Obergfell83a80a32015-04-14 15:44:08 -0700810
Frederic Weisbeckerb8900bc2013-06-06 15:42:53 +0200811 if (err || !write)
Michal Hocko359e6fa2013-09-24 15:27:29 -0700812 goto out;
Mandeep Singh Bainese04ab2b2011-05-22 22:10:21 -0700813
anish kumarb66a23562013-03-12 14:44:08 -0400814 /*
Ulrich Obergfelld283c642015-11-05 18:44:27 -0800815 * Update the sample period. Restore on failure.
anish kumarb66a23562013-03-12 14:44:08 -0400816 */
Joshua Hunta1ee1932016-03-17 14:17:23 -0700817 new = ACCESS_ONCE(watchdog_thresh);
818 if (old == new)
819 goto out;
820
Ulrich Obergfell83a80a32015-04-14 15:44:08 -0700821 set_sample_period();
822 err = proc_watchdog_update();
Ulrich Obergfelld283c642015-11-05 18:44:27 -0800823 if (err) {
Ulrich Obergfell83a80a32015-04-14 15:44:08 -0700824 watchdog_thresh = old;
Ulrich Obergfelld283c642015-11-05 18:44:27 -0800825 set_sample_period();
826 }
Michal Hocko359e6fa2013-09-24 15:27:29 -0700827out:
Thomas Gleixner946d1972017-09-12 21:37:01 +0200828 mutex_unlock(&watchdog_mutex);
Thomas Gleixnerb7a34982017-09-12 21:37:00 +0200829 cpu_hotplug_enable();
Frederic Weisbeckerb8900bc2013-06-06 15:42:53 +0200830 return err;
Don Zickus58687ac2010-05-07 17:11:44 -0400831}
Chris Metcalffe4ba3c2015-06-24 16:55:45 -0700832
833/*
834 * The cpumask is the mask of possible cpus that the watchdog can run
835 * on, not the mask of cpus it is actually running on. This allows the
836 * user to specify a mask that will include cpus that have not yet
837 * been brought online, if desired.
838 */
839int proc_watchdog_cpumask(struct ctl_table *table, int write,
840 void __user *buffer, size_t *lenp, loff_t *ppos)
841{
842 int err;
843
Thomas Gleixnerb7a34982017-09-12 21:37:00 +0200844 cpu_hotplug_disable();
Thomas Gleixner946d1972017-09-12 21:37:01 +0200845 mutex_lock(&watchdog_mutex);
Ulrich Obergfell8c073d22015-09-04 15:45:18 -0700846
Chris Metcalffe4ba3c2015-06-24 16:55:45 -0700847 err = proc_do_large_bitmap(table, write, buffer, lenp, ppos);
848 if (!err && write) {
849 /* Remove impossible cpus to keep sysctl output cleaner. */
850 cpumask_and(&watchdog_cpumask, &watchdog_cpumask,
851 cpu_possible_mask);
852
853 if (watchdog_running) {
854 /*
855 * Failure would be due to being unable to allocate
856 * a temporary cpumask, so we are likely not in a
857 * position to do much else to make things better.
858 */
Nicholas Piggina10a8422017-07-12 14:35:49 -0700859 if (watchdog_update_cpus() != 0)
Chris Metcalffe4ba3c2015-06-24 16:55:45 -0700860 pr_err("cpumask update failed\n");
861 }
Nicholas Piggina10a8422017-07-12 14:35:49 -0700862
863 watchdog_nmi_reconfigure();
Thomas Gleixner941154b2017-09-12 21:37:04 +0200864 __lockup_detector_cleanup();
Chris Metcalffe4ba3c2015-06-24 16:55:45 -0700865 }
Thomas Gleixner54901252017-09-12 21:36:59 +0200866
Thomas Gleixner946d1972017-09-12 21:37:01 +0200867 mutex_unlock(&watchdog_mutex);
Thomas Gleixnerb7a34982017-09-12 21:37:00 +0200868 cpu_hotplug_enable();
Chris Metcalffe4ba3c2015-06-24 16:55:45 -0700869 return err;
870}
871
Don Zickus58687ac2010-05-07 17:11:44 -0400872#endif /* CONFIG_SYSCTL */
873
Peter Zijlstra004417a2010-11-25 18:38:29 +0100874void __init lockup_detector_init(void)
Don Zickus58687ac2010-05-07 17:11:44 -0400875{
Chuansheng Liu0f34c402012-12-17 15:59:50 -0800876 set_sample_period();
Frederic Weisbeckerb8900bc2013-06-06 15:42:53 +0200877
Chris Metcalffe4ba3c2015-06-24 16:55:45 -0700878#ifdef CONFIG_NO_HZ_FULL
879 if (tick_nohz_full_enabled()) {
Frederic Weisbecker314b08ff2015-09-04 15:45:09 -0700880 pr_info("Disabling watchdog on nohz_full cores by default\n");
881 cpumask_copy(&watchdog_cpumask, housekeeping_mask);
Chris Metcalffe4ba3c2015-06-24 16:55:45 -0700882 } else
883 cpumask_copy(&watchdog_cpumask, cpu_possible_mask);
884#else
885 cpumask_copy(&watchdog_cpumask, cpu_possible_mask);
886#endif
887
Ulrich Obergfell195daf62015-04-14 15:44:13 -0700888 if (watchdog_enabled)
Ulrich Obergfellb2f57c32015-04-14 15:44:16 -0700889 watchdog_enable_all_cpus();
Don Zickus58687ac2010-05-07 17:11:44 -0400890}