Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 586692a5 authored by Mandeep Singh Baines's avatar Mandeep Singh Baines Committed by Ingo Molnar
Browse files

watchdog: Disable watchdog when thresh is zero



This restores the previous behavior of softlock_thresh.

Currently, setting watchdog_thresh to zero causes the watchdog
kthreads to consume a lot of CPU.

In addition, the logic of proc_dowatchdog_thresh and
proc_dowatchdog_enabled has been factored into proc_dowatchdog.

Signed-off-by: default avatarMandeep Singh Baines <msb@chromium.org>
Cc: Marcin Slusarz <marcin.slusarz@gmail.com>
Cc: Don Zickus <dzickus@redhat.com>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Link: http://lkml.kernel.org/r/1306127423-3347-3-git-send-email-msb@chromium.org


Signed-off-by: default avatarIngo Molnar <mingo@elte.hu>
LKML-Reference: <20110517071018.GE22305@elte.hu>
parent e04ab2bc
Loading
Loading
Loading
Loading
+3 −2
Original line number Original line Diff line number Diff line
@@ -47,8 +47,9 @@ static inline bool trigger_all_cpu_backtrace(void)
int hw_nmi_is_cpu_stuck(struct pt_regs *);
int hw_nmi_is_cpu_stuck(struct pt_regs *);
u64 hw_nmi_get_sample_period(void);
u64 hw_nmi_get_sample_period(void);
extern int watchdog_enabled;
extern int watchdog_enabled;
extern int watchdog_thresh;
struct ctl_table;
struct ctl_table;
extern int proc_dowatchdog_enabled(struct ctl_table *, int ,
extern int proc_dowatchdog(struct ctl_table *, int ,
			   void __user *, size_t *, loff_t *);
			   void __user *, size_t *, loff_t *);
#endif
#endif


+0 −1
Original line number Original line Diff line number Diff line
@@ -315,7 +315,6 @@ extern int proc_dowatchdog_thresh(struct ctl_table *table, int write,
				  void __user *buffer,
				  void __user *buffer,
				  size_t *lenp, loff_t *ppos);
				  size_t *lenp, loff_t *ppos);
extern unsigned int  softlockup_panic;
extern unsigned int  softlockup_panic;
extern int softlockup_thresh;
void lockup_detector_init(void);
void lockup_detector_init(void);
#else
#else
static inline void touch_softlockup_watchdog(void)
static inline void touch_softlockup_watchdog(void)
+8 −4
Original line number Original line Diff line number Diff line
@@ -730,14 +730,16 @@ static struct ctl_table kern_table[] = {
		.data           = &watchdog_enabled,
		.data           = &watchdog_enabled,
		.maxlen         = sizeof (int),
		.maxlen         = sizeof (int),
		.mode           = 0644,
		.mode           = 0644,
		.proc_handler   = proc_dowatchdog_enabled,
		.proc_handler   = proc_dowatchdog,
		.extra1		= &zero,
		.extra2		= &one,
	},
	},
	{
	{
		.procname	= "watchdog_thresh",
		.procname	= "watchdog_thresh",
		.data		= &softlockup_thresh,
		.data		= &watchdog_thresh,
		.maxlen		= sizeof(int),
		.maxlen		= sizeof(int),
		.mode		= 0644,
		.mode		= 0644,
		.proc_handler	= proc_dowatchdog_thresh,
		.proc_handler	= proc_dowatchdog,
		.extra1		= &neg_one,
		.extra1		= &neg_one,
		.extra2		= &sixty,
		.extra2		= &sixty,
	},
	},
@@ -755,7 +757,9 @@ static struct ctl_table kern_table[] = {
		.data           = &watchdog_enabled,
		.data           = &watchdog_enabled,
		.maxlen         = sizeof (int),
		.maxlen         = sizeof (int),
		.mode           = 0644,
		.mode           = 0644,
		.proc_handler   = proc_dowatchdog_enabled,
		.proc_handler   = proc_dowatchdog,
		.extra1		= &zero,
		.extra2		= &one,
	},
	},
#endif
#endif
#if defined(CONFIG_X86_LOCAL_APIC) && defined(CONFIG_X86)
#if defined(CONFIG_X86_LOCAL_APIC) && defined(CONFIG_X86)
+9 −16
Original line number Original line Diff line number Diff line
@@ -28,7 +28,7 @@
#include <linux/perf_event.h>
#include <linux/perf_event.h>


int watchdog_enabled = 1;
int watchdog_enabled = 1;
int __read_mostly softlockup_thresh = 60;
int __read_mostly watchdog_thresh = 60;


static DEFINE_PER_CPU(unsigned long, watchdog_touch_ts);
static DEFINE_PER_CPU(unsigned long, watchdog_touch_ts);
static DEFINE_PER_CPU(struct task_struct *, softlockup_watchdog);
static DEFINE_PER_CPU(struct task_struct *, softlockup_watchdog);
@@ -105,12 +105,12 @@ static unsigned long get_timestamp(int this_cpu)
static unsigned long get_sample_period(void)
static unsigned long get_sample_period(void)
{
{
	/*
	/*
	 * convert softlockup_thresh from seconds to ns
	 * convert watchdog_thresh from seconds to ns
	 * the divide by 5 is to give hrtimer 5 chances to
	 * the divide by 5 is to give hrtimer 5 chances to
	 * increment before the hardlockup detector generates
	 * increment before the hardlockup detector generates
	 * a warning
	 * a warning
	 */
	 */
	return softlockup_thresh * (NSEC_PER_SEC / 5);
	return watchdog_thresh * (NSEC_PER_SEC / 5);
}
}


/* Commands for resetting the watchdog */
/* Commands for resetting the watchdog */
@@ -182,7 +182,7 @@ static int is_softlockup(unsigned long touch_ts)
	unsigned long now = get_timestamp(smp_processor_id());
	unsigned long now = get_timestamp(smp_processor_id());


	/* Warn about unreasonable delays: */
	/* Warn about unreasonable delays: */
	if (time_after(now, touch_ts + softlockup_thresh))
	if (time_after(now, touch_ts + watchdog_thresh))
		return now - touch_ts;
		return now - touch_ts;


	return 0;
	return 0;
@@ -501,19 +501,19 @@ static void watchdog_disable_all_cpus(void)
/* sysctl functions */
/* sysctl functions */
#ifdef CONFIG_SYSCTL
#ifdef CONFIG_SYSCTL
/*
/*
 * proc handler for /proc/sys/kernel/nmi_watchdog
 * proc handler for /proc/sys/kernel/nmi_watchdog,watchdog_thresh
 */
 */


int proc_dowatchdog_enabled(struct ctl_table *table, int write,
int proc_dowatchdog(struct ctl_table *table, int write,
		     void __user *buffer, size_t *length, loff_t *ppos)
		    void __user *buffer, size_t *lenp, loff_t *ppos)
{
{
	int ret;
	int ret;


	ret = proc_dointvec(table, write, buffer, length, ppos);
	ret = proc_dointvec_minmax(table, write, buffer, lenp, ppos);
	if (ret || !write)
	if (ret || !write)
		goto out;
		goto out;


	if (watchdog_enabled)
	if (watchdog_enabled && watchdog_thresh)
		watchdog_enable_all_cpus();
		watchdog_enable_all_cpus();
	else
	else
		watchdog_disable_all_cpus();
		watchdog_disable_all_cpus();
@@ -521,13 +521,6 @@ int proc_dowatchdog_enabled(struct ctl_table *table, int write,
out:
out:
	return ret;
	return ret;
}
}

int proc_dowatchdog_thresh(struct ctl_table *table, int write,
			     void __user *buffer,
			     size_t *lenp, loff_t *ppos)
{
	return proc_dointvec_minmax(table, write, buffer, lenp, ppos);
}
#endif /* CONFIG_SYSCTL */
#endif /* CONFIG_SYSCTL */