softLockup_hardLockup

0. 简介

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.

example: 持有spinlock之后,在临界区花了太长时间

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.

example: 关闭本地中断太长时间

1. 编译linux kernel

打开soft lockup detector 和 hard lockup detector

## based on linux 5.4 version
$ make x86_64_defconfig
$ make menuconfig
Kernel hacking  --->
    Debug Lockups and Hangs  --->
        [*] Detect Soft Lockups                 ## CONFIG_SOFTLOCKUP_DETECTOR
        [*]   Panic (Reboot) On Soft Lockups    ## CONFIG_BOOTPARAM_SOFTLOCKUP_PANIC
        [*] Detect Hard Lockups                 ## CONFIG_HARDLOCKUP_DETECTOR
        [*]   Panic (Reboot) On Hard Lockups    ## CONFIG_BOOTPARAM_HARDLOCKUP_PANIC
$ make

2. 启动linux kernel

查看soft/hard lockup相关属性

3. 例子

例子一:添加soft lockup的模拟代码

例子二:添加hard lockup的模拟代码

Last updated

Was this helpful?