|
@@ -438,11 +438,14 @@ void oom_kill_process(struct task_struct *p, gfp_t gfp_mask, int order,
|
|
|
* If the task is already exiting, don't alarm the sysadmin or kill
|
|
|
* its children or threads, just set TIF_MEMDIE so it can die quickly
|
|
|
*/
|
|
|
- if (task_will_free_mem(p)) {
|
|
|
+ task_lock(p);
|
|
|
+ if (p->mm && task_will_free_mem(p)) {
|
|
|
set_tsk_thread_flag(p, TIF_MEMDIE);
|
|
|
+ task_unlock(p);
|
|
|
put_task_struct(p);
|
|
|
return;
|
|
|
}
|
|
|
+ task_unlock(p);
|
|
|
|
|
|
if (__ratelimit(&oom_rs))
|
|
|
dump_header(p, gfp_mask, order, memcg, nodemask);
|
|
@@ -492,6 +495,7 @@ void oom_kill_process(struct task_struct *p, gfp_t gfp_mask, int order,
|
|
|
|
|
|
/* mm cannot safely be dereferenced after task_unlock(victim) */
|
|
|
mm = victim->mm;
|
|
|
+ set_tsk_thread_flag(victim, TIF_MEMDIE);
|
|
|
pr_err("Killed process %d (%s) total-vm:%lukB, anon-rss:%lukB, file-rss:%lukB\n",
|
|
|
task_pid_nr(victim), victim->comm, K(victim->mm->total_vm),
|
|
|
K(get_mm_counter(victim->mm, MM_ANONPAGES)),
|
|
@@ -522,7 +526,6 @@ void oom_kill_process(struct task_struct *p, gfp_t gfp_mask, int order,
|
|
|
}
|
|
|
rcu_read_unlock();
|
|
|
|
|
|
- set_tsk_thread_flag(victim, TIF_MEMDIE);
|
|
|
do_send_sig_info(SIGKILL, SEND_SIG_FORCED, victim, true);
|
|
|
put_task_struct(victim);
|
|
|
}
|