^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1) // SPDX-License-Identifier: GPL-2.0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3) * drivers/power/process.c - Functions for starting/stopping processes on
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4) * suspend transitions.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6) * Originally from swsusp.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10) #undef DEBUG
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 12) #include <linux/interrupt.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 13) #include <linux/oom.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14) #include <linux/suspend.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15) #include <linux/module.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 16) #include <linux/sched/debug.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 17) #include <linux/sched/task.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 18) #include <linux/syscalls.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 19) #include <linux/freezer.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20) #include <linux/delay.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 21) #include <linux/workqueue.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 22) #include <linux/kmod.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 23) #include <trace/events/power.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 24) #include <linux/cpuset.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 25)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 26) #include <trace/hooks/power.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 27)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 28) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 29) * Timeout for stopping processes
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 30) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 31) unsigned int __read_mostly freeze_timeout_msecs = 20 * MSEC_PER_SEC;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 32)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 33) static int try_to_freeze_tasks(bool user_only)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 34) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 35) struct task_struct *g, *p;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 36) unsigned long end_time;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 37) unsigned int todo;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 38) bool wq_busy = false;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 39) ktime_t start, end, elapsed;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 40) unsigned int elapsed_msecs;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 41) bool wakeup = false;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 42) int sleep_usecs = USEC_PER_MSEC;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 43)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 44) start = ktime_get_boottime();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 45)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 46) end_time = jiffies + msecs_to_jiffies(freeze_timeout_msecs);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 47)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 48) if (!user_only)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 49) freeze_workqueues_begin();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 50)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 51) while (true) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 52) todo = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 53) read_lock(&tasklist_lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 54) for_each_process_thread(g, p) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 55) if (p == current || !freeze_task(p))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 56) continue;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 57)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 58) if (!freezer_should_skip(p))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 59) todo++;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 60) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 61) read_unlock(&tasklist_lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 62)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 63) if (!user_only) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 64) wq_busy = freeze_workqueues_busy();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 65) todo += wq_busy;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 66) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 67)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 68) if (!todo || time_after(jiffies, end_time))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 69) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 70)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 71) if (pm_wakeup_pending()) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 72) wakeup = true;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 73) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 74) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 75)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 76) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 77) * We need to retry, but first give the freezing tasks some
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 78) * time to enter the refrigerator. Start with an initial
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 79) * 1 ms sleep followed by exponential backoff until 8 ms.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 80) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 81) usleep_range(sleep_usecs / 2, sleep_usecs);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 82) if (sleep_usecs < 8 * USEC_PER_MSEC)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 83) sleep_usecs *= 2;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 84) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 85)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 86) end = ktime_get_boottime();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 87) elapsed = ktime_sub(end, start);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 88) elapsed_msecs = ktime_to_ms(elapsed);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 89)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 90) if (wakeup) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 91) pr_cont("\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 92) pr_err("Freezing of tasks aborted after %d.%03d seconds",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 93) elapsed_msecs / 1000, elapsed_msecs % 1000);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 94) } else if (todo) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 95) pr_cont("\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 96) pr_err("Freezing of tasks failed after %d.%03d seconds"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 97) " (%d tasks refusing to freeze, wq_busy=%d):\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 98) elapsed_msecs / 1000, elapsed_msecs % 1000,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 99) todo - wq_busy, wq_busy);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101) if (wq_busy)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102) show_workqueue_state();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104) if (pm_debug_messages_on) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 105) read_lock(&tasklist_lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 106) for_each_process_thread(g, p) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 107) if (p != current && !freezer_should_skip(p)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 108) && freezing(p) && !frozen(p)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 109) sched_show_task(p);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 110) trace_android_vh_try_to_freeze_todo_unfrozen(p);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 111) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 112) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 113) read_unlock(&tasklist_lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 114) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 115)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 116) trace_android_vh_try_to_freeze_todo(todo, elapsed_msecs, wq_busy);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 117) } else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 118) pr_cont("(elapsed %d.%03d seconds) ", elapsed_msecs / 1000,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 119) elapsed_msecs % 1000);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 120) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 121)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 122) return todo ? -EBUSY : 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 123) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 124)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 125) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 126) * freeze_processes - Signal user space processes to enter the refrigerator.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 127) * The current thread will not be frozen. The same process that calls
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 128) * freeze_processes must later call thaw_processes.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 129) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 130) * On success, returns 0. On failure, -errno and system is fully thawed.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 131) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 132) int freeze_processes(void)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 133) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 134) int error;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 135)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 136) error = __usermodehelper_disable(UMH_FREEZING);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 137) if (error)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 138) return error;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 139)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 140) /* Make sure this task doesn't get frozen */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 141) current->flags |= PF_SUSPEND_TASK;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 142)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 143) if (!pm_freezing)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 144) atomic_inc(&system_freezing_cnt);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 145)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 146) pm_wakeup_clear(0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 147) pr_info("Freezing user space processes ... ");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 148) pm_freezing = true;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 149) error = try_to_freeze_tasks(true);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 150) if (!error) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 151) __usermodehelper_set_disable_depth(UMH_DISABLED);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 152) pr_cont("done.");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 153) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 154) pr_cont("\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 155) BUG_ON(in_atomic());
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 156)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 157) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 158) * Now that the whole userspace is frozen we need to disable
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 159) * the OOM killer to disallow any further interference with
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 160) * killable tasks. There is no guarantee oom victims will
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 161) * ever reach a point they go away we have to wait with a timeout.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 162) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 163) if (!error && !oom_killer_disable(msecs_to_jiffies(freeze_timeout_msecs)))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 164) error = -EBUSY;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 165)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 166) if (error)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 167) thaw_processes();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 168) return error;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 169) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 170)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 171) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 172) * freeze_kernel_threads - Make freezable kernel threads go to the refrigerator.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 173) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 174) * On success, returns 0. On failure, -errno and only the kernel threads are
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 175) * thawed, so as to give a chance to the caller to do additional cleanups
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 176) * (if any) before thawing the userspace tasks. So, it is the responsibility
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 177) * of the caller to thaw the userspace tasks, when the time is right.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 178) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 179) int freeze_kernel_threads(void)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 180) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 181) int error;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 182)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 183) pr_info("Freezing remaining freezable tasks ... ");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 184)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 185) pm_nosig_freezing = true;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 186) error = try_to_freeze_tasks(false);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 187) if (!error)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 188) pr_cont("done.");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 189)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 190) pr_cont("\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 191) BUG_ON(in_atomic());
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 192)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 193) if (error)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 194) thaw_kernel_threads();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 195) return error;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 196) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 197)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 198) void thaw_processes(void)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 199) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 200) struct task_struct *g, *p;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 201) struct task_struct *curr = current;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 202)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 203) trace_suspend_resume(TPS("thaw_processes"), 0, true);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 204) if (pm_freezing)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 205) atomic_dec(&system_freezing_cnt);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 206) pm_freezing = false;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 207) pm_nosig_freezing = false;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 208)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 209) oom_killer_enable();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 210)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 211) pr_info("Restarting tasks ... ");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 212)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 213) __usermodehelper_set_disable_depth(UMH_FREEZING);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 214) thaw_workqueues();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 215)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 216) cpuset_wait_for_hotplug();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 217)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 218) read_lock(&tasklist_lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 219) for_each_process_thread(g, p) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 220) /* No other threads should have PF_SUSPEND_TASK set */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 221) WARN_ON((p != curr) && (p->flags & PF_SUSPEND_TASK));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 222) __thaw_task(p);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 223) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 224) read_unlock(&tasklist_lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 225)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 226) WARN_ON(!(curr->flags & PF_SUSPEND_TASK));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 227) curr->flags &= ~PF_SUSPEND_TASK;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 228)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 229) usermodehelper_enable();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 230)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 231) schedule();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 232) pr_cont("done.\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 233) trace_suspend_resume(TPS("thaw_processes"), 0, false);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 234) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 235)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 236) void thaw_kernel_threads(void)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 237) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 238) struct task_struct *g, *p;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 239)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 240) pm_nosig_freezing = false;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 241) pr_info("Restarting kernel threads ... ");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 242)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 243) thaw_workqueues();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 244)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 245) read_lock(&tasklist_lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 246) for_each_process_thread(g, p) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 247) if (p->flags & (PF_KTHREAD | PF_WQ_WORKER))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 248) __thaw_task(p);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 249) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 250) read_unlock(&tasklist_lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 251)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 252) schedule();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 253) pr_cont("done.\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 254) }