diff options
Diffstat (limited to 'kernel')
| -rw-r--r-- | kernel/exit.c | 3 | ||||
| -rw-r--r-- | kernel/power/process.c | 50 |
2 files changed, 11 insertions, 42 deletions
diff --git a/kernel/exit.c b/kernel/exit.c index 02b3d1ab2ec0..feff10bbb307 100644 --- a/kernel/exit.c +++ b/kernel/exit.c | |||
| @@ -435,7 +435,8 @@ static void exit_mm(struct task_struct *tsk) | |||
| 435 | task_unlock(tsk); | 435 | task_unlock(tsk); |
| 436 | mm_update_next_owner(mm); | 436 | mm_update_next_owner(mm); |
| 437 | mmput(mm); | 437 | mmput(mm); |
| 438 | unmark_oom_victim(); | 438 | if (test_thread_flag(TIF_MEMDIE)) |
| 439 | unmark_oom_victim(); | ||
| 439 | } | 440 | } |
| 440 | 441 | ||
| 441 | static struct task_struct *find_alive_thread(struct task_struct *p) | 442 | static struct task_struct *find_alive_thread(struct task_struct *p) |
diff --git a/kernel/power/process.c b/kernel/power/process.c index 3ac45f192e9f..564f786df470 100644 --- a/kernel/power/process.c +++ b/kernel/power/process.c | |||
| @@ -108,30 +108,6 @@ static int try_to_freeze_tasks(bool user_only) | |||
| 108 | return todo ? -EBUSY : 0; | 108 | return todo ? -EBUSY : 0; |
| 109 | } | 109 | } |
| 110 | 110 | ||
| 111 | static bool __check_frozen_processes(void) | ||
| 112 | { | ||
| 113 | struct task_struct *g, *p; | ||
| 114 | |||
| 115 | for_each_process_thread(g, p) | ||
| 116 | if (p != current && !freezer_should_skip(p) && !frozen(p)) | ||
| 117 | return false; | ||
| 118 | |||
| 119 | return true; | ||
| 120 | } | ||
| 121 | |||
| 122 | /* | ||
| 123 | * Returns true if all freezable tasks (except for current) are frozen already | ||
| 124 | */ | ||
| 125 | static bool check_frozen_processes(void) | ||
| 126 | { | ||
| 127 | bool ret; | ||
| 128 | |||
| 129 | read_lock(&tasklist_lock); | ||
| 130 | ret = __check_frozen_processes(); | ||
| 131 | read_unlock(&tasklist_lock); | ||
| 132 | return ret; | ||
| 133 | } | ||
| 134 | |||
| 135 | /** | 111 | /** |
| 136 | * freeze_processes - Signal user space processes to enter the refrigerator. | 112 | * freeze_processes - Signal user space processes to enter the refrigerator. |
| 137 | * The current thread will not be frozen. The same process that calls | 113 | * The current thread will not be frozen. The same process that calls |
| @@ -142,7 +118,6 @@ static bool check_frozen_processes(void) | |||
| 142 | int freeze_processes(void) | 118 | int freeze_processes(void) |
| 143 | { | 119 | { |
| 144 | int error; | 120 | int error; |
| 145 | int oom_kills_saved; | ||
| 146 | 121 | ||
| 147 | error = __usermodehelper_disable(UMH_FREEZING); | 122 | error = __usermodehelper_disable(UMH_FREEZING); |
| 148 | if (error) | 123 | if (error) |
| @@ -157,29 +132,22 @@ int freeze_processes(void) | |||
| 157 | pm_wakeup_clear(); | 132 | pm_wakeup_clear(); |
| 158 | pr_info("Freezing user space processes ... "); | 133 | pr_info("Freezing user space processes ... "); |
| 159 | pm_freezing = true; | 134 | pm_freezing = true; |
| 160 | oom_kills_saved = oom_kills_count(); | ||
| 161 | error = try_to_freeze_tasks(true); | 135 | error = try_to_freeze_tasks(true); |
| 162 | if (!error) { | 136 | if (!error) { |
| 163 | __usermodehelper_set_disable_depth(UMH_DISABLED); | 137 | __usermodehelper_set_disable_depth(UMH_DISABLED); |
| 164 | oom_killer_disable(); | 138 | pr_cont("done."); |
| 165 | |||
| 166 | /* | ||
| 167 | * There might have been an OOM kill while we were | ||
| 168 | * freezing tasks and the killed task might be still | ||
| 169 | * on the way out so we have to double check for race. | ||
| 170 | */ | ||
| 171 | if (oom_kills_count() != oom_kills_saved && | ||
| 172 | !check_frozen_processes()) { | ||
| 173 | __usermodehelper_set_disable_depth(UMH_ENABLED); | ||
| 174 | pr_cont("OOM in progress."); | ||
| 175 | error = -EBUSY; | ||
| 176 | } else { | ||
| 177 | pr_cont("done."); | ||
| 178 | } | ||
| 179 | } | 139 | } |
| 180 | pr_cont("\n"); | 140 | pr_cont("\n"); |
| 181 | BUG_ON(in_atomic()); | 141 | BUG_ON(in_atomic()); |
| 182 | 142 | ||
| 143 | /* | ||
| 144 | * Now that the whole userspace is frozen we need to disbale | ||
| 145 | * the OOM killer to disallow any further interference with | ||
| 146 | * killable tasks. | ||
| 147 | */ | ||
| 148 | if (!error && !oom_killer_disable()) | ||
| 149 | error = -EBUSY; | ||
| 150 | |||
| 183 | if (error) | 151 | if (error) |
| 184 | thaw_processes(); | 152 | thaw_processes(); |
| 185 | return error; | 153 | return error; |
