diff --git a/kernel/hung_task.c b/kernel/hung_task.c index 9a24574988d23020b8fab1b483542521bf55a71a..07e8e6233596499c3f351c0d883ca2f8d950fc27 100644 --- a/kernel/hung_task.c +++ b/kernel/hung_task.c @@ -25,10 +25,14 @@ #include +#ifdef CONFIG_DFX_HUNGTASK +#include +#endif + /* * The number of tasks checked: */ -static int __read_mostly sysctl_hung_task_check_count = PID_MAX_LIMIT; +int __read_mostly sysctl_hung_task_check_count = PID_MAX_LIMIT; /* * Limit number of tasks checked in a batch. @@ -47,14 +51,16 @@ unsigned long __read_mostly sysctl_hung_task_timeout_secs = CONFIG_DEFAULT_HUNG_ /* * Zero (default value) means use sysctl_hung_task_timeout_secs: */ -static unsigned long __read_mostly sysctl_hung_task_check_interval_secs; +unsigned long __read_mostly sysctl_hung_task_check_interval_secs; -static int __read_mostly sysctl_hung_task_warnings = 10; +int __read_mostly sysctl_hung_task_warnings = 10; static int __read_mostly did_panic; +#ifndef CONFIG_DFX_HUNGTASK static bool hung_task_show_lock; static bool hung_task_call_panic; static bool hung_task_show_all_bt; +#endif static struct task_struct *watchdog_task; @@ -72,14 +78,16 @@ static unsigned int __read_mostly sysctl_hung_task_all_cpu_backtrace; * Should we panic (and reboot, if panic_timeout= is set) when a * hung task is detected: */ -static unsigned int __read_mostly sysctl_hung_task_panic = - IS_ENABLED(CONFIG_BOOTPARAM_HUNG_TASK_PANIC); +unsigned int __read_mostly sysctl_hung_task_panic = + CONFIG_BOOTPARAM_HUNG_TASK_PANIC_VALUE; static int hung_task_panic(struct notifier_block *this, unsigned long event, void *ptr) { did_panic = 1; - +#ifdef CONFIG_DFX_HUNGTASK + htbase_set_panic(did_panic); +#endif return NOTIFY_DONE; } @@ -87,6 +95,7 @@ static struct notifier_block panic_block = { .notifier_call = hung_task_panic, }; +#ifndef CONFIG_DFX_HUNGTASK static void check_hung_task(struct task_struct *t, unsigned long timeout) { unsigned long switch_count = t->nvcsw + t->nivcsw; @@ -225,6 +234,7 @@ static void check_hung_uninterruptible_tasks(unsigned long timeout) if (hung_task_call_panic) panic("hung_task: blocked tasks"); } +#endif static long hung_timeout_jiffies(unsigned long last_checked, unsigned long timeout) @@ -250,7 +260,9 @@ static int proc_dohung_task_timeout_secs(struct ctl_table *table, int write, goto out; wake_up_process(watchdog_task); - +#ifdef CONFIG_DFX_HUNGTASK + htbase_set_timeout_secs(sysctl_hung_task_timeout_secs); +#endif out: return ret; } @@ -365,7 +377,11 @@ static int watchdog(void *dummy) set_user_nice(current, 0); for ( ; ; ) { +#ifdef CONFIG_DFX_HUNGTASK + unsigned long timeout = HEARTBEAT_TIME; +#else unsigned long timeout = sysctl_hung_task_timeout_secs; +#endif unsigned long interval = sysctl_hung_task_check_interval_secs; long t; @@ -376,7 +392,11 @@ static int watchdog(void *dummy) if (t <= 0) { if (!atomic_xchg(&reset_hung_task, 0) && !hung_detector_suspended) +#ifdef CONFIG_DFX_HUNGTASK + htbase_check_tasks(timeout); +#else check_hung_uninterruptible_tasks(timeout); +#endif hung_last_checked = jiffies; continue; } @@ -388,6 +408,13 @@ static int watchdog(void *dummy) static int __init hung_task_init(void) { +#ifdef CONFIG_DFX_HUNGTASK + int ret = 0; + + ret = htbase_create_sysfs(); + if (ret) + pr_err("hungtask: create_sysfs_hungtask fail"); +#endif atomic_notifier_chain_register(&panic_notifier_list, &panic_block); /* Disable hung task detector on suspend */ diff --git a/lib/Kconfig.debug b/lib/Kconfig.debug index d2f73bb4121b0a2839d8fae83fa3e553d7d9e2a3..34672fba205a088a91b99130a4ae5cf0da2695ad 100644 --- a/lib/Kconfig.debug +++ b/lib/Kconfig.debug @@ -1188,6 +1188,13 @@ config BOOTPARAM_HUNG_TASK_PANIC Say N if unsure. +config BOOTPARAM_HUNG_TASK_PANIC_VALUE + int + depends on DETECT_HUNG_TASK + range 0 1 + default 0 if !BOOTPARAM_HUNG_TASK_PANIC + default 1 if BOOTPARAM_HUNG_TASK_PANIC + config WQ_WATCHDOG bool "Detect Workqueue Stalls" depends on DEBUG_KERNEL