Re: [PATCH] oom_reaper: avoid pointless atomic_inc_not_zero usage.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Sat 04-06-16 16:19:19, Tetsuo Handa wrote:
> Since commit 36324a990cf578b5 ("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().
> 
> Signed-off-by: Tetsuo Handa <penguin-kernel@xxxxxxxxxxxxxxxxxxx>
> Cc: Michal Hocko <mhocko@xxxxxxxx>
> Cc: Arnd Bergmann <arnd@xxxxxxxx>
> Cc: Andrew Morton <akpm@xxxxxxxxxxxxxxxxxxxx>

Acked-by: Michal Hocko <mhocko@xxxxxxxx>

Thanks!

> ---
>  mm/oom_kill.c | 7 +------
>  1 file changed, 1 insertion(+), 6 deletions(-)
> 
> diff --git a/mm/oom_kill.c b/mm/oom_kill.c
> index dfb1ab6..8050fa0 100644
> --- a/mm/oom_kill.c
> +++ b/mm/oom_kill.c
> @@ -474,13 +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);
> -		goto unlock_oom;
> -	}
> -
> +	atomic_inc(&mm->mm_users);
>  	task_unlock(p);
>  
>  	if (!down_read_trylock(&mm->mmap_sem)) {
> -- 
> 1.8.3.1
> 

-- 
Michal Hocko
SUSE Labs

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@xxxxxxxxx.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@xxxxxxxxx";> email@xxxxxxxxx </a>



[Index of Archives]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Bugtraq]     [Linux]     [Linux OMAP]     [Linux MIPS]     [ECOS]     [Asterisk Internet PBX]     [Linux API]