linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: KOSAKI Motohiro <kosaki.motohiro@jp.fujitsu.com>
To: Andrew Morton <akpm@linux-foundation.org>
Cc: kosaki.motohiro@jp.fujitsu.com,
	LKML <linux-kernel@vger.kernel.org>,
	Hugh Dickins <hugh.dickins@tiscali.co.uk>,
	linux-mm <linux-mm@kvack.org>
Subject: Re: [PATCH]  [for mmotm-1113] mm: Simplify try_to_unmap_one()
Date: Thu, 19 Nov 2009 10:23:16 +0900 (JST)	[thread overview]
Message-ID: <20091119100525.3E2B.A69D9226@jp.fujitsu.com> (raw)
In-Reply-To: <20091118151803.35f55ca3.akpm@linux-foundation.org>

> On Tue, 17 Nov 2009 17:39:27 +0900 (JST)
> KOSAKI Motohiro <kosaki.motohiro@jp.fujitsu.com> wrote:
> 
> > +out_mlock:
> > +	pte_unmap_unlock(pte, ptl);
> > +
> > +	if (down_read_trylock(&vma->vm_mm->mmap_sem)) {
> > +		if (vma->vm_flags & VM_LOCKED) {
> > +			mlock_vma_page(page);
> > +			ret = SWAP_MLOCK;
> >  		}
> > +		up_read(&vma->vm_mm->mmap_sem);
> 
> It's somewhat unobvious why we're using a trylock here.  Ranking versus
> lock_page(), perhaps?
> 
> In general I think a trylock should have an associated comment which explains
> 
> a) why it is being used at this site and
> 
> b) what happens when the trylock fails - why this isn't a
>    bug, how the kernel recovers from the inconsistency, what its
>    overall effect is, etc.
> 
> <wonders why we need to take mmap_sem here at all>

This mmap_sem is needed certainenaly. Following comment is sufficient?


---
 mm/rmap.c |    8 ++++++++
 1 files changed, 8 insertions(+), 0 deletions(-)

diff --git a/mm/rmap.c b/mm/rmap.c
index 70dec01..b1c9342 100644
--- a/mm/rmap.c
+++ b/mm/rmap.c
@@ -860,6 +860,14 @@ out:
 out_mlock:
 	pte_unmap_unlock(pte, ptl);
 
+
+	/*
+	 * We need mmap_sem locking, Otherwise VM_LOCKED check makes
+	 * unstable result and race. Plus, We can't wait here because
+	 * we now hold anon_vma->lock or mapping->i_mmap_lock.
+	 * If trylock failed, The page remain evictable lru and
+	 * retry to more unevictable lru by later vmscan.
+	 */
 	if (down_read_trylock(&vma->vm_mm->mmap_sem)) {
 		if (vma->vm_flags & VM_LOCKED) {
 			mlock_vma_page(page);
-- 
1.6.2.5



--
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>

  reply	other threads:[~2009-11-19  1:23 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-11-17  8:39 KOSAKI Motohiro
2009-11-18 16:34 ` Hugh Dickins
2009-11-18 23:18 ` Andrew Morton
2009-11-19  1:23   ` KOSAKI Motohiro [this message]
2009-11-19  5:27     ` Vincent Li
2009-11-19  5:49       ` KOSAKI Motohiro
2009-11-19  6:14         ` Vincent Li
2009-11-19  6:28           ` KOSAKI Motohiro
2009-11-19  7:11             ` Vincent Li
2009-12-04  8:29             ` KOSAKI Motohiro

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=20091119100525.3E2B.A69D9226@jp.fujitsu.com \
    --to=kosaki.motohiro@jp.fujitsu.com \
    --cc=akpm@linux-foundation.org \
    --cc=hugh.dickins@tiscali.co.uk \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.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