hung_task

0. 简介

The hung task which are bugs that cause the task to be stuck in uninterruptible "D" state indefinitely.

1. 编译linux kernel

打开Hung Tasks detector

## based on linux 5.4 version
$ make x86_64_defconfig
$ make menuconfig
Kernel hacking  --->
    Debug Lockups and Hangs  --->
        [*] Detect Hung Tasks ## CONFIG_DETECT_HUNG_TASK
            (120) Default timeout for hung task detection (in seconds)
            [*]   Panic (Reboot) On Hung Tasks
$ make

2. 启动linux kernel

查看Hung Tasks相关属性

$ cd /proc/sys/kernel/
$ grep . hung*
hung_task_check_count:4194304   ## 检查次数
hung_task_check_interval_secs:0 ## 每隔多长时间检查一次
hung_task_panic:1               ## 当出现hung tasks后, 打印stack信息,同时是否触发panic
hung_task_timeout_secs:120      ## hung tasks后的超时时间
hung_task_warnings:10           ## 警告的次数

3. 例子

添加hung task的模拟代码

加载模块

通过分析panic stack,可知 哪一行内核源码出现hung task.

或者

Last updated

Was this helpful?