Message ID | 20200212104902.7779-4-hauke.mehrtens@intel.com |
---|---|
State | Accepted |
Delegated to: | Hauke Mehrtens |
Headers | show |
Series | [OpenWrt-Devel,1/4] build: Add option KERNEL_UBSAN | expand |
On Wed, Feb 12, 2020 at 12:50 PM Hauke Mehrtens <hauke.mehrtens@intel.com> wrote: > > Make it possible to activate some additional kernel debug options. > This can be used to debug some problems in kernel drivers. > Reviewed-by: Alexandru Ardelean <ardeleanalex@gmail.com> > Signed-off-by: Hauke Mehrtens <hauke.mehrtens@intel.com> > --- > config/Config-kernel.in | 68 ++++++++++++++++++++++++++++++++ > target/linux/generic/config-4.14 | 5 +++ > target/linux/generic/config-4.19 | 5 +++ > 3 files changed, 78 insertions(+) > > diff --git a/config/Config-kernel.in b/config/Config-kernel.in > index 8e9e3518bf..4330d9fa5c 100644 > --- a/config/Config-kernel.in > +++ b/config/Config-kernel.in > @@ -377,6 +377,74 @@ config KERNEL_PROVE_LOCKING > select KERNEL_DEBUG_KERNEL > default n > > +config KERNEL_LOCKUP_DETECTOR > + bool "Compile the kernel with detect Hard and Soft Lockups" > + depends on KERNEL_DEBUG_KERNEL > + help > + 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 20 seconds, without giving other tasks a > + chance to run. The current stack trace is displayed upon > + detection and the system will stay locked up. > + > + Hardlockups are bugs that cause the CPU to loop in kernel mode > + for more than 10 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 4 seconds. > + An NMI is generated every 10 seconds or so to check for hardlockups. > + > + The frequency of hrtimer and NMI events and the soft and hard lockup > + thresholds can be controlled through the sysctl watchdog_thresh. > + > +config KERNEL_DETECT_HUNG_TASK > + bool "Compile the kernel with detect Hung Tasks" > + depends on KERNEL_DEBUG_KERNEL > + default KERNEL_LOCKUP_DETECTOR > + 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 indefinitely. > + > + 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 KERNEL_WQ_WATCHDOG > + bool "Compile the kernel with detect Workqueue Stalls" > + depends on KERNEL_DEBUG_KERNEL > + help > + Say Y here to enable stall detection on workqueues. If a > + worker pool doesn't make forward progress on a pending work > + item for over a given amount of time, 30s by default, a > + warning message is printed along with dump of workqueue > + state. This can be configured through kernel parameter > + "workqueue.watchdog_thresh" and its sysfs counterpart. > + > +config KERNEL_DEBUG_ATOMIC_SLEEP > + bool "Compile the kernel with sleep inside atomic section checking" > + depends on KERNEL_DEBUG_KERNEL > + help > + If you say Y here, various routines which may sleep will become very > + noisy if they are called inside atomic sections: when a spinlock is > + held, inside an rcu read side critical section, inside preempt disabled > + sections, inside an interrupt, etc... > + > +config KERNEL_DEBUG_VM > + bool "Compile the kernel with debug VM" > + depends on KERNEL_DEBUG_KERNEL > + help > + Enable this to turn on extended checks in the virtual-memory system > + that may impact performance. > + > + If unsure, say N. > + > config KERNEL_PRINTK_TIME > bool "Enable printk timestamps" > default y > diff --git a/target/linux/generic/config-4.14 b/target/linux/generic/config-4.14 > index 5a9b82db80..d1ce30d2f7 100644 > --- a/target/linux/generic/config-4.14 > +++ b/target/linux/generic/config-4.14 > @@ -594,6 +594,7 @@ CONFIG_BLOCK=y > # CONFIG_BONDING is not set > # CONFIG_BOOKE_WDT is not set > CONFIG_BOOKE_WDT_DEFAULT_TIMEOUT=3 > +# CONFIG_BOOTPARAM_HUNG_TASK_PANIC is not set > # CONFIG_BOOT_PRINTK_DELAY is not set > CONFIG_BOOT_RAW=y > CONFIG_BPF=y > @@ -1073,6 +1074,9 @@ CONFIG_DEBUG_KERNEL=y > # CONFIG_DEBUG_UART_BCM63XX is not set > # CONFIG_DEBUG_VIRTUAL is not set > # CONFIG_DEBUG_VM is not set > +# CONFIG_DEBUG_VM_PGFLAGS is not set > +# CONFIG_DEBUG_VM_RB is not set > +# CONFIG_DEBUG_VM_VMACACHE is not set > # CONFIG_DEBUG_WQ_FORCE_RR_CPU is not set > # CONFIG_DEBUG_WW_MUTEX_SLOWPATH is not set > # CONFIG_DEBUG_WX is not set > @@ -1081,6 +1085,7 @@ CONFIG_DEBUG_KERNEL=y > CONFIG_DEFAULT_CUBIC=y > CONFIG_DEFAULT_DEADLINE=y > CONFIG_DEFAULT_HOSTNAME="(none)" > +CONFIG_DEFAULT_HUNG_TASK_TIMEOUT=120 > CONFIG_DEFAULT_IOSCHED="deadline" > CONFIG_DEFAULT_MMAP_MIN_ADDR=4096 > # CONFIG_DEFAULT_NOOP is not set > diff --git a/target/linux/generic/config-4.19 b/target/linux/generic/config-4.19 > index 372cad70a6..153520c396 100644 > --- a/target/linux/generic/config-4.19 > +++ b/target/linux/generic/config-4.19 > @@ -617,6 +617,7 @@ CONFIG_BLOCK=y > # CONFIG_BONDING is not set > # CONFIG_BOOKE_WDT is not set > CONFIG_BOOKE_WDT_DEFAULT_TIMEOUT=3 > +# CONFIG_BOOTPARAM_HUNG_TASK_PANIC is not set > # CONFIG_BOOT_PRINTK_DELAY is not set > CONFIG_BOOT_RAW=y > CONFIG_BPF=y > @@ -1131,6 +1132,9 @@ CONFIG_DEBUG_KERNEL=y > # CONFIG_DEBUG_UART_BCM63XX is not set > # CONFIG_DEBUG_VIRTUAL is not set > # CONFIG_DEBUG_VM is not set > +# CONFIG_DEBUG_VM_PGFLAGS is not set > +# CONFIG_DEBUG_VM_RB is not set > +# CONFIG_DEBUG_VM_VMACACHE is not set > # CONFIG_DEBUG_WQ_FORCE_RR_CPU is not set > # CONFIG_DEBUG_WW_MUTEX_SLOWPATH is not set > # CONFIG_DEBUG_WX is not set > @@ -1139,6 +1143,7 @@ CONFIG_DEBUG_KERNEL=y > CONFIG_DEFAULT_CUBIC=y > CONFIG_DEFAULT_DEADLINE=y > CONFIG_DEFAULT_HOSTNAME="(none)" > +CONFIG_DEFAULT_HUNG_TASK_TIMEOUT=120 > CONFIG_DEFAULT_IOSCHED="deadline" > CONFIG_DEFAULT_MMAP_MIN_ADDR=4096 > # CONFIG_DEFAULT_NOOP is not set > -- > 2.17.1 > > > _______________________________________________ > openwrt-devel mailing list > openwrt-devel@lists.openwrt.org > https://lists.openwrt.org/mailman/listinfo/openwrt-devel
diff --git a/config/Config-kernel.in b/config/Config-kernel.in index 8e9e3518bf..4330d9fa5c 100644 --- a/config/Config-kernel.in +++ b/config/Config-kernel.in @@ -377,6 +377,74 @@ config KERNEL_PROVE_LOCKING select KERNEL_DEBUG_KERNEL default n +config KERNEL_LOCKUP_DETECTOR + bool "Compile the kernel with detect Hard and Soft Lockups" + depends on KERNEL_DEBUG_KERNEL + help + 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 20 seconds, without giving other tasks a + chance to run. The current stack trace is displayed upon + detection and the system will stay locked up. + + Hardlockups are bugs that cause the CPU to loop in kernel mode + for more than 10 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 4 seconds. + An NMI is generated every 10 seconds or so to check for hardlockups. + + The frequency of hrtimer and NMI events and the soft and hard lockup + thresholds can be controlled through the sysctl watchdog_thresh. + +config KERNEL_DETECT_HUNG_TASK + bool "Compile the kernel with detect Hung Tasks" + depends on KERNEL_DEBUG_KERNEL + default KERNEL_LOCKUP_DETECTOR + 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 indefinitely. + + 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 KERNEL_WQ_WATCHDOG + bool "Compile the kernel with detect Workqueue Stalls" + depends on KERNEL_DEBUG_KERNEL + help + Say Y here to enable stall detection on workqueues. If a + worker pool doesn't make forward progress on a pending work + item for over a given amount of time, 30s by default, a + warning message is printed along with dump of workqueue + state. This can be configured through kernel parameter + "workqueue.watchdog_thresh" and its sysfs counterpart. + +config KERNEL_DEBUG_ATOMIC_SLEEP + bool "Compile the kernel with sleep inside atomic section checking" + depends on KERNEL_DEBUG_KERNEL + help + If you say Y here, various routines which may sleep will become very + noisy if they are called inside atomic sections: when a spinlock is + held, inside an rcu read side critical section, inside preempt disabled + sections, inside an interrupt, etc... + +config KERNEL_DEBUG_VM + bool "Compile the kernel with debug VM" + depends on KERNEL_DEBUG_KERNEL + help + Enable this to turn on extended checks in the virtual-memory system + that may impact performance. + + If unsure, say N. + config KERNEL_PRINTK_TIME bool "Enable printk timestamps" default y diff --git a/target/linux/generic/config-4.14 b/target/linux/generic/config-4.14 index 5a9b82db80..d1ce30d2f7 100644 --- a/target/linux/generic/config-4.14 +++ b/target/linux/generic/config-4.14 @@ -594,6 +594,7 @@ CONFIG_BLOCK=y # CONFIG_BONDING is not set # CONFIG_BOOKE_WDT is not set CONFIG_BOOKE_WDT_DEFAULT_TIMEOUT=3 +# CONFIG_BOOTPARAM_HUNG_TASK_PANIC is not set # CONFIG_BOOT_PRINTK_DELAY is not set CONFIG_BOOT_RAW=y CONFIG_BPF=y @@ -1073,6 +1074,9 @@ CONFIG_DEBUG_KERNEL=y # CONFIG_DEBUG_UART_BCM63XX is not set # CONFIG_DEBUG_VIRTUAL is not set # CONFIG_DEBUG_VM is not set +# CONFIG_DEBUG_VM_PGFLAGS is not set +# CONFIG_DEBUG_VM_RB is not set +# CONFIG_DEBUG_VM_VMACACHE is not set # CONFIG_DEBUG_WQ_FORCE_RR_CPU is not set # CONFIG_DEBUG_WW_MUTEX_SLOWPATH is not set # CONFIG_DEBUG_WX is not set @@ -1081,6 +1085,7 @@ CONFIG_DEBUG_KERNEL=y CONFIG_DEFAULT_CUBIC=y CONFIG_DEFAULT_DEADLINE=y CONFIG_DEFAULT_HOSTNAME="(none)" +CONFIG_DEFAULT_HUNG_TASK_TIMEOUT=120 CONFIG_DEFAULT_IOSCHED="deadline" CONFIG_DEFAULT_MMAP_MIN_ADDR=4096 # CONFIG_DEFAULT_NOOP is not set diff --git a/target/linux/generic/config-4.19 b/target/linux/generic/config-4.19 index 372cad70a6..153520c396 100644 --- a/target/linux/generic/config-4.19 +++ b/target/linux/generic/config-4.19 @@ -617,6 +617,7 @@ CONFIG_BLOCK=y # CONFIG_BONDING is not set # CONFIG_BOOKE_WDT is not set CONFIG_BOOKE_WDT_DEFAULT_TIMEOUT=3 +# CONFIG_BOOTPARAM_HUNG_TASK_PANIC is not set # CONFIG_BOOT_PRINTK_DELAY is not set CONFIG_BOOT_RAW=y CONFIG_BPF=y @@ -1131,6 +1132,9 @@ CONFIG_DEBUG_KERNEL=y # CONFIG_DEBUG_UART_BCM63XX is not set # CONFIG_DEBUG_VIRTUAL is not set # CONFIG_DEBUG_VM is not set +# CONFIG_DEBUG_VM_PGFLAGS is not set +# CONFIG_DEBUG_VM_RB is not set +# CONFIG_DEBUG_VM_VMACACHE is not set # CONFIG_DEBUG_WQ_FORCE_RR_CPU is not set # CONFIG_DEBUG_WW_MUTEX_SLOWPATH is not set # CONFIG_DEBUG_WX is not set @@ -1139,6 +1143,7 @@ CONFIG_DEBUG_KERNEL=y CONFIG_DEFAULT_CUBIC=y CONFIG_DEFAULT_DEADLINE=y CONFIG_DEFAULT_HOSTNAME="(none)" +CONFIG_DEFAULT_HUNG_TASK_TIMEOUT=120 CONFIG_DEFAULT_IOSCHED="deadline" CONFIG_DEFAULT_MMAP_MIN_ADDR=4096 # CONFIG_DEFAULT_NOOP is not set
Make it possible to activate some additional kernel debug options. This can be used to debug some problems in kernel drivers. Signed-off-by: Hauke Mehrtens <hauke.mehrtens@intel.com> --- config/Config-kernel.in | 68 ++++++++++++++++++++++++++++++++ target/linux/generic/config-4.14 | 5 +++ target/linux/generic/config-4.19 | 5 +++ 3 files changed, 78 insertions(+)