Greg Kroah-Hartman | b244131 | 2017-11-01 15:07:57 +0100 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2 | /* |
Zhen Lei | 0346688 | 2021-06-08 15:44:37 +0800 | [diff] [blame] | 3 | * drivers/power/process.c - Functions for starting/stopping processes on |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4 | * suspend transitions. |
| 5 | * |
| 6 | * Originally from swsusp. |
| 7 | */ |
| 8 | |
| 9 | |
| 10 | #undef DEBUG |
| 11 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 12 | #include <linux/interrupt.h> |
Alexey Dobriyan | 1a8670a | 2009-09-21 17:03:09 -0700 | [diff] [blame] | 13 | #include <linux/oom.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 14 | #include <linux/suspend.h> |
| 15 | #include <linux/module.h> |
Ingo Molnar | b17b015 | 2017-02-08 18:51:35 +0100 | [diff] [blame] | 16 | #include <linux/sched/debug.h> |
Ingo Molnar | 2993002 | 2017-02-08 18:51:36 +0100 | [diff] [blame] | 17 | #include <linux/sched/task.h> |
Rafael J. Wysocki | 02aaeb9 | 2006-03-23 03:00:04 -0800 | [diff] [blame] | 18 | #include <linux/syscalls.h> |
Nigel Cunningham | 7dfb710 | 2006-12-06 20:34:23 -0800 | [diff] [blame] | 19 | #include <linux/freezer.h> |
Tejun Heo | be404f0 | 2009-10-08 22:47:30 +0200 | [diff] [blame] | 20 | #include <linux/delay.h> |
Tejun Heo | a0a1a5f | 2010-06-29 10:07:12 +0200 | [diff] [blame] | 21 | #include <linux/workqueue.h> |
Rafael J. Wysocki | 1e73203 | 2012-03-28 23:30:21 +0200 | [diff] [blame] | 22 | #include <linux/kmod.h> |
Todd E Brandt | bb3632c | 2014-06-06 05:40:17 -0700 | [diff] [blame] | 23 | #include <trace/events/power.h> |
Peter Zijlstra | 50e7663 | 2017-09-07 11:13:38 +0200 | [diff] [blame] | 24 | #include <linux/cpuset.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 25 | |
Peter Zijlstra | 50e7663 | 2017-09-07 11:13:38 +0200 | [diff] [blame] | 26 | /* |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 27 | * Timeout for stopping processes |
| 28 | */ |
Li Fei | 957d128 | 2013-02-01 08:56:03 +0000 | [diff] [blame] | 29 | unsigned int __read_mostly freeze_timeout_msecs = 20 * MSEC_PER_SEC; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 30 | |
Tejun Heo | 839e340 | 2011-11-21 12:32:26 -0800 | [diff] [blame] | 31 | static int try_to_freeze_tasks(bool user_only) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 32 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 33 | struct task_struct *g, *p; |
Rafael J. Wysocki | 11b2ce2 | 2006-12-06 20:34:40 -0800 | [diff] [blame] | 34 | unsigned long end_time; |
| 35 | unsigned int todo; |
Tejun Heo | a0a1a5f | 2010-06-29 10:07:12 +0200 | [diff] [blame] | 36 | bool wq_busy = false; |
Abhilash Jindal | f7b382b | 2016-01-31 14:29:01 -0500 | [diff] [blame] | 37 | ktime_t start, end, elapsed; |
Colin Cross | 18ad0c6 | 2013-05-06 23:50:10 +0000 | [diff] [blame] | 38 | unsigned int elapsed_msecs; |
Rafael J. Wysocki | dbeeec5 | 2010-10-04 22:07:32 +0200 | [diff] [blame] | 39 | bool wakeup = false; |
Colin Cross | 18ad0c6 | 2013-05-06 23:50:10 +0000 | [diff] [blame] | 40 | int sleep_usecs = USEC_PER_MSEC; |
Rafael J. Wysocki | 438e2ce | 2007-10-18 03:04:49 -0700 | [diff] [blame] | 41 | |
Abhilash Jindal | f7b382b | 2016-01-31 14:29:01 -0500 | [diff] [blame] | 42 | start = ktime_get_boottime(); |
Christoph Lameter | 3e1d1d2 | 2005-06-24 23:13:50 -0700 | [diff] [blame] | 43 | |
Li Fei | 957d128 | 2013-02-01 08:56:03 +0000 | [diff] [blame] | 44 | end_time = jiffies + msecs_to_jiffies(freeze_timeout_msecs); |
Tejun Heo | a0a1a5f | 2010-06-29 10:07:12 +0200 | [diff] [blame] | 45 | |
Tejun Heo | 839e340 | 2011-11-21 12:32:26 -0800 | [diff] [blame] | 46 | if (!user_only) |
Tejun Heo | a0a1a5f | 2010-06-29 10:07:12 +0200 | [diff] [blame] | 47 | freeze_workqueues_begin(); |
| 48 | |
Tejun Heo | be404f0 | 2009-10-08 22:47:30 +0200 | [diff] [blame] | 49 | while (true) { |
Rafael J. Wysocki | 11b2ce2 | 2006-12-06 20:34:40 -0800 | [diff] [blame] | 50 | todo = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 51 | read_lock(&tasklist_lock); |
Michal Hocko | a28e785 | 2014-10-21 09:27:15 +0200 | [diff] [blame] | 52 | for_each_process_thread(g, p) { |
Tejun Heo | 839e340 | 2011-11-21 12:32:26 -0800 | [diff] [blame] | 53 | if (p == current || !freeze_task(p)) |
Rafael J. Wysocki | d5d8c59 | 2007-10-18 03:04:46 -0700 | [diff] [blame] | 54 | continue; |
| 55 | |
Oleg Nesterov | 5d8f72b | 2012-10-26 19:46:06 +0200 | [diff] [blame] | 56 | if (!freezer_should_skip(p)) |
Rafael J. Wysocki | ba96a0c | 2007-05-23 13:57:25 -0700 | [diff] [blame] | 57 | todo++; |
Michal Hocko | a28e785 | 2014-10-21 09:27:15 +0200 | [diff] [blame] | 58 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 59 | read_unlock(&tasklist_lock); |
Tejun Heo | a0a1a5f | 2010-06-29 10:07:12 +0200 | [diff] [blame] | 60 | |
Tejun Heo | 839e340 | 2011-11-21 12:32:26 -0800 | [diff] [blame] | 61 | if (!user_only) { |
Tejun Heo | a0a1a5f | 2010-06-29 10:07:12 +0200 | [diff] [blame] | 62 | wq_busy = freeze_workqueues_busy(); |
| 63 | todo += wq_busy; |
| 64 | } |
| 65 | |
Tejun Heo | be404f0 | 2009-10-08 22:47:30 +0200 | [diff] [blame] | 66 | if (!todo || time_after(jiffies, end_time)) |
Rafael J. Wysocki | 02aaeb9 | 2006-03-23 03:00:04 -0800 | [diff] [blame] | 67 | break; |
Tejun Heo | be404f0 | 2009-10-08 22:47:30 +0200 | [diff] [blame] | 68 | |
Rafael J. Wysocki | a2867e0 | 2010-12-03 22:58:31 +0100 | [diff] [blame] | 69 | if (pm_wakeup_pending()) { |
Rafael J. Wysocki | dbeeec5 | 2010-10-04 22:07:32 +0200 | [diff] [blame] | 70 | wakeup = true; |
| 71 | break; |
| 72 | } |
| 73 | |
Tejun Heo | be404f0 | 2009-10-08 22:47:30 +0200 | [diff] [blame] | 74 | /* |
| 75 | * We need to retry, but first give the freezing tasks some |
Colin Cross | 18ad0c6 | 2013-05-06 23:50:10 +0000 | [diff] [blame] | 76 | * time to enter the refrigerator. Start with an initial |
| 77 | * 1 ms sleep followed by exponential backoff until 8 ms. |
Tejun Heo | be404f0 | 2009-10-08 22:47:30 +0200 | [diff] [blame] | 78 | */ |
Colin Cross | 18ad0c6 | 2013-05-06 23:50:10 +0000 | [diff] [blame] | 79 | usleep_range(sleep_usecs / 2, sleep_usecs); |
| 80 | if (sleep_usecs < 8 * USEC_PER_MSEC) |
| 81 | sleep_usecs *= 2; |
Tejun Heo | be404f0 | 2009-10-08 22:47:30 +0200 | [diff] [blame] | 82 | } |
Christoph Lameter | 3e1d1d2 | 2005-06-24 23:13:50 -0700 | [diff] [blame] | 83 | |
Abhilash Jindal | f7b382b | 2016-01-31 14:29:01 -0500 | [diff] [blame] | 84 | end = ktime_get_boottime(); |
| 85 | elapsed = ktime_sub(end, start); |
| 86 | elapsed_msecs = ktime_to_ms(elapsed); |
Rafael J. Wysocki | 438e2ce | 2007-10-18 03:04:49 -0700 | [diff] [blame] | 87 | |
Pavel Machek | 6161b2c | 2005-09-03 15:57:05 -0700 | [diff] [blame] | 88 | if (todo) { |
Michal Hocko | 35536ae | 2015-02-11 15:26:18 -0800 | [diff] [blame] | 89 | pr_cont("\n"); |
| 90 | pr_err("Freezing of tasks %s after %d.%03d seconds " |
Tejun Heo | a0a1a5f | 2010-06-29 10:07:12 +0200 | [diff] [blame] | 91 | "(%d tasks refusing to freeze, wq_busy=%d):\n", |
Rafael J. Wysocki | dbeeec5 | 2010-10-04 22:07:32 +0200 | [diff] [blame] | 92 | wakeup ? "aborted" : "failed", |
Colin Cross | 18ad0c6 | 2013-05-06 23:50:10 +0000 | [diff] [blame] | 93 | elapsed_msecs / 1000, elapsed_msecs % 1000, |
Tejun Heo | a0a1a5f | 2010-06-29 10:07:12 +0200 | [diff] [blame] | 94 | todo - wq_busy, wq_busy); |
| 95 | |
Roger Lu | 7b776af | 2016-07-01 11:05:02 +0800 | [diff] [blame] | 96 | if (wq_busy) |
Imran Khan | 55df093 | 2021-10-20 14:09:00 +1100 | [diff] [blame] | 97 | show_all_workqueues(); |
Roger Lu | 7b776af | 2016-07-01 11:05:02 +0800 | [diff] [blame] | 98 | |
Todd Brandt | 8412dbd | 2018-08-22 18:37:11 -0700 | [diff] [blame] | 99 | if (!wakeup || pm_debug_messages_on) { |
Rafael J. Wysocki | 6c83b48 | 2012-02-11 00:00:34 +0100 | [diff] [blame] | 100 | read_lock(&tasklist_lock); |
Michal Hocko | a28e785 | 2014-10-21 09:27:15 +0200 | [diff] [blame] | 101 | for_each_process_thread(g, p) { |
Rafael J. Wysocki | 6c83b48 | 2012-02-11 00:00:34 +0100 | [diff] [blame] | 102 | if (p != current && !freezer_should_skip(p) |
| 103 | && freezing(p) && !frozen(p)) |
| 104 | sched_show_task(p); |
Michal Hocko | a28e785 | 2014-10-21 09:27:15 +0200 | [diff] [blame] | 105 | } |
Rafael J. Wysocki | 6c83b48 | 2012-02-11 00:00:34 +0100 | [diff] [blame] | 106 | read_unlock(&tasklist_lock); |
| 107 | } |
Rafael J. Wysocki | 438e2ce | 2007-10-18 03:04:49 -0700 | [diff] [blame] | 108 | } else { |
Michal Hocko | 35536ae | 2015-02-11 15:26:18 -0800 | [diff] [blame] | 109 | pr_cont("(elapsed %d.%03d seconds) ", elapsed_msecs / 1000, |
Colin Cross | 18ad0c6 | 2013-05-06 23:50:10 +0000 | [diff] [blame] | 110 | elapsed_msecs % 1000); |
Pavel Machek | 6161b2c | 2005-09-03 15:57:05 -0700 | [diff] [blame] | 111 | } |
| 112 | |
Rafael J. Wysocki | e7cd8a7 | 2007-07-19 01:47:34 -0700 | [diff] [blame] | 113 | return todo ? -EBUSY : 0; |
Rafael J. Wysocki | 11b2ce2 | 2006-12-06 20:34:40 -0800 | [diff] [blame] | 114 | } |
| 115 | |
| 116 | /** |
Rafael J. Wysocki | 2aede85 | 2011-09-26 20:32:27 +0200 | [diff] [blame] | 117 | * freeze_processes - Signal user space processes to enter the refrigerator. |
Colin Cross | 2b44c4d | 2013-07-24 17:41:33 -0700 | [diff] [blame] | 118 | * The current thread will not be frozen. The same process that calls |
| 119 | * freeze_processes must later call thaw_processes. |
Tejun Heo | 03afed8 | 2011-11-21 12:32:24 -0800 | [diff] [blame] | 120 | * |
| 121 | * On success, returns 0. On failure, -errno and system is fully thawed. |
Rafael J. Wysocki | 11b2ce2 | 2006-12-06 20:34:40 -0800 | [diff] [blame] | 122 | */ |
| 123 | int freeze_processes(void) |
| 124 | { |
Rafael J. Wysocki | e7cd8a7 | 2007-07-19 01:47:34 -0700 | [diff] [blame] | 125 | int error; |
Rafael J. Wysocki | 11b2ce2 | 2006-12-06 20:34:40 -0800 | [diff] [blame] | 126 | |
Rafael J. Wysocki | 247bc03 | 2012-03-28 23:30:28 +0200 | [diff] [blame] | 127 | error = __usermodehelper_disable(UMH_FREEZING); |
Rafael J. Wysocki | 1e73203 | 2012-03-28 23:30:21 +0200 | [diff] [blame] | 128 | if (error) |
| 129 | return error; |
| 130 | |
Colin Cross | 2b44c4d | 2013-07-24 17:41:33 -0700 | [diff] [blame] | 131 | /* Make sure this task doesn't get frozen */ |
| 132 | current->flags |= PF_SUSPEND_TASK; |
| 133 | |
Tejun Heo | a320122 | 2011-11-21 12:32:25 -0800 | [diff] [blame] | 134 | if (!pm_freezing) |
| 135 | atomic_inc(&system_freezing_cnt); |
| 136 | |
Rafael J. Wysocki | cb1f65c | 2022-02-04 18:35:22 +0100 | [diff] [blame] | 137 | pm_wakeup_clear(0); |
Michal Hocko | 35536ae | 2015-02-11 15:26:18 -0800 | [diff] [blame] | 138 | pr_info("Freezing user space processes ... "); |
Tejun Heo | a320122 | 2011-11-21 12:32:25 -0800 | [diff] [blame] | 139 | pm_freezing = true; |
Rafael J. Wysocki | ebb12db | 2008-06-11 22:04:29 +0200 | [diff] [blame] | 140 | error = try_to_freeze_tasks(true); |
Rafael J. Wysocki | 2aede85 | 2011-09-26 20:32:27 +0200 | [diff] [blame] | 141 | if (!error) { |
Rafael J. Wysocki | 247bc03 | 2012-03-28 23:30:28 +0200 | [diff] [blame] | 142 | __usermodehelper_set_disable_depth(UMH_DISABLED); |
Michal Hocko | c32b3cb | 2015-02-11 15:26:24 -0800 | [diff] [blame] | 143 | pr_cont("done."); |
Rafael J. Wysocki | 2aede85 | 2011-09-26 20:32:27 +0200 | [diff] [blame] | 144 | } |
Michal Hocko | 35536ae | 2015-02-11 15:26:18 -0800 | [diff] [blame] | 145 | pr_cont("\n"); |
Rafael J. Wysocki | 2aede85 | 2011-09-26 20:32:27 +0200 | [diff] [blame] | 146 | BUG_ON(in_atomic()); |
| 147 | |
Michal Hocko | c32b3cb | 2015-02-11 15:26:24 -0800 | [diff] [blame] | 148 | /* |
Jackie Zamow | 4d4ce80 | 2020-10-27 07:43:19 -0500 | [diff] [blame] | 149 | * Now that the whole userspace is frozen we need to disable |
Michal Hocko | c32b3cb | 2015-02-11 15:26:24 -0800 | [diff] [blame] | 150 | * the OOM killer to disallow any further interference with |
Michal Hocko | 7d2e7a2 | 2016-10-07 16:59:00 -0700 | [diff] [blame] | 151 | * killable tasks. There is no guarantee oom victims will |
| 152 | * ever reach a point they go away we have to wait with a timeout. |
Michal Hocko | c32b3cb | 2015-02-11 15:26:24 -0800 | [diff] [blame] | 153 | */ |
Michal Hocko | 7d2e7a2 | 2016-10-07 16:59:00 -0700 | [diff] [blame] | 154 | if (!error && !oom_killer_disable(msecs_to_jiffies(freeze_timeout_msecs))) |
Michal Hocko | c32b3cb | 2015-02-11 15:26:24 -0800 | [diff] [blame] | 155 | error = -EBUSY; |
| 156 | |
Tejun Heo | 03afed8 | 2011-11-21 12:32:24 -0800 | [diff] [blame] | 157 | if (error) |
| 158 | thaw_processes(); |
Rafael J. Wysocki | 2aede85 | 2011-09-26 20:32:27 +0200 | [diff] [blame] | 159 | return error; |
| 160 | } |
| 161 | |
| 162 | /** |
| 163 | * freeze_kernel_threads - Make freezable kernel threads go to the refrigerator. |
Tejun Heo | 03afed8 | 2011-11-21 12:32:24 -0800 | [diff] [blame] | 164 | * |
Srivatsa S. Bhat | 379e0be | 2012-02-03 22:22:41 +0100 | [diff] [blame] | 165 | * On success, returns 0. On failure, -errno and only the kernel threads are |
| 166 | * thawed, so as to give a chance to the caller to do additional cleanups |
| 167 | * (if any) before thawing the userspace tasks. So, it is the responsibility |
| 168 | * of the caller to thaw the userspace tasks, when the time is right. |
Rafael J. Wysocki | 2aede85 | 2011-09-26 20:32:27 +0200 | [diff] [blame] | 169 | */ |
| 170 | int freeze_kernel_threads(void) |
| 171 | { |
| 172 | int error; |
Rafael J. Wysocki | 11b2ce2 | 2006-12-06 20:34:40 -0800 | [diff] [blame] | 173 | |
Michal Hocko | 35536ae | 2015-02-11 15:26:18 -0800 | [diff] [blame] | 174 | pr_info("Freezing remaining freezable tasks ... "); |
| 175 | |
Tejun Heo | a320122 | 2011-11-21 12:32:25 -0800 | [diff] [blame] | 176 | pm_nosig_freezing = true; |
Rafael J. Wysocki | ebb12db | 2008-06-11 22:04:29 +0200 | [diff] [blame] | 177 | error = try_to_freeze_tasks(false); |
Rafael J. Wysocki | 2aede85 | 2011-09-26 20:32:27 +0200 | [diff] [blame] | 178 | if (!error) |
Michal Hocko | 35536ae | 2015-02-11 15:26:18 -0800 | [diff] [blame] | 179 | pr_cont("done."); |
Rafael J. Wysocki | 7f33d49 | 2009-06-16 15:32:41 -0700 | [diff] [blame] | 180 | |
Michal Hocko | 35536ae | 2015-02-11 15:26:18 -0800 | [diff] [blame] | 181 | pr_cont("\n"); |
Rafael J. Wysocki | 2aede85 | 2011-09-26 20:32:27 +0200 | [diff] [blame] | 182 | BUG_ON(in_atomic()); |
Rafael J. Wysocki | 7f33d49 | 2009-06-16 15:32:41 -0700 | [diff] [blame] | 183 | |
Tejun Heo | 03afed8 | 2011-11-21 12:32:24 -0800 | [diff] [blame] | 184 | if (error) |
Srivatsa S. Bhat | 379e0be | 2012-02-03 22:22:41 +0100 | [diff] [blame] | 185 | thaw_kernel_threads(); |
Rafael J. Wysocki | b842ee5 | 2007-10-18 03:04:48 -0700 | [diff] [blame] | 186 | return error; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 187 | } |
| 188 | |
Tejun Heo | 6cd8ded | 2011-11-21 12:32:23 -0800 | [diff] [blame] | 189 | void thaw_processes(void) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 190 | { |
| 191 | struct task_struct *g, *p; |
Colin Cross | 2b44c4d | 2013-07-24 17:41:33 -0700 | [diff] [blame] | 192 | struct task_struct *curr = current; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 193 | |
Todd E Brandt | bb3632c | 2014-06-06 05:40:17 -0700 | [diff] [blame] | 194 | trace_suspend_resume(TPS("thaw_processes"), 0, true); |
Tejun Heo | a320122 | 2011-11-21 12:32:25 -0800 | [diff] [blame] | 195 | if (pm_freezing) |
| 196 | atomic_dec(&system_freezing_cnt); |
| 197 | pm_freezing = false; |
| 198 | pm_nosig_freezing = false; |
| 199 | |
Tejun Heo | 6cd8ded | 2011-11-21 12:32:23 -0800 | [diff] [blame] | 200 | oom_killer_enable(); |
| 201 | |
Michal Hocko | 35536ae | 2015-02-11 15:26:18 -0800 | [diff] [blame] | 202 | pr_info("Restarting tasks ... "); |
Tejun Heo | 6cd8ded | 2011-11-21 12:32:23 -0800 | [diff] [blame] | 203 | |
Takashi Iwai | 4320f6b | 2014-07-15 08:51:27 +0200 | [diff] [blame] | 204 | __usermodehelper_set_disable_depth(UMH_FREEZING); |
Tejun Heo | 6cd8ded | 2011-11-21 12:32:23 -0800 | [diff] [blame] | 205 | thaw_workqueues(); |
| 206 | |
Peter Zijlstra | 50e7663 | 2017-09-07 11:13:38 +0200 | [diff] [blame] | 207 | cpuset_wait_for_hotplug(); |
| 208 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 209 | read_lock(&tasklist_lock); |
Michal Hocko | a28e785 | 2014-10-21 09:27:15 +0200 | [diff] [blame] | 210 | for_each_process_thread(g, p) { |
Colin Cross | 2b44c4d | 2013-07-24 17:41:33 -0700 | [diff] [blame] | 211 | /* No other threads should have PF_SUSPEND_TASK set */ |
| 212 | WARN_ON((p != curr) && (p->flags & PF_SUSPEND_TASK)); |
Tejun Heo | a5be2d0 | 2011-11-21 12:32:23 -0800 | [diff] [blame] | 213 | __thaw_task(p); |
Michal Hocko | a28e785 | 2014-10-21 09:27:15 +0200 | [diff] [blame] | 214 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 215 | read_unlock(&tasklist_lock); |
Rafael J. Wysocki | a9b6f56 | 2006-12-06 20:34:37 -0800 | [diff] [blame] | 216 | |
Colin Cross | 2b44c4d | 2013-07-24 17:41:33 -0700 | [diff] [blame] | 217 | WARN_ON(!(curr->flags & PF_SUSPEND_TASK)); |
| 218 | curr->flags &= ~PF_SUSPEND_TASK; |
| 219 | |
Rafael J. Wysocki | 1e73203 | 2012-03-28 23:30:21 +0200 | [diff] [blame] | 220 | usermodehelper_enable(); |
| 221 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 222 | schedule(); |
Michal Hocko | 35536ae | 2015-02-11 15:26:18 -0800 | [diff] [blame] | 223 | pr_cont("done.\n"); |
Todd E Brandt | bb3632c | 2014-06-06 05:40:17 -0700 | [diff] [blame] | 224 | trace_suspend_resume(TPS("thaw_processes"), 0, false); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 225 | } |
| 226 | |
Rafael J. Wysocki | 181e9bd | 2012-01-29 20:35:52 +0100 | [diff] [blame] | 227 | void thaw_kernel_threads(void) |
| 228 | { |
| 229 | struct task_struct *g, *p; |
| 230 | |
| 231 | pm_nosig_freezing = false; |
Michal Hocko | 35536ae | 2015-02-11 15:26:18 -0800 | [diff] [blame] | 232 | pr_info("Restarting kernel threads ... "); |
Rafael J. Wysocki | 181e9bd | 2012-01-29 20:35:52 +0100 | [diff] [blame] | 233 | |
| 234 | thaw_workqueues(); |
| 235 | |
| 236 | read_lock(&tasklist_lock); |
Michal Hocko | a28e785 | 2014-10-21 09:27:15 +0200 | [diff] [blame] | 237 | for_each_process_thread(g, p) { |
Zqiang | ccf7ce4 | 2021-01-25 12:18:28 +0800 | [diff] [blame] | 238 | if (p->flags & PF_KTHREAD) |
Rafael J. Wysocki | 181e9bd | 2012-01-29 20:35:52 +0100 | [diff] [blame] | 239 | __thaw_task(p); |
Michal Hocko | a28e785 | 2014-10-21 09:27:15 +0200 | [diff] [blame] | 240 | } |
Rafael J. Wysocki | 181e9bd | 2012-01-29 20:35:52 +0100 | [diff] [blame] | 241 | read_unlock(&tasklist_lock); |
| 242 | |
| 243 | schedule(); |
Michal Hocko | 35536ae | 2015-02-11 15:26:18 -0800 | [diff] [blame] | 244 | pr_cont("done.\n"); |
Rafael J. Wysocki | 181e9bd | 2012-01-29 20:35:52 +0100 | [diff] [blame] | 245 | } |