linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Andrew Morton <akpm@linux-foundation.org>
To: Tetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp>
Cc: linux-mm@kvack.org, Michal Hocko <mhocko@suse.com>,
	Arnd Bergmann <arnd@arndb.de>
Subject: Re: [PATCH] oom_reaper: avoid pointless atomic_inc_not_zero usage.
Date: Mon, 6 Jun 2016 14:13:40 -0700	[thread overview]
Message-ID: <20160606141340.86c96c1d3dc29823438313d9@linux-foundation.org> (raw)
In-Reply-To: <1465024759-8074-1-git-send-email-penguin-kernel@I-love.SAKURA.ne.jp>

On Sat,  4 Jun 2016 16:19:19 +0900 Tetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp> 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().
> 
> ...
>
> --- 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)) {

In an off-list email (please don't do that!) you asked me to replace
mmoom_reaper-dont-call-mmput_async-without-atomic_inc_not_zero.patch
with this above patch.

But the
mmoom_reaper-dont-call-mmput_async-without-atomic_inc_not_zero.patch
changelog is pretty crappy:

: Commit e2fe14564d3316d1 ("oom_reaper: close race with exiting task")
: reduced frequency of needlessly selecting next OOM victim, but was
: calling mmput_async() when atomic_inc_not_zero() failed.

because it doesn't explain that the patch potentially fixes a kernel
crash.

And the changelog for this above patch is similarly crappy - it fails
to described the end-user visible effects of the bug which is being
fixed.  Please *always* do this.  Always always always.

Please send me a complete changelog for this patch, thanks.

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

  parent reply	other threads:[~2016-06-06 21:13 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-06-04  7:19 [PATCH] oom_reaper: avoid pointless atomic_inc_not_zero usage Tetsuo Handa
2016-06-06  7:18 ` Michal Hocko
2016-06-06 21:13 ` Andrew Morton [this message]
2016-06-08 17:04   ` Andrew Morton
2016-06-08 22:27     ` Tetsuo Handa

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20160606141340.86c96c1d3dc29823438313d9@linux-foundation.org \
    --to=akpm@linux-foundation.org \
    --cc=arnd@arndb.de \
    --cc=linux-mm@kvack.org \
    --cc=mhocko@suse.com \
    --cc=penguin-kernel@I-love.SAKURA.ne.jp \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).