Merge branch 'perf-watchdog-for-linus' of git://git.kernel.org/pub/scm/linux/kernel...
authorLinus Torvalds <torvalds@linux-foundation.org>
Mon, 13 Oct 2014 14:10:06 +0000 (16:10 +0200)
committerLinus Torvalds <torvalds@linux-foundation.org>
Mon, 13 Oct 2014 14:10:06 +0000 (16:10 +0200)
Pull watchdog fixes from Ingo Molnar:
 "Two small watchdog subsystem fixes"

* 'perf-watchdog-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip:
  watchdog: Fix print-once on enable
  watchdog: Remove unnecessary header files

1  2 
kernel/watchdog.c

diff --combined kernel/watchdog.c
index 7b223b212683202e2e50ee83153eb8df7dbbe3de,df5494edf694e9d2561225a1a6df74c8754eeda3..ff7fd80bef994d07730ac87de9602dc750600934
  #include <linux/cpu.h>
  #include <linux/nmi.h>
  #include <linux/init.h>
- #include <linux/delay.h>
- #include <linux/freezer.h>
- #include <linux/kthread.h>
- #include <linux/lockdep.h>
- #include <linux/notifier.h>
  #include <linux/module.h>
  #include <linux/sysctl.h>
  #include <linux/smpboot.h>
@@@ -47,7 -42,6 +42,7 @@@ static DEFINE_PER_CPU(bool, softlockup_
  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);
@@@ -261,11 -255,9 +256,11 @@@ static void watchdog_overflow_callback(
                        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;
@@@ -334,22 -326,8 +329,22 @@@ static enum hrtimer_restart watchdog_ti
                        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
                        }
                }
  
 -              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)
                        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);
@@@ -503,7 -479,7 +498,7 @@@ static int watchdog_nmi_enable(unsigne
        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",
@@@ -530,7 -506,10 +525,10 @@@ static void watchdog_nmi_disable(unsign
                /* should be in cleanup, but blocks oprofile */
                perf_event_release_kernel(event);
        }
-       return;
+       if (cpu == 0) {
+               /* watchdog_nmi_enable() expects this to be zero initially. */
+               cpu0_err = 0;
+       }
  }
  #else
  static int watchdog_nmi_enable(unsigned int cpu) { return 0; }