1 From 247952e5f2aad78b1a083c465816434289beceff Mon Sep 17 00:00:00 2001
2 From: Vitaly Kuznetsov <vkuznets@redhat.com>
3 Date: Wed, 17 Oct 2018 13:23:55 +0200
4 Subject: kernel: hung_task.c: disable on suspend
6 [ Upstream commit a1c6ca3c6de763459a6e93b644ec6518c890ba1c ]
8 It is possible to observe hung_task complaints when system goes to
11 # echo freeze > /sys/power/state
13 PM: Syncing filesystems ... done.
14 Freezing user space processes ... (elapsed 0.001 seconds) done.
16 Freezing remaining freezable tasks ... (elapsed 0.002 seconds) done.
17 sd 0:0:0:0: [sda] Synchronizing SCSI cache
18 INFO: task bash:1569 blocked for more than 120 seconds.
19 Not tainted 4.19.0-rc3_+ #687
20 "echo 0 > /proc/sys/kernel/hung_task_timeout_secs" disables this message.
21 bash D 0 1569 604 0x00000000
23 ? __schedule+0x1fe/0x7e0
25 suspend_devices_and_enter+0x4ac/0x750
26 pm_suspend+0x2c0/0x310
28 Register a PM notifier to disable the detector on suspend and re-enable
31 Signed-off-by: Vitaly Kuznetsov <vkuznets@redhat.com>
32 Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
33 Signed-off-by: Sasha Levin <sashal@kernel.org>
35 kernel/hung_task.c | 30 +++++++++++++++++++++++++++++-
36 1 file changed, 29 insertions(+), 1 deletion(-)
38 diff --git a/kernel/hung_task.c b/kernel/hung_task.c
39 index fd781a468f32..fb00cf30abd1 100644
40 --- a/kernel/hung_task.c
41 +++ b/kernel/hung_task.c
43 #include <linux/lockdep.h>
44 #include <linux/export.h>
45 #include <linux/sysctl.h>
46 +#include <linux/suspend.h>
47 #include <linux/utsname.h>
48 #include <trace/events/sched.h>
50 @@ -221,6 +222,28 @@ void reset_hung_task_detector(void)
52 EXPORT_SYMBOL_GPL(reset_hung_task_detector);
54 +static bool hung_detector_suspended;
56 +static int hungtask_pm_notify(struct notifier_block *self,
57 + unsigned long action, void *hcpu)
60 + case PM_SUSPEND_PREPARE:
61 + case PM_HIBERNATION_PREPARE:
62 + case PM_RESTORE_PREPARE:
63 + hung_detector_suspended = true;
65 + case PM_POST_SUSPEND:
66 + case PM_POST_HIBERNATION:
67 + case PM_POST_RESTORE:
68 + hung_detector_suspended = false;
77 * kthread which checks for tasks stuck in D state
79 @@ -235,7 +258,8 @@ static int watchdog(void *dummy)
80 long t = hung_timeout_jiffies(hung_last_checked, timeout);
83 - if (!atomic_xchg(&reset_hung_task, 0))
84 + if (!atomic_xchg(&reset_hung_task, 0) &&
85 + !hung_detector_suspended)
86 check_hung_uninterruptible_tasks(timeout);
87 hung_last_checked = jiffies;
89 @@ -249,6 +273,10 @@ static int watchdog(void *dummy)
90 static int __init hung_task_init(void)
92 atomic_notifier_chain_register(&panic_notifier_list, &panic_block);
94 + /* Disable hung task detector on suspend */
95 + pm_notifier(hungtask_pm_notify, 0);
97 watchdog_task = kthread_run(watchdog, NULL, "khungtaskd");