Skip to content

Commit fb794bc

Browse files
rientjestorvalds
authored andcommitted
mm, oom: remove unnecessary exit_state check
The oom killer scans each process and determines whether it is eligible for oom kill or whether the oom killer should abort because of concurrent memory freeing. It will abort when an eligible process is found to have TIF_MEMDIE set, meaning it has already been oom killed and we're waiting for it to exit. Processes with task->mm == NULL should not be considered because they are either kthreads or have already detached their memory and killing them would not lead to memory freeing. That memory is only freed after exit_mm() has returned, however, and not when task->mm is first set to NULL. Clear TIF_MEMDIE after exit_mm()'s mmput() so that an oom killed process is no longer considered for oom kill, but only until exit_mm() has returned. This was fragile in the past because it relied on exit_notify() to be reached before no longer considering TIF_MEMDIE processes. Signed-off-by: David Rientjes <rientjes@google.com> Cc: Oleg Nesterov <oleg@redhat.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
1 parent d017763 commit fb794bc

2 files changed

Lines changed: 1 addition & 2 deletions

File tree

‎kernel/exit.c‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -455,6 +455,7 @@ static void exit_mm(struct task_struct * tsk)
455455
task_unlock(tsk);
456456
mm_update_next_owner(mm);
457457
mmput(mm);
458+
clear_thread_flag(TIF_MEMDIE);
458459
}
459460

460461
/*

‎mm/oom_kill.c‎

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -258,8 +258,6 @@ enum oom_scan_t oom_scan_process_thread(struct task_struct *task,
258258
unsigned long totalpages, const nodemask_t *nodemask,
259259
bool force_kill)
260260
{
261-
if (task->exit_state)
262-
return OOM_SCAN_CONTINUE;
263261
if (oom_unkillable_task(task, NULL, nodemask))
264262
return OOM_SCAN_CONTINUE;
265263

0 commit comments

Comments
 (0)