Merge branch 'perf-watchdog-for-linus' of git://git.kernel.org/pub/scm/linux/kernel...
[sfrench/cifs-2.6.git] / kernel / watchdog.c
index df5494edf694e9d2561225a1a6df74c8754eeda3..ff7fd80bef994d07730ac87de9602dc750600934 100644 (file)
@@ -42,6 +42,7 @@ static DEFINE_PER_CPU(bool, softlockup_touch_sync);
 static DEFINE_PER_CPU(bool, soft_watchdog_warn);
 static DEFINE_PER_CPU(unsigned long, hrtimer_interrupts);
 static DEFINE_PER_CPU(unsigned long, soft_lockup_hrtimer_cnt);
+static DEFINE_PER_CPU(struct task_struct *, softlockup_task_ptr_saved);
 #ifdef CONFIG_HARDLOCKUP_DETECTOR
 static DEFINE_PER_CPU(bool, hard_watchdog_warn);
 static DEFINE_PER_CPU(bool, watchdog_nmi_touch);
@@ -255,9 +256,11 @@ static void watchdog_overflow_callback(struct perf_event *event,
                        return;
 
                if (hardlockup_panic)
-                       panic("Watchdog detected hard LOCKUP on cpu %d", this_cpu);
+                       panic("Watchdog detected hard LOCKUP on cpu %d",
+                             this_cpu);
                else
-                       WARN(1, "Watchdog detected hard LOCKUP on cpu %d", this_cpu);
+                       WARN(1, "Watchdog detected hard LOCKUP on cpu %d",
+                            this_cpu);
 
                __this_cpu_write(hard_watchdog_warn, true);
                return;
@@ -326,8 +329,22 @@ static enum hrtimer_restart watchdog_timer_fn(struct hrtimer *hrtimer)
                        return HRTIMER_RESTART;
 
                /* only warn once */
-               if (__this_cpu_read(soft_watchdog_warn) == true)
+               if (__this_cpu_read(soft_watchdog_warn) == true) {
+                       /*
+                        * When multiple processes are causing softlockups the
+                        * softlockup detector only warns on the first one
+                        * because the code relies on a full quiet cycle to
+                        * re-arm.  The second process prevents the quiet cycle
+                        * and never gets reported.  Use task pointers to detect
+                        * this.
+                        */
+                       if (__this_cpu_read(softlockup_task_ptr_saved) !=
+                           current) {
+                               __this_cpu_write(soft_watchdog_warn, false);
+                               __touch_watchdog();
+                       }
                        return HRTIMER_RESTART;
+               }
 
                if (softlockup_all_cpu_backtrace) {
                        /* Prevent multiple soft-lockup reports if one cpu is already
@@ -340,9 +357,10 @@ static enum hrtimer_restart watchdog_timer_fn(struct hrtimer *hrtimer)
                        }
                }
 
-               printk(KERN_EMERG "BUG: soft lockup - CPU#%d stuck for %us! [%s:%d]\n",
+               pr_emerg("BUG: soft lockup - CPU#%d stuck for %us! [%s:%d]\n",
                        smp_processor_id(), duration,
                        current->comm, task_pid_nr(current));
+               __this_cpu_write(softlockup_task_ptr_saved, current);
                print_modules();
                print_irqtrace_events(current);
                if (regs)
@@ -361,6 +379,7 @@ static enum hrtimer_restart watchdog_timer_fn(struct hrtimer *hrtimer)
                        smp_mb__after_atomic();
                }
 
+               add_taint(TAINT_SOFTLOCKUP, LOCKDEP_STILL_OK);
                if (softlockup_panic)
                        panic("softlockup: hung tasks");
                __this_cpu_write(soft_watchdog_warn, true);
@@ -479,7 +498,7 @@ static int watchdog_nmi_enable(unsigned int cpu)
        if (PTR_ERR(event) == -EOPNOTSUPP)
                pr_info("disabled (cpu%i): not supported (no LAPIC?)\n", cpu);
        else if (PTR_ERR(event) == -ENOENT)
-               pr_warning("disabled (cpu%i): hardware events not enabled\n",
+               pr_warn("disabled (cpu%i): hardware events not enabled\n",
                         cpu);
        else
                pr_err("disabled (cpu%i): unable to create perf event: %ld\n",