softlockup detector updates for v2.6.30
Subsystems (6)
Linus,
Please pull the latest softlockup-for-linus git tree from:
git://git.kernel.org/pub/scm/linux/kernel/git/tip/linux-2.6-tip.git softlockup-for-linus
Note: CONFIG_DETECT_HUNG_TASK defaults to Y here, because that was its previous (implict) default from the softlockup watchdog. Should this default to N perhaps?
Thanks,
Ingo
------------------>
Frederic Weisbecker (1):
softlockup: ensure the task has been switched out once
Ingo Molnar (1):
softlockup: move 'one' to the softlockup section in sysctl.c
Mandeep Singh Baines (7):
softlockup: decouple hung tasks check from softlockup detection
softlockup: fix to allow compiling with !DETECT_HUNG_TASK
softlockup: fix potential race in hung_task when resetting timeout
softlockup: remove unused definition for spawn_softlockup_task
softlockup: check all tasks in hung_task
softlockup: convert read_lock in hung_task to rcu_read_lock
softlockup: remove timestamp checking from hung_task
include/linux/sched.h | 18 +++-- kernel/Makefile | 1 + kernel/fork.c | 8 +- kernel/hung_task.c | 217 +++++++++++++++++++++++++++++++++++++++++++++++++ kernel/softlockup.c | 100 ----------------------- kernel/sysctl.c | 19 ++++- lib/Kconfig.debug | 38 +++++++++ 7 files changed, 286 insertions(+), 115 deletions(-) create mode 100644 kernel/hung_task.c
include/linux/sched.h +10 -8
@@ -297,17 +297,11 @@ extern int proc_dosoftlockup_thresh(struct ctl_table *table, int write, struct file *filp, void __user *buffer, size_t *lenp, loff_t *ppos);extern unsigned int softlockup_panic; -extern unsigned long sysctl_hung_task_check_count; -extern unsigned long sysctl_hung_task_timeout_secs; -extern unsigned long sysctl_hung_task_warnings;extern int softlockup_thresh;#else static inline void softlockup_tick (void ) { } -static inline void spawn_softlockup_task (void ) -{ -}static inline void touch_softlockup_watchdog (void ) { }
@@ -316,6 +310,15 @@ static inline void touch_all_softlockup_watchdogs(void) }#endif +#ifdef CONFIG_DETECT_HUNG_TASK +extern unsigned int sysctl_hung_task_panic; +extern unsigned long sysctl_hung_task_check_count; +extern unsigned long sysctl_hung_task_timeout_secs; +extern unsigned long sysctl_hung_task_warnings; +extern int proc_dohung_task_timeout_secs (struct ctl_table *table,int write, +struct file *filp,void __user *buffer, +size_t *lenp,loff_t *ppos); +#endif /* Attach to any functions which should be ignored in wchan output. */ #define __sched __attribute__((__section__(".sched.text")))
@@ -1260,9 +1263,8 @@ struct task_struct {/* ipc stuff */ struct sysv_sem sysvsem;#endif -#ifdef CONFIG_DETECT_SOFTLOCKUP +#ifdef CONFIG_DETECT_HUNG_TASK /* hung task detection */ -unsigned long last_switch_timestamp;unsigned long last_switch_count;#endif /* CPU-specific state of this task */
kernel/Makefile +1 -0
@@ -74,6 +74,7 @@ obj-$(CONFIG_AUDIT_TREE) += audit_tree.o obj-$(CONFIG_KPROBES) += kprobes.o obj-$(CONFIG_KGDB) += kgdb.o obj-$(CONFIG_DETECT_SOFTLOCKUP) += softlockup.o +obj-$(CONFIG_DETECT_HUNG_TASK) += hung_task.o obj-$(CONFIG_GENERIC_HARDIRQS) += irq/ obj-$(CONFIG_SECCOMP) += seccomp.o obj-$(CONFIG_RCU_TORTURE_TEST) += rcutorture.o
kernel/fork.c +3 -5
@@ -644,6 +644,9 @@ static int copy_mm(unsigned long clone_flags, struct task_struct * tsk) tsk->min_flt = tsk->maj_flt =0 ; tsk->nvcsw = tsk->nivcsw =0 ; +#ifdef CONFIG_DETECT_HUNG_TASK + tsk->last_switch_count = tsk->nvcsw + tsk->nivcsw; +#endif tsk->mm =NULL ; tsk->active_mm =NULL ;
@@ -1046,11 +1049,6 @@ static struct task_struct *copy_process(unsigned long clone_flags, p->default_timer_slack_ns = current->timer_slack_ns; -#ifdef CONFIG_DETECT_SOFTLOCKUP - p->last_switch_count =0 ; - p->last_switch_timestamp =0 ; -#endif -task_io_accounting_init (&p->ioac);acct_clear_integrals (p);
kernel/hung_task.c new file +217 -0
217 lines not on this page · raw message
kernel/softlockup.c +0 -100
126 lines not on this page · raw message
kernel/sysctl.c +17 -2
@@ -90,6 +90,9 @@ extern int rcutorture_runnable;#endif /* #ifdef CONFIG_RCU_TORTURE_TEST */ /* Constants used for minimum and maximum */ +#if defined(CONFIG_DETECT_HUNG_TASK ) || defined(CONFIG_DETECT_SOFTLOCKUP ) || defined(CONFIG_HIGHMEM ) +static int one =1 ; +#endif #ifdef CONFIG_DETECT_SOFTLOCKUP static int sixty =60 ;static int neg_one =-1 ;
@@ -100,7 +103,6 @@ static int two = 2;#endif static int zero; -static int one =1 ;static unsigned long one_ul =1 ;static int one_hundred =100 ;
@@ -815,6 +817,19 @@ static struct ctl_table kern_table[] = { .extra1 = &neg_one, .extra2 = &sixty, }, +#endif +#ifdef CONFIG_DETECT_HUNG_TASK + { + .ctl_name = CTL_UNNUMBERED, + .procname = "hung_task_panic", + .data = &sysctl_hung_task_panic, + .maxlen = sizeof(int), + .mode = 0644, + .proc_handler = &proc_dointvec_minmax, + .strategy = &sysctl_intvec, + .extra1 = &zero, + .extra2 = &one, + }, { .ctl_name = CTL_UNNUMBERED, .procname = "hung_task_check_count",
@@ -830,7 +845,7 @@ static struct ctl_table kern_table[] = { .data = &sysctl_hung_task_timeout_secs, .maxlen = sizeof(unsigned long), .mode = 0644, - .proc_handler = &proc_doulongvec_minmax, + .proc_handler = &proc_dohung_task_timeout_secs, .strategy = &sysctl_intvec, }, {
lib/Kconfig.debug +38 -0
@@ -186,6 +186,44 @@ config BOOTPARAM_SOFTLOCKUP_PANIC_VALUE default 0 if !BOOTPARAM_SOFTLOCKUP_PANIC default 1 if BOOTPARAM_SOFTLOCKUP_PANIC +config DETECT_HUNG_TASK + bool "Detect Hung Tasks" + depends on DEBUG_KERNEL + default y + help + Say Y here to enable the kernel to detect "hung tasks", + which are bugs that cause the task to be stuck in + uninterruptible "D" state indefinitiley. + + When a hung task is detected, the kernel will print the + current stack trace (which you should report), but the + task will stay in uninterruptible state. If lockdep is + enabled then all held locks will also be reported. This + feature has negligible overhead. + +config BOOTPARAM_HUNG_TASK_PANIC + bool "Panic (Reboot) On Hung Tasks" + depends on DETECT_HUNG_TASK + help + Say Y here to enable the kernel to panic on "hung tasks", + which are bugs that cause the kernel to leave a task stuck + in uninterruptible "D" state. + + The panic can be used in combination with panic_timeout, + to cause the system to reboot automatically after a + hung task has been detected. This feature is useful for + high-availability systems that have uptime guarantees and + where a hung tasks must be resolved ASAP. + + Say N if unsure. + +config BOOTPARAM_HUNG_TASK_PANIC_VALUE + int + depends on DETECT_HUNG_TASK + range 0 1 + default 0 if !BOOTPARAM_HUNG_TASK_PANIC + default 1 if BOOTPARAM_HUNG_TASK_PANIC + config SCHED_DEBUG bool "Collect scheduler debugging info" depends on DEBUG_KERNEL && PROC_FS