Commit 28324d1d authored by Oleg Nesterov's avatar Oleg Nesterov Committed by Linus Torvalds
Browse files

[PATCH] select_bad_process(): kill a bogus PF_DEAD/TASK_DEAD check

The only one usage of TASK_DEAD outside of last schedule path,


	for_each_task(p) {

		if (!p->mm)
			if (p->state == TASK_DEAD)

TASK_DEAD state is set at the end of do_exit(), this means that p->mm
was already set == NULL by exit_mm(), so this task was already rejected
by 'if (!p->mm)' above.

Note also that the caller holds tasklist_lock, this means that p can't
pass exit_notify() and then set TASK_DEAD when p->mm != NULL.

Also, remove open-coded is_init().
Signed-off-by: default avatarOleg Nesterov <>
Cc: Ingo Molnar <>
Cc: Nick Piggin <>
Signed-off-by: default avatarAndrew Morton <>
Signed-off-by: default avatarLinus Torvalds <>
parent c394cc9f
......@@ -206,11 +206,14 @@ static struct task_struct *select_bad_process(unsigned long *ppoints)
unsigned long points;
int releasing;
/* skip kernel threads */
* skip kernel threads and tasks which have already released
* their mm.
if (!p->mm)
/* skip the init task with pid == 1 */
if (p->pid == 1)
/* skip the init task */
if (is_init(p))
......@@ -226,9 +229,6 @@ static struct task_struct *select_bad_process(unsigned long *ppoints)
releasing = test_tsk_thread_flag(p, TIF_MEMDIE) ||
p->flags & PF_EXITING;
if (releasing) {
/* TASK_DEAD tasks have already released their mm */
if (p->state == TASK_DEAD)
if (p->flags & PF_EXITING && p == current) {
chosen = p;
*ppoints = ULONG_MAX;
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment