* page_referenced() and VM_LOCKED
@ 2007-11-16 4:25 Ethan Solomita
2007-11-16 5:46 ` KAMEZAWA Hiroyuki
0 siblings, 1 reply; 8+ messages in thread
From: Ethan Solomita @ 2007-11-16 4:25 UTC (permalink / raw)
To: linux-mm
page_referenced_file() checks for the vma to be VM_LOCKED|VM_MAYSHARE
and adds returns 1. We don't do the same in page_referenced_anon(). 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.
Thanks,
-- Ethan
--
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>
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: page_referenced() and VM_LOCKED
2007-11-16 4:25 page_referenced() and VM_LOCKED Ethan Solomita
@ 2007-11-16 5:46 ` KAMEZAWA Hiroyuki
2007-11-16 18:00 ` Hugh Dickins
2007-11-17 0:32 ` kamezawa.hiroyu
0 siblings, 2 replies; 8+ messages in thread
From: KAMEZAWA Hiroyuki @ 2007-11-16 5:46 UTC (permalink / raw)
To: Ethan Solomita; +Cc: linux-mm
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. We don't do the same in page_referenced_anon(). 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.
>
> 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 ?
Thanks,
- Kame
--
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>
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: page_referenced() and VM_LOCKED
2007-11-16 5:46 ` KAMEZAWA Hiroyuki
@ 2007-11-16 18:00 ` Hugh Dickins
2007-12-05 0:26 ` Ethan Solomita
2007-11-17 0:32 ` kamezawa.hiroyu
1 sibling, 1 reply; 8+ messages in thread
From: Hugh Dickins @ 2007-11-16 18:00 UTC (permalink / raw)
To: KAMEZAWA Hiroyuki; +Cc: Ethan Solomita, linux-mm
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>
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: Re: page_referenced() and VM_LOCKED
2007-11-16 5:46 ` KAMEZAWA Hiroyuki
2007-11-16 18:00 ` Hugh Dickins
@ 2007-11-17 0:32 ` kamezawa.hiroyu
2007-11-19 9:39 ` KAMEZAWA Hiroyuki
1 sibling, 1 reply; 8+ messages in thread
From: kamezawa.hiroyu @ 2007-11-17 0:32 UTC (permalink / raw)
To: Hugh Dickins; +Cc: KAMEZAWA Hiroyuki, Ethan Solomita, linux-mm
>> > 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.
>
agreed.
>> 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?
>
seems nice. I'd like to do some test in the next week,
Thanks,
-Kame
--
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>
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: page_referenced() and VM_LOCKED
2007-11-17 0:32 ` kamezawa.hiroyu
@ 2007-11-19 9:39 ` KAMEZAWA Hiroyuki
2007-11-19 19:09 ` Hugh Dickins
0 siblings, 1 reply; 8+ messages in thread
From: KAMEZAWA Hiroyuki @ 2007-11-19 9:39 UTC (permalink / raw)
To: kamezawa.hiroyu; +Cc: Hugh Dickins, Ethan Solomita, linux-mm
On Sat, 17 Nov 2007 09:32:36 +0900 (JST)
kamezawa.hiroyu@jp.fujitsu.com wrote:
> >> > 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.
> >
> agreed.
>
> >> 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?
> >
> seems nice. I'd like to do some test in the next week,
>
your patch helps the kernel to avoid a waste of Swap.
Tested-by: KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com>
==
I tested your patch on x86_64/6GiB memory, + 2.6.24-rc3.
mlock 5GiB and create 4GiB file by"dd".
[before patch]
MemTotal: 6072620 kB
MemFree: 50540 kB
Buffers: 4508 kB
Cached: 724828 kB
SwapCached: 5146960 kB
Active: 2683964 kB
Inactive: 3198752 kB
[after patch]
MemTotal: 6072620 kB
MemFree: 17112 kB
Buffers: 6816 kB
Cached: 744880 kB
SwapCached: 21724 kB
Active: 5175828 kB
Inactive: 744956 kB
Thanks,
-Kame
--
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>
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: page_referenced() and VM_LOCKED
2007-11-19 9:39 ` KAMEZAWA Hiroyuki
@ 2007-11-19 19:09 ` Hugh Dickins
0 siblings, 0 replies; 8+ messages in thread
From: Hugh Dickins @ 2007-11-19 19:09 UTC (permalink / raw)
To: KAMEZAWA Hiroyuki; +Cc: Ethan Solomita, linux-mm
On Mon, 19 Nov 2007, KAMEZAWA Hiroyuki wrote:
> >
> your patch helps the kernel to avoid a waste of Swap.
>
> Tested-by: KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com>
Many thanks, Kame. I'll send it in with my next little lot.
Hugh
> ==
> I tested your patch on x86_64/6GiB memory, + 2.6.24-rc3.
> mlock 5GiB and create 4GiB file by"dd".
>
> [before patch]
> MemTotal: 6072620 kB
> MemFree: 50540 kB
> Buffers: 4508 kB
> Cached: 724828 kB
> SwapCached: 5146960 kB
> Active: 2683964 kB
> Inactive: 3198752 kB
>
> [after patch]
> MemTotal: 6072620 kB
> MemFree: 17112 kB
> Buffers: 6816 kB
> Cached: 744880 kB
> SwapCached: 21724 kB
> Active: 5175828 kB
> Inactive: 744956 kB
--
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>
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: page_referenced() and VM_LOCKED
2007-11-16 18:00 ` Hugh Dickins
@ 2007-12-05 0:26 ` Ethan Solomita
2007-12-05 15:54 ` Hugh Dickins
0 siblings, 1 reply; 8+ messages in thread
From: Ethan Solomita @ 2007-12-05 0:26 UTC (permalink / raw)
To: Hugh Dickins; +Cc: KAMEZAWA Hiroyuki, linux-mm
Hugh Dickins wrote:
> 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).
Sorry to come back in with this so late -- if the vma is VM_MAYSHARE,
would there be COWs of the original page?
-- Ethan
--
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>
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: page_referenced() and VM_LOCKED
2007-12-05 0:26 ` Ethan Solomita
@ 2007-12-05 15:54 ` Hugh Dickins
0 siblings, 0 replies; 8+ messages in thread
From: Hugh Dickins @ 2007-12-05 15:54 UTC (permalink / raw)
To: Ethan Solomita; +Cc: KAMEZAWA Hiroyuki, linux-mm
On Tue, 4 Dec 2007, Ethan Solomita wrote:
> Hugh Dickins wrote:
> > 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).
>
> Sorry to come back in with this so late --
> if the vma is VM_MAYSHARE, would there be COWs of the original page?
99.999% correct answer: No, that's why we're testing VM_MAYSHARE,
because we know it has to be that original page which is present
and locked there (it might be readwrite, or it might be readonly,
but it won't be a COWed copy in a VM_MAYSHARE vma; the same would
be true if we tested VM_SHARED, but that would miss readonly cases).
00.001% adjustment: Actually, there's an aberrant case in which
do_wp_page() can put a COW into a VM_MAYSHARE area, supposedly to
suit ptrace(). I overlooked that case when I put the VM_MAYSHARE
test into page_referenced_file(); later when I learnt about it
(and found Linus unwilling to change it), I did an audit of such
oversights, but concluded this test wasn't worth changing.
Hugh
--
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>
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2007-12-05 15:55 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-11-16 4:25 page_referenced() and VM_LOCKED Ethan Solomita
2007-11-16 5:46 ` KAMEZAWA Hiroyuki
2007-11-16 18:00 ` Hugh Dickins
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
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox