Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

oom_reaper: avoid pointless atomic_inc_not_zero usage.

Since commit 36324a990cf5 ("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>

authored by

Tetsuo Handa and committed by
Linus Torvalds
9df10fb7 491a1c65

+1 -7
+1 -7
mm/oom_kill.c
··· 474 474 p = find_lock_task_mm(tsk); 475 475 if (!p) 476 476 goto unlock_oom; 477 - 478 477 mm = p->mm; 479 - if (!atomic_inc_not_zero(&mm->mm_users)) { 480 - task_unlock(p); 481 - mm = NULL; 482 - goto unlock_oom; 483 - } 484 - 478 + atomic_inc(&mm->mm_users); 485 479 task_unlock(p); 486 480 487 481 if (!down_read_trylock(&mm->mmap_sem)) {