From: Mandeep Singh Baines <msb@chromium.org>
To: Ingo Molnar <mingo@elte.hu>
Cc: Mandeep Singh Baines <msb@chromium.org>,
Andrew Morton <akpm@linux-foundation.org>,
linux-kernel@vger.kernel.org,
Marcin Slusarz <marcin.slusarz@gmail.com>,
Don Zickus <dzickus@redhat.com>,
Peter Zijlstra <a.p.zijlstra@chello.nl>,
Frederic Weisbecker <fweisbec@gmail.com>
Subject: [PATCH 3/4 v3] watchdog: disable watchdog when thresh is zero
Date: Thu, 19 May 2011 09:20:42 -0700 [thread overview]
Message-ID: <20110519162042.GI11023@google.com> (raw)
In-Reply-To: <20110518083551.GE14805@elte.hu>
Ingo Molnar (mingo@elte.hu) wrote:
>
> * Mandeep Singh Baines <msb@chromium.org> wrote:
>
> > +extern int watchdog_thresh;
> > struct ctl_table;
> > -extern int proc_dowatchdog_enabled(struct ctl_table *, int ,
> > - void __user *, size_t *, loff_t *);
> > +extern int __proc_dowatchdog(struct ctl_table *, int ,
> > + void __user *, size_t *, loff_t *);
> > +#define proc_dowatchdog_enabled __proc_dowatchdog
> > +#define proc_dowatchdog_thresh __proc_dowatchdog
>
> i like the other aspects of your patch but this one is a no-no, we do not use
> 1970's tech to obfuscate nice C code! :-)
>
Yeah, you're right. Fixed in this patch (v3).
---
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: Mandeep Singh Baines <msb@chromium.org>
LKML-Reference: <20110517071018.GE22305@elte.hu>
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>
Cc: Ingo Molnar <mingo@elte.hu>
---
include/linux/nmi.h | 5 +++--
include/linux/sched.h | 1 -
kernel/sysctl.c | 12 ++++++++----
kernel/watchdog.c | 25 +++++++++----------------
4 files changed, 20 insertions(+), 23 deletions(-)
diff --git a/include/linux/nmi.h b/include/linux/nmi.h
index c536f85..5317b8b 100644
--- a/include/linux/nmi.h
+++ b/include/linux/nmi.h
@@ -47,9 +47,10 @@ static inline bool trigger_all_cpu_backtrace(void)
int hw_nmi_is_cpu_stuck(struct pt_regs *);
u64 hw_nmi_get_sample_period(void);
extern int watchdog_enabled;
+extern int watchdog_thresh;
struct ctl_table;
-extern int proc_dowatchdog_enabled(struct ctl_table *, int ,
- void __user *, size_t *, loff_t *);
+extern int proc_dowatchdog(struct ctl_table *, int ,
+ void __user *, size_t *, loff_t *);
#endif
#endif
diff --git a/include/linux/sched.h b/include/linux/sched.h
index 12211e1..d8b2d0b 100644
--- a/include/linux/sched.h
+++ b/include/linux/sched.h
@@ -315,7 +315,6 @@ extern int proc_dowatchdog_thresh(struct ctl_table *table, int write,
void __user *buffer,
size_t *lenp, loff_t *ppos);
extern unsigned int softlockup_panic;
-extern int softlockup_thresh;
void lockup_detector_init(void);
#else
static inline void touch_softlockup_watchdog(void)
diff --git a/kernel/sysctl.c b/kernel/sysctl.c
index c0bb324..3dd0c46 100644
--- a/kernel/sysctl.c
+++ b/kernel/sysctl.c
@@ -730,14 +730,16 @@ static struct ctl_table kern_table[] = {
.data = &watchdog_enabled,
.maxlen = sizeof (int),
.mode = 0644,
- .proc_handler = proc_dowatchdog_enabled,
+ .proc_handler = proc_dowatchdog,
+ .extra1 = &zero,
+ .extra2 = &one,
},
{
.procname = "watchdog_thresh",
- .data = &softlockup_thresh,
+ .data = &watchdog_thresh,
.maxlen = sizeof(int),
.mode = 0644,
- .proc_handler = proc_dowatchdog_thresh,
+ .proc_handler = proc_dowatchdog,
.extra1 = &neg_one,
.extra2 = &sixty,
},
@@ -755,7 +757,9 @@ static struct ctl_table kern_table[] = {
.data = &watchdog_enabled,
.maxlen = sizeof (int),
.mode = 0644,
- .proc_handler = proc_dowatchdog_enabled,
+ .proc_handler = proc_dowatchdog,
+ .extra1 = &zero,
+ .extra2 = &one,
},
#endif
#if defined(CONFIG_X86_LOCAL_APIC) && defined(CONFIG_X86)
diff --git a/kernel/watchdog.c b/kernel/watchdog.c
index cf0e09f..6030191 100644
--- a/kernel/watchdog.c
+++ b/kernel/watchdog.c
@@ -28,7 +28,7 @@
#include <linux/perf_event.h>
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(struct task_struct *, softlockup_watchdog);
@@ -105,12 +105,12 @@ static unsigned long get_timestamp(int this_cpu)
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
* increment before the hardlockup detector generates
* a warning
*/
- return softlockup_thresh * (NSEC_PER_SEC / 5);
+ return watchdog_thresh * (NSEC_PER_SEC / 5);
}
/* 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());
/* 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 0;
@@ -501,19 +501,19 @@ static void watchdog_disable_all_cpus(void)
/* sysctl functions */
#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,
- void __user *buffer, size_t *length, loff_t *ppos)
+int proc_dowatchdog(struct ctl_table *table, int write,
+ void __user *buffer, size_t *lenp, loff_t *ppos)
{
int ret;
- ret = proc_dointvec(table, write, buffer, length, ppos);
+ ret = proc_dointvec_minmax(table, write, buffer, lenp, ppos);
if (ret || !write)
goto out;
- if (watchdog_enabled)
+ if (watchdog_enabled && watchdog_thresh)
watchdog_enable_all_cpus();
else
watchdog_disable_all_cpus();
@@ -521,13 +521,6 @@ int proc_dowatchdog_enabled(struct ctl_table *table, int write,
out:
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 */
--
1.7.3.1
next prev parent reply other threads:[~2011-05-19 16:21 UTC|newest]
Thread overview: 30+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-05-16 23:34 [PATCH 1/4] watchdog: fix rounding issues in get_sample_period() Mandeep Singh Baines
2011-05-16 23:34 ` [PATCH 2/4] watchdog: only disable/enable watchdog if neccessary Mandeep Singh Baines
2011-05-16 23:35 ` [PATCH 3/4] watchdog: disable watchdog when thresh is zero Mandeep Singh Baines
2011-05-17 7:10 ` Ingo Molnar
2011-05-18 3:36 ` [PATCH 3/4 v2] " Mandeep Singh Baines
2011-05-18 8:35 ` Ingo Molnar
2011-05-19 16:20 ` Mandeep Singh Baines [this message]
2011-05-23 11:13 ` [tip:perf/urgent] watchdog: Disable " tip-bot for Mandeep Singh Baines
2011-05-16 23:35 ` [PATCH 4/4] watchdog: configure nmi watchdog period based on watchdog_thresh Mandeep Singh Baines
2011-05-17 7:16 ` Ingo Molnar
2011-05-17 14:03 ` Don Zickus
2011-05-17 18:47 ` Ingo Molnar
2011-05-18 3:44 ` [PATCH 4/4 v2] " Mandeep Singh Baines
2011-05-18 8:39 ` Ingo Molnar
2011-05-18 13:51 ` Don Zickus
2011-05-23 11:13 ` [tip:perf/urgent] watchdog: Change the default timeout and " tip-bot for Mandeep Singh Baines
2011-05-24 3:58 ` [tip:perf/urgent] watchdog: Fix non-standard prototype of get_softlockup_thresh() tip-bot for Ingo Molnar
2011-05-18 13:53 ` [PATCH 1/4] watchdog: fix rounding issues in get_sample_period() Don Zickus
2011-05-19 16:26 ` Mandeep Singh Baines
2011-05-20 11:51 ` Ingo Molnar
2011-05-23 5:14 ` Mandeep Singh Baines
2011-06-09 11:47 ` Don Zickus
2011-06-09 14:51 ` Mandeep Singh Baines
2011-05-23 5:10 Mandeep Singh Baines
2011-05-23 5:10 ` [PATCH 2/4] watchdog: only disable/enable watchdog if neccessary Mandeep Singh Baines
2011-05-23 11:12 ` [tip:perf/urgent] watchdog: Only " tip-bot for Mandeep Singh Baines
2011-05-23 5:10 ` [PATCH 3/4] watchdog: disable watchdog when thresh is zero Mandeep Singh Baines
2011-05-23 5:10 ` [PATCH 4/4] watchdog: configure nmi watchdog period based on watchdog_thresh Mandeep Singh Baines
2011-05-23 11:12 ` [tip:perf/urgent] watchdog: Fix rounding bug in get_sample_period() tip-bot for Mandeep Singh Baines
2011-05-24 3:41 linux-next: build warning in Lunus' tree Stephen Rothwell
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20110519162042.GI11023@google.com \
--to=msb@chromium.org \
--cc=a.p.zijlstra@chello.nl \
--cc=akpm@linux-foundation.org \
--cc=dzickus@redhat.com \
--cc=fweisbec@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=marcin.slusarz@gmail.com \
--cc=mingo@elte.hu \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).