]> www.pilppa.org Git - linux-2.6-omap-h63xx.git/commitdiff
Merge branch 'linus' into core/softlockup
authorIngo Molnar <mingo@elte.hu>
Mon, 16 Jun 2008 09:24:43 +0000 (11:24 +0200)
committerIngo Molnar <mingo@elte.hu>
Mon, 16 Jun 2008 09:24:43 +0000 (11:24 +0200)
Documentation/kernel-parameters.txt
include/linux/sched.h
kernel/softlockup.c
kernel/sysctl.c
kernel/time/tick-sched.c
lib/Kconfig.debug

index e07c432c731ff9a516fe8b23228af0fe6fa1d29a..042588fa12e5c3a2bf4657bfdf7c255bc6ac58c6 100644 (file)
@@ -1971,6 +1971,9 @@ and is between 256 and 4096 characters. It is defined in the file
 
        snd-ymfpci=     [HW,ALSA]
 
+       softlockup_panic=
+                       [KNL] Should the soft-lockup detector generate panics.
+
        sonypi.*=       [HW] Sony Programmable I/O Control Device driver
                        See Documentation/sonypi.txt
 
index c5d3f847ca8d05bd52ca575608c2d428a23d1b28..69760a379b6dc5747703cfb7c9ed818ea8ffb841 100644 (file)
@@ -294,10 +294,11 @@ extern void softlockup_tick(void);
 extern void spawn_softlockup_task(void);
 extern void touch_softlockup_watchdog(void);
 extern void touch_all_softlockup_watchdogs(void);
-extern unsigned long  softlockup_thresh;
+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)
 {
index 01b6522fd92bc0b28f7df00eb66876a389b34908..6b682d86bddf606c4342641204d673a6df3a6ff6 100644 (file)
@@ -25,7 +25,22 @@ static DEFINE_PER_CPU(unsigned long, print_timestamp);
 static DEFINE_PER_CPU(struct task_struct *, watchdog_task);
 
 static int __read_mostly did_panic;
-unsigned long __read_mostly softlockup_thresh = 60;
+int __read_mostly softlockup_thresh = 60;
+
+/*
+ * Should we panic (and reboot, if panic_timeout= is set) when a
+ * soft-lockup occurs:
+ */
+unsigned int __read_mostly softlockup_panic =
+                               CONFIG_BOOTPARAM_SOFTLOCKUP_PANIC_VALUE;
+
+static int __init softlockup_panic_setup(char *str)
+{
+       softlockup_panic = simple_strtoul(str, NULL, 0);
+
+       return 1;
+}
+__setup("softlockup_panic=", softlockup_panic_setup);
 
 static int
 softlock_panic(struct notifier_block *this, unsigned long event, void *ptr)
@@ -49,12 +64,17 @@ static unsigned long get_timestamp(int this_cpu)
        return cpu_clock(this_cpu) >> 30LL;  /* 2^30 ~= 10^9 */
 }
 
-void touch_softlockup_watchdog(void)
+static void __touch_softlockup_watchdog(void)
 {
        int this_cpu = raw_smp_processor_id();
 
        __raw_get_cpu_var(touch_timestamp) = get_timestamp(this_cpu);
 }
+
+void touch_softlockup_watchdog(void)
+{
+       __raw_get_cpu_var(touch_timestamp) = 0;
+}
 EXPORT_SYMBOL(touch_softlockup_watchdog);
 
 void touch_all_softlockup_watchdogs(void)
@@ -79,8 +99,16 @@ void softlockup_tick(void)
        struct pt_regs *regs = get_irq_regs();
        unsigned long now;
 
+       /* Is detection switched off? */
+       if (!per_cpu(watchdog_task, this_cpu) || softlockup_thresh <= 0) {
+               /* Be sure we don't false trigger if switched back on */
+               if (touch_timestamp)
+                       per_cpu(touch_timestamp, this_cpu) = 0;
+               return;
+       }
+
        if (touch_timestamp == 0) {
-               touch_softlockup_watchdog();
+               __touch_softlockup_watchdog();
                return;
        }
 
@@ -89,13 +117,13 @@ void softlockup_tick(void)
        /* report at most once a second */
        if ((print_timestamp >= touch_timestamp &&
                        print_timestamp < (touch_timestamp + 1)) ||
-                       did_panic || !per_cpu(watchdog_task, this_cpu)) {
+                       did_panic) {
                return;
        }
 
        /* do not print during early bootup: */
        if (unlikely(system_state != SYSTEM_RUNNING)) {
-               touch_softlockup_watchdog();
+               __touch_softlockup_watchdog();
                return;
        }
 
@@ -120,6 +148,9 @@ void softlockup_tick(void)
        else
                dump_stack();
        spin_unlock(&print_lock);
+
+       if (softlockup_panic)
+               panic("softlockup: hung tasks");
 }
 
 /*
@@ -172,6 +203,9 @@ static void check_hung_task(struct task_struct *t, unsigned long now)
 
        t->last_switch_timestamp = now;
        touch_nmi_watchdog();
+
+       if (softlockup_panic)
+               panic("softlockup: blocked tasks");
 }
 
 /*
@@ -214,7 +248,7 @@ static int watchdog(void *__bind_cpu)
        sched_setscheduler(current, SCHED_FIFO, &param);
 
        /* initialize timestamp */
-       touch_softlockup_watchdog();
+       __touch_softlockup_watchdog();
 
        set_current_state(TASK_INTERRUPTIBLE);
        /*
@@ -223,7 +257,7 @@ static int watchdog(void *__bind_cpu)
         * debug-printout triggers in softlockup_tick().
         */
        while (!kthread_should_stop()) {
-               touch_softlockup_watchdog();
+               __touch_softlockup_watchdog();
                schedule();
 
                if (kthread_should_stop())
index 29116652dca825943ed7cb8e70350108542ce641..a829dc8d7a9ec0d6340349c11f883fe2c785ebb5 100644 (file)
@@ -84,12 +84,13 @@ extern int latencytop_enabled;
 extern int sysctl_nr_open_min, sysctl_nr_open_max;
 
 /* Constants used for minimum and  maximum */
-#if defined(CONFIG_DETECT_SOFTLOCKUP) || defined(CONFIG_HIGHMEM)
+#if defined(CONFIG_HIGHMEM) || defined(CONFIG_DETECT_SOFTLOCKUP)
 static int one = 1;
 #endif
 
 #ifdef CONFIG_DETECT_SOFTLOCKUP
 static int sixty = 60;
+static int neg_one = -1;
 #endif
 
 #ifdef CONFIG_MMU
@@ -727,15 +728,26 @@ static struct ctl_table kern_table[] = {
        },
 #endif
 #ifdef CONFIG_DETECT_SOFTLOCKUP
+       {
+               .ctl_name       = CTL_UNNUMBERED,
+               .procname       = "softlockup_panic",
+               .data           = &softlockup_panic,
+               .maxlen         = sizeof(int),
+               .mode           = 0644,
+               .proc_handler   = &proc_doulongvec_minmax,
+               .strategy       = &sysctl_intvec,
+               .extra1         = &zero,
+               .extra2         = &one,
+       },
        {
                .ctl_name       = CTL_UNNUMBERED,
                .procname       = "softlockup_thresh",
                .data           = &softlockup_thresh,
-               .maxlen         = sizeof(unsigned long),
+               .maxlen         = sizeof(int),
                .mode           = 0644,
-               .proc_handler   = &proc_doulongvec_minmax,
+               .proc_handler   = &proc_dointvec_minmax,
                .strategy       = &sysctl_intvec,
-               .extra1         = &one,
+               .extra1         = &neg_one,
                .extra2         = &sixty,
        },
        {
index b854a895591efe4f1d40f522d079fe1de0cf256e..28abad66fc8e56ade236e07d94d08ef29534786e 100644 (file)
@@ -133,8 +133,6 @@ void tick_nohz_update_jiffies(void)
        if (!ts->tick_stopped)
                return;
 
-       touch_softlockup_watchdog();
-
        cpu_clear(cpu, nohz_cpu_mask);
        now = ktime_get();
        ts->idle_waketime = now;
@@ -142,6 +140,8 @@ void tick_nohz_update_jiffies(void)
        local_irq_save(flags);
        tick_do_update_jiffies64(now);
        local_irq_restore(flags);
+
+       touch_softlockup_watchdog();
 }
 
 void tick_nohz_stop_idle(int cpu)
index d2099f41aa1ebe46bc614c7187290f7a32dd941c..509ae35a9ef5c71371e5c86451bf59ec45953227 100644 (file)
@@ -147,7 +147,7 @@ config DETECT_SOFTLOCKUP
        help
          Say Y here to enable the kernel to detect "soft lockups",
          which are bugs that cause the kernel to loop in kernel
-         mode for more than 10 seconds, without giving other tasks a
+         mode for more than 60 seconds, without giving other tasks a
          chance to run.
 
          When a soft-lockup is detected, the kernel will print the
@@ -159,6 +159,30 @@ config DETECT_SOFTLOCKUP
           can be detected via the NMI-watchdog, on platforms that
           support it.)
 
+config BOOTPARAM_SOFTLOCKUP_PANIC
+       bool "Panic (Reboot) On Soft Lockups"
+       depends on DETECT_SOFTLOCKUP
+       help
+         Say Y here to enable the kernel to panic on "soft lockups",
+         which are bugs that cause the kernel to loop in kernel
+         mode for more than 60 seconds, without giving other tasks a
+         chance to run.
+
+         The panic can be used in combination with panic_timeout,
+         to cause the system to reboot automatically after a
+         lockup has been detected. This feature is useful for
+         high-availability systems that have uptime guarantees and
+         where a lockup must be resolved ASAP.
+
+         Say N if unsure.
+
+config BOOTPARAM_SOFTLOCKUP_PANIC_VALUE
+       int
+       depends on DETECT_SOFTLOCKUP
+       range 0 1
+       default 0 if !BOOTPARAM_SOFTLOCKUP_PANIC
+       default 1 if BOOTPARAM_SOFTLOCKUP_PANIC
+
 config SCHED_DEBUG
        bool "Collect scheduler debugging info"
        depends on DEBUG_KERNEL && PROC_FS