]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/blob - queue-4.9/kernel-hung_task.c-disable-on-suspend.patch
autosel patches for 4.9
[thirdparty/kernel/stable-queue.git] / queue-4.9 / kernel-hung_task.c-disable-on-suspend.patch
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
5
6 [ Upstream commit a1c6ca3c6de763459a6e93b644ec6518c890ba1c ]
7
8 It is possible to observe hung_task complaints when system goes to
9 suspend-to-idle state:
10
11 # echo freeze > /sys/power/state
12
13 PM: Syncing filesystems ... done.
14 Freezing user space processes ... (elapsed 0.001 seconds) done.
15 OOM killer disabled.
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
22 Call Trace:
23 ? __schedule+0x1fe/0x7e0
24 schedule+0x28/0x80
25 suspend_devices_and_enter+0x4ac/0x750
26 pm_suspend+0x2c0/0x310
27
28 Register a PM notifier to disable the detector on suspend and re-enable
29 back on wakeup.
30
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>
34 ---
35 kernel/hung_task.c | 30 +++++++++++++++++++++++++++++-
36 1 file changed, 29 insertions(+), 1 deletion(-)
37
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
42 @@ -15,6 +15,7 @@
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>
49
50 @@ -221,6 +222,28 @@ void reset_hung_task_detector(void)
51 }
52 EXPORT_SYMBOL_GPL(reset_hung_task_detector);
53
54 +static bool hung_detector_suspended;
55 +
56 +static int hungtask_pm_notify(struct notifier_block *self,
57 + unsigned long action, void *hcpu)
58 +{
59 + switch (action) {
60 + case PM_SUSPEND_PREPARE:
61 + case PM_HIBERNATION_PREPARE:
62 + case PM_RESTORE_PREPARE:
63 + hung_detector_suspended = true;
64 + break;
65 + case PM_POST_SUSPEND:
66 + case PM_POST_HIBERNATION:
67 + case PM_POST_RESTORE:
68 + hung_detector_suspended = false;
69 + break;
70 + default:
71 + break;
72 + }
73 + return NOTIFY_OK;
74 +}
75 +
76 /*
77 * kthread which checks for tasks stuck in D state
78 */
79 @@ -235,7 +258,8 @@ static int watchdog(void *dummy)
80 long t = hung_timeout_jiffies(hung_last_checked, timeout);
81
82 if (t <= 0) {
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;
88 continue;
89 @@ -249,6 +273,10 @@ static int watchdog(void *dummy)
90 static int __init hung_task_init(void)
91 {
92 atomic_notifier_chain_register(&panic_notifier_list, &panic_block);
93 +
94 + /* Disable hung task detector on suspend */
95 + pm_notifier(hungtask_pm_notify, 0);
96 +
97 watchdog_task = kthread_run(watchdog, NULL, "khungtaskd");
98
99 return 0;
100 --
101 2.19.1
102