Skip to content

Commit

Permalink
oom_reaper: avoid pointless atomic_inc_not_zero usage.
Browse files Browse the repository at this point in the history
Since commit 36324a9 ("oom: clear TIF_MEMDIE after oom_reaper
managed to unmap the address space") changed to use find_lock_task_mm()
for finding a mm_struct to reap, it is guaranteed that mm->mm_users > 0
because find_lock_task_mm() returns a task_struct with ->mm != NULL.
Therefore, we can safely use atomic_inc().

Link: http://lkml.kernel.org/r/1465024759-8074-1-git-send-email-penguin-kernel@I-love.SAKURA.ne.jp
Signed-off-by: Tetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp>
Acked-by: Michal Hocko <mhocko@suse.com>
Cc: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
  • Loading branch information
Tetsuo Handa authored and Linus Torvalds committed Jun 25, 2016
1 parent 491a1c6 commit 9df10fb
Showing 1 changed file with 1 addition and 7 deletions.
8 changes: 1 addition & 7 deletions mm/oom_kill.c
Original file line number Diff line number Diff line change
Expand Up @@ -474,14 +474,8 @@ static bool __oom_reap_task(struct task_struct *tsk)
p = find_lock_task_mm(tsk);
if (!p)
goto unlock_oom;

mm = p->mm;
if (!atomic_inc_not_zero(&mm->mm_users)) {
task_unlock(p);
mm = NULL;
goto unlock_oom;
}

atomic_inc(&mm->mm_users);
task_unlock(p);

if (!down_read_trylock(&mm->mmap_sem)) {
Expand Down

0 comments on commit 9df10fb

Please sign in to comment.