linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Hugh Dickins <hugh@veritas.com>
To: KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com>
Cc: Ethan Solomita <solo@google.com>, linux-mm@kvack.org
Subject: Re: page_referenced() and VM_LOCKED
Date: Fri, 16 Nov 2007 18:00:02 +0000 (GMT)	[thread overview]
Message-ID: <Pine.LNX.4.64.0711161749020.12201@blonde.wat.veritas.com> (raw)
In-Reply-To: <20071116144641.f12fd610.kamezawa.hiroyu@jp.fujitsu.com>

On Fri, 16 Nov 2007, KAMEZAWA Hiroyuki wrote:
> On Thu, 15 Nov 2007 20:25:45 -0800
> Ethan Solomita <solo@google.com> wrote:
> 
> > page_referenced_file() checks for the vma to be VM_LOCKED|VM_MAYSHARE
> > and adds returns 1.

That's a case where it can deduce that the page is present and should
be treated as referenced, without even examining the page tables.

> > We don't do the same in page_referenced_anon().

It cannot make that same deduction in the page_referenced_anon() case
(different vmas may well contain different COWs of some original page).

Perhaps you're suggesting that page_referenced_one() ought to cover
this case.  Yes.  I think we were coming at it from the 2.6.4 rmap.c
in which VM_LOCKED was checked only in the try_to_unmap() case; but
I was worried about the length of the vma lists and tried to short-
circuit the full search in the one case I could; without thinking
about doing the equivalent elsewhere for the other cases.

> > I would've thought the point was to treat locked pages as active, never
> > pushing them into the inactive list, but since that's not quite what's
> > happening I was hoping someone could give me a clue.

Rik and Lee and others have proposed that we keep VM_LOCKED pages
off both active and inactive lists: that seems a better way forward.

> > 
> > 	Thanks,
> > 	-- Ethan
> Hmm,
> 
> == vmscan.c::shrink_page_list()
> 
>    page_referenced()  if returns 1 ->  link to active list
>    
>    add to swap  # only works if anon
> 
>    try_to_unmap()    if VM_LOCKED -> SWAP_FAIL -> link to active list
> 
> ==
> 
> Then, "VM_LOCKED & not referenced" anon page is added to swap cache
> (before pushed back to active list)
> 
> Seems intended ?

Not intended, no.  Rather a waste of swap.  How about this patch?

--- 2.6.24-rc2/mm/rmap.c	2007-10-24 07:16:04.000000000 +0100
+++ linux/mm/rmap.c	2007-11-16 17:45:32.000000000 +0000
@@ -283,7 +283,10 @@ static int page_referenced_one(struct pa
 	if (!pte)
 		goto out;
 
-	if (ptep_clear_flush_young(vma, address, pte))
+	if (vma->vm_flags & VM_LOCKED) {
+		referenced++;
+		*mapcount = 1;
+	} else if (ptep_clear_flush_young(vma, address, pte))
 		referenced++;
 
 	/* Pretend the page is referenced if the task has the

--
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:[~2007-11-16 18:00 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-11-16  4:25 Ethan Solomita
2007-11-16  5:46 ` KAMEZAWA Hiroyuki
2007-11-16 18:00   ` Hugh Dickins [this message]
2007-12-05  0:26     ` Ethan Solomita
2007-12-05 15:54       ` Hugh Dickins
2007-11-17  0:32   ` kamezawa.hiroyu
2007-11-19  9:39     ` KAMEZAWA Hiroyuki
2007-11-19 19:09       ` Hugh Dickins

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=Pine.LNX.4.64.0711161749020.12201@blonde.wat.veritas.com \
    --to=hugh@veritas.com \
    --cc=kamezawa.hiroyu@jp.fujitsu.com \
    --cc=linux-mm@kvack.org \
    --cc=solo@google.com \
    /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