Unified lockup detector
Subsystems (5)
Linus,
Please pull the lockup-detector-for-linus git tree from:
git://git.kernel.org/pub/scm/linux/kernel/git/tip/linux-2.6-tip.git lockup-detector-for-linus
This tree unifies the various lockup detection facilities (kernel/softlockup.c for hung tasks and hung kernels, and arch/x86/../nmi_watchdog.c for hard lockups) into a single
entity: kernel/watchdog.c.
There's a single .config variable controlling this functionality:
Detect Hard and Soft Lockups (LOCKUP_DETECTOR) [N/y/?] (NEW)
Defaulting to off.
We thought to keep it simple to users - under X there's little sign to the user whether a particular lockup is a hard or soft one.
The lockup detector uses NMI perf events to detect hard lockups, and is thus both more compatible with perf events (they were exclusive to each other before these changes), and also more portable to other architectures.
Thanks,
Ingo
------------------>
Don Zickus (19):
x86: Move notify_die from nmi.c to traps.c
nmi_watchdog: Add new, generic implementation, using perf events
nmi_watchdog: Config option to enable new nmi_watchdog
nmi_watchdog: Use a boolean config flag for compiling
nmi_watchdog: Compile and portability fixes
nmi_watchdog: Fallback to software events when no hardware pmu detected
nmi_watchdog: support for oprofile
nmi_watchdog: Properly configure for software events
nmi_watchdog: Fix undefined 'apic' build bug
nmi_watchdog: Clean up various small details
lockup_detector: Combine nmi_watchdog and softlockup detector
lockup_detector: Touch_softlockup cleanups and softlockup_tick removal
lockup_detector: Remove old softlockup code
lockup_detector: Remove nmi_watchdog.c file
x86: Move trigger_all_cpu_backtrace to its own die_notifier
x86: Cleanup hw_nmi.c cruft
lockup_detector: Separate touch_nmi_watchdog code path from touch_watchdog
lockup_detector: Cross arch compile fixes
lockup_detector: Convert per_cpu to __get_cpu_var for readability
Frederic Weisbecker (6):
lockup_detector: Make BOOTPARAM_SOFTLOCKUP_PANIC depend on LOCKUP_DETECTOR
lockup_detector: Fix forgotten config conversion
lockup_detector: Update some config
lockup_detector: Adapt CONFIG_PERF_EVENT_NMI to other archs
lockup_detector: Introduce CONFIG_HARDLOCKUP_DETECTOR
lockup_detector: Don't enable the lockup detector by default
Ingo Molnar (4):
nmi_watchdog: Only enable on x86 for now
nmi_watchdog: Turn it off by default
watchdog: Export touch_softlockup_watchdog x86, watchdog: Fix build error in hw_nmi.c
Peter Zijlstra (1):
nmi_watchdog: Tell the world we're active
Documentation/kernel-parameters.txt | 2 + arch/Kconfig | 7 + arch/x86/Kconfig | 1 + arch/x86/include/asm/nmi.h | 2 + arch/x86/kernel/apic/Makefile | 7 +- arch/x86/kernel/apic/hw_nmi.c | 107 +++++++ arch/x86/kernel/apic/nmi.c | 7 - arch/x86/kernel/traps.c | 7 + include/linux/nmi.h | 13 + include/linux/sched.h | 12 +- kernel/Makefile | 2 +- kernel/softlockup.c | 293 ------------------ kernel/sysctl.c | 55 ++-- kernel/timer.c | 1 - kernel/watchdog.c | 567 +++++++++++++++++++++++++++++++++++ lib/Kconfig.debug | 35 ++- 16 files changed, 770 insertions(+), 348 deletions(-) create mode 100644 arch/x86/kernel/apic/hw_nmi.c delete mode 100644 kernel/softlockup.c create mode 100644 kernel/watchdog.c
Documentation/kernel-parameters.txt +2 -0
@@ -1777,6 +1777,8 @@ and is between 256 and 4096 characters. It is defined in the file nousb [USB] Disable the USB subsystem + nowatchdog [KNL] Disable the lockup detector. + nowb [ARM] nox2apic [X86-64,APIC] Do not enable x2APIC mode.
arch/Kconfig +7 -0
@@ -145,4 +145,11 @@ config HAVE_HW_BREAKPOINT config HAVE_USER_RETURN_NOTIFIER bool +config HAVE_PERF_EVENTS_NMI + bool + help + System hardware can generate an NMI using the perf event + subsystem. Also has support for calculating CPU cycle events + to determine how many clock cycles in a given period. + source "kernel/gcov/Kconfig"
arch/x86/Kconfig +1 -0
@@ -54,6 +54,7 @@ config X86 select HAVE_KERNEL_LZO select HAVE_HW_BREAKPOINT select PERF_EVENTS + select HAVE_PERF_EVENTS_NMI select ANON_INODES select HAVE_ARCH_KMEMCHECK select HAVE_USER_RETURN_NOTIFIER
arch/x86/include/asm/nmi.h +2 -0
@@ -17,7 +17,9 @@ int do_nmi_callback(struct pt_regs *regs, int cpu);extern void die_nmi (char *str,struct pt_regs *regs,int do_panic);extern int check_nmi_watchdog (void ); +#if !defined(CONFIG_LOCKUP_DETECTOR )extern int nmi_watchdog_enabled; +#endif extern int avail_to_resrv_perfctr_nmi_bit (unsigned int );extern int reserve_perfctr_nmi (unsigned int );extern void release_perfctr_nmi (unsigned int );
arch/x86/kernel/apic/Makefile +6 -1
@@ -2,7 +2,12 @@ # Makefile for local APIC drivers and for the IO-APIC code # -obj-$(CONFIG_X86_LOCAL_APIC) += apic.o apic_noop.o probe_$(BITS).o ipi.o nmi.o +obj-$(CONFIG_X86_LOCAL_APIC) += apic.o apic_noop.o probe_$(BITS).o ipi.o +ifneq ($(CONFIG_HARDLOCKUP_DETECTOR),y) +obj-$(CONFIG_X86_LOCAL_APIC) += nmi.o +endif +obj-$(CONFIG_HARDLOCKUP_DETECTOR) += hw_nmi.o + obj-$(CONFIG_X86_IO_APIC) += io_apic.o obj-$(CONFIG_SMP) += ipi.o
arch/x86/kernel/apic/hw_nmi.c new file +107 -0
107 lines not on this page · raw message
arch/x86/kernel/apic/nmi.c +0 -7
@@ -401,13 +401,6 @@ nmi_watchdog_tick(struct pt_regs *regs, unsigned reason)int cpu =smp_processor_id ();int rc =0 ; -/* check for other users first */ -if (notify_die (DIE_NMI ,"nmi" , regs, reason,2 ,SIGINT ) - ==NOTIFY_STOP ) { - rc =1 ; - touched =1 ; - } - sum =get_timer_irqs (cpu);if (__get_cpu_var (nmi_touch)) {
arch/x86/kernel/traps.c +7 -0
@@ -400,7 +400,13 @@ static notrace __kprobes void default_do_nmi(struct pt_regs *regs)if (notify_die (DIE_NMI_IPI ,"nmi_ipi" , regs, reason,2 ,SIGINT ) ==NOTIFY_STOP )return ; +#ifdef CONFIG_X86_LOCAL_APIC +if (notify_die (DIE_NMI ,"nmi" , regs, reason,2 ,SIGINT ) + ==NOTIFY_STOP ) +return ; + +#ifndef CONFIG_LOCKUP_DETECTOR /* * Ok, so this is none of the documented NMI sources, * so it must be the NMI watchdog.
@@ -408,6 +414,7 @@ static notrace __kprobes void default_do_nmi(struct pt_regs *regs)if (nmi_watchdog_tick (regs, reason))return ; if (!do_nmi_callback(regs, cpu)) +#endif /* !CONFIG_LOCKUP_DETECTOR */ unknown_nmi_error (reason, regs);#else unknown_nmi_error (reason, regs);
include/linux/nmi.h +13 -0
@@ -20,10 +20,14 @@ extern void touch_nmi_watchdog(void);extern void acpi_nmi_disable (void );extern void acpi_nmi_enable (void );#else +#ifndef CONFIG_HARDLOCKUP_DETECTOR static inline void touch_nmi_watchdog (void ) {touch_softlockup_watchdog (); } +#else +extern void touch_nmi_watchdog (void ); +#endif static inline void acpi_nmi_disable (void ) { }static inline void acpi_nmi_enable (void ) { }#endif
@@ -47,4 +51,13 @@ static inline bool trigger_all_cpu_backtrace(void) }#endif +#ifdef CONFIG_LOCKUP_DETECTOR +int hw_nmi_is_cpu_stuck (struct pt_regs *); +u64 hw_nmi_get_sample_period (void ); +extern int watchdog_enabled; +struct ctl_table ; +extern int proc_dowatchdog_enabled (struct ctl_table *,int , +void __user *,size_t *,loff_t *); +#endif +#endif
include/linux/sched.h +4 -8
@@ -311,20 +311,16 @@ extern void scheduler_tick(void);extern void sched_show_task (struct task_struct *p); -#ifdef CONFIG_DETECT_SOFTLOCKUP -extern void softlockup_tick (void ); +#ifdef CONFIG_LOCKUP_DETECTOR extern void touch_softlockup_watchdog (void );extern void touch_softlockup_watchdog_sync (void );extern void touch_all_softlockup_watchdogs (void ); -extern int proc_dosoftlockup_thresh (struct ctl_table *table,int write, -void __user *buffer, -size_t *lenp,loff_t *ppos); +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;#else -static inline void softlockup_tick (void ) -{ -}static inline void touch_softlockup_watchdog (void ) { }
kernel/Makefile +1 -1
@@ -76,8 +76,8 @@ obj-$(CONFIG_GCOV_KERNEL) += gcov/ 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_LOCKUP_DETECTOR) += watchdog.o obj-$(CONFIG_GENERIC_HARDIRQS) += irq/ obj-$(CONFIG_SECCOMP) += seccomp.o obj-$(CONFIG_RCU_TORTURE_TEST) += rcutorture.o
kernel/softlockup.c deleted +0 -293
293 lines not on this page · raw message
kernel/sysctl.c +33 -22
79 lines not on this page · raw message
kernel/timer.c +0 -1
@@ -1225,7 +1225,6 @@ void run_local_timers(void) {hrtimer_run_queues ();raise_softirq (TIMER_SOFTIRQ ); -softlockup_tick (); }/*
kernel/watchdog.c new file +567 -0
567 lines not on this page · raw message
lib/Kconfig.debug +20 -15
@@ -152,28 +152,33 @@ config DEBUG_SHIRQ Drivers ought to be able to handle interrupts coming in at those points; some don't and need to be caught. -config DETECT_SOFTLOCKUP - bool "Detect Soft Lockups" +config LOCKUP_DETECTOR + bool "Detect Hard and Soft Lockups" depends on DEBUG_KERNEL && !S390 - default y help - Say Y here to enable the kernel to detect "soft lockups", - which are bugs that cause the kernel to loop in kernel + Say Y here to enable the kernel to act as a watchdog to detect + hard and soft lockups. + + Softlockups are bugs that cause the kernel to loop in kernel mode for more than 60 seconds, without giving other tasks a - chance to run. + chance to run. The current stack trace is displayed upon + detection and the system will stay locked up. - When a soft-lockup is detected, the kernel will print the - current stack trace (which you should report), but the - system will stay locked up. This feature has negligible - overhead. + Hardlockups are bugs that cause the CPU to loop in kernel mode + for more than 60 seconds, without letting other interrupts have a + chance to run. The current stack trace is displayed upon detection + and the system will stay locked up. + + The overhead should be minimal. A periodic hrtimer runs to + generate interrupts and kick the watchdog task every 10-12 seconds. + An NMI is generated every 60 seconds or so to check for hardlockups. - (Note that "hard lockups" are separate type of bugs that - can be detected via the NMI-watchdog, on platforms that - support it.) +config HARDLOCKUP_DETECTOR + def_bool LOCKUP_DETECTOR && PERF_EVENTS && HAVE_PERF_EVENTS_NMI config BOOTPARAM_SOFTLOCKUP_PANIC bool "Panic (Reboot) On Soft Lockups" - depends on DETECT_SOFTLOCKUP + depends on LOCKUP_DETECTOR help Say Y here to enable the kernel to panic on "soft lockups", which are bugs that cause the kernel to loop in kernel
@@ -190,7 +195,7 @@ config BOOTPARAM_SOFTLOCKUP_PANIC config BOOTPARAM_SOFTLOCKUP_PANIC_VALUE int - depends on DETECT_SOFTLOCKUP + depends on LOCKUP_DETECTOR range 0 1 default 0 if !BOOTPARAM_SOFTLOCKUP_PANIC default 1 if BOOTPARAM_SOFTLOCKUP_PANIC