linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Michal Hocko <mhocko@kernel.org>
To: Tetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp>
Cc: linux-mm@kvack.org, akpm@linux-foundation.org,
	torvalds@linux-foundation.org, mgorman@suse.de,
	rientjes@google.com, riel@redhat.com, hughd@google.com,
	oleg@redhat.com, andrea@kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [RFC PATCH -v2] mm, oom: introduce oom reaper
Date: Tue, 1 Dec 2015 14:22:30 +0100	[thread overview]
Message-ID: <20151201132230.GF4567@dhcp22.suse.cz> (raw)
In-Reply-To: <201511281339.JHH78172.SLOQFOFHVFOMJt@I-love.SAKURA.ne.jp>

On Sat 28-11-15 13:39:11, Tetsuo Handa wrote:
> Michal Hocko wrote:
> > for write while write but the probability is reduced considerably wrt.
> 
> Is this "while write" garbage?

Fixed

> > Users of mmap_sem which need it for write should be carefully reviewed
> > to use _killable waiting as much as possible and reduce allocations
> > requests done with the lock held to absolute minimum to reduce the risk
> > even further.
> 
> It will be nice if we can have down_write_killable()/down_read_killable().

Yes that is an idea.

> > The API between oom killer and oom reaper is quite trivial. wake_oom_reaper
> > updates mm_to_reap with cmpxchg to guarantee only NUll->mm transition
> 
> NULL->mm

fixed

> > and oom_reaper clear this atomically once it is done with the work.
> 
> Can't oom_reaper() become as compact as below?

Good idea! I think we still need {READ,WRITE}_ONCE to prevent from any
potential mis optimizations, though.

Here is what I did:
diff --git a/mm/oom_kill.c b/mm/oom_kill.c
index 333953bf4968..b50ce41194b3 100644
--- a/mm/oom_kill.c
+++ b/mm/oom_kill.c
@@ -477,21 +477,11 @@ static void oom_reap_vmas(struct mm_struct *mm)
 
 static int oom_reaper(void *unused)
 {
-	DEFINE_WAIT(wait);
-
 	while (true) {
 		struct mm_struct *mm;
-
-		prepare_to_wait(&oom_reaper_wait, &wait, TASK_UNINTERRUPTIBLE);
-		mm = READ_ONCE(mm_to_reap);
-		if (!mm) {
-			freezable_schedule();
-			finish_wait(&oom_reaper_wait, &wait);
-		} else {
-			finish_wait(&oom_reaper_wait, &wait);
-			oom_reap_vmas(mm);
-			WRITE_ONCE(mm_to_reap, NULL);
-		}
+		wait_event_freezable(oom_reaper_wait, (mm = READ_ONCE(mm_to_reap)));
+		oom_reap_vmas(mm);
+		WRITE_ONCE(mm_to_reap, NULL);
 	}
 
 	return 0;
-- 
Michal Hocko
SUSE Labs

--
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:[~2015-12-01 13:22 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-11-25 15:56 [RFC PATCH] mm, oom: introduce oom reaper Michal Hocko
2015-11-25 20:08 ` Johannes Weiner
2015-11-26 11:08   ` Michal Hocko
2015-11-26 15:24     ` Tetsuo Handa
2015-11-26 16:34       ` Michal Hocko
2015-11-26 17:31         ` Michal Hocko
2015-11-27 11:29         ` Tetsuo Handa
2015-11-27 12:35           ` Michal Hocko
2015-11-27 16:12 ` [RFC PATCH -v2] " Michal Hocko
2015-11-27 16:39   ` Mel Gorman
2015-12-01 13:07     ` Michal Hocko
2015-11-28  4:39   ` Tetsuo Handa
2015-11-28 16:10     ` Tetsuo Handa
2015-12-01 13:29       ` Michal Hocko
2015-12-05 12:33         ` Tetsuo Handa
2015-12-07 16:07           ` Michal Hocko
2015-12-07 22:19             ` Tetsuo Handa
2015-12-08 11:06               ` Michal Hocko
2015-12-01 13:22     ` Michal Hocko [this message]

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=20151201132230.GF4567@dhcp22.suse.cz \
    --to=mhocko@kernel.org \
    --cc=akpm@linux-foundation.org \
    --cc=andrea@kernel.org \
    --cc=hughd@google.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=mgorman@suse.de \
    --cc=oleg@redhat.com \
    --cc=penguin-kernel@I-love.SAKURA.ne.jp \
    --cc=riel@redhat.com \
    --cc=rientjes@google.com \
    --cc=torvalds@linux-foundation.org \
    /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).