page_referenced() and VM_LOCKED
Subsystems (2)
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 [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
Quoted 8 lines · On Thu, 15 Nov 2007 20:25:45 -0800 Ethan Solomita <[email protected]> wrote:
page_referenced_file()checks for the vma to be VM_LOCKED|VM_MAYSHARE and adds returns 1. We don't do the same inpage_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 [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
Quoted 5 lines · KAMEZAWA Hiroyuki
Quoted 2 lines · On Thu, 15 Nov 2007 20:25:45 -0800 Ethan Solomita <[email protected]> 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.
Quoted 1 line
Quoted 1 line
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.
Quoted 3 lines
Quoted 3 lines
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.
Quoted 11 lines
Quoted 3 lines
Thanks,
-- EthanHmm,
==
vmscan.c::shrink_page_list()
page_referenced()if returns 1 -> link to active listadd to swap # only works if anon
Quoted 8 lines
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?
mm/rmap.c +4 -1
@@ -283,7 +283,10 @@ static int page_referenced_one(struct paif (!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 [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
Quoted 7 lines
Quoted 3 lines
Quoted 3 lines
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_LOCKEDpages off both active and inactive lists: that seems a better way forward.
agreed.
Quoted 7 lines
Quoted 4 lines
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 [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
KAMEZAWA Hiroyuki
Tested-byQuoted 9 lines · On Sat, 17 Nov 2007 09:32:36 +0900 (JST) [email protected] wrote:
Quoted 7 lines
Quoted 3 lines
Quoted 3 lines
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_LOCKEDpages off both active and inactive lists: that seems a better way forward.agreed.
Quoted 9 lines
Quoted 7 lines
Quoted 4 lines
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.
==
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 [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
Quoted 4 lines · KAMEZAWA Hiroyuki
Quoted 1 line
your patch helps the kernel to avoid a waste of Swap.
Tested-by KAMEZAWA Hiroyuki <[email protected]>
Many thanks, Kame. I'll send it in with my next little lot. Hugh
Quoted 13 lines
==
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
Quoted 8 lines
[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 [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
Quoted 7 lines · Hugh Dickins
Quoted 5 lines · KAMEZAWA Hiroyuki
Quoted 2 lines · On Thu, 15 Nov 2007 20:25:45 -0800 Ethan Solomita <[email protected]> wrote:
page_referenced_file()checks for the vma to be VM_LOCKED|VM_MAYSHARE and adds returns 1.
Quoted 7 lines
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.
Quoted 1 line
Quoted 1 line
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 [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
Quoted 11 lines · Ethan Solomita
Quoted 10 lines · Hugh Dickins
Quoted 5 lines · KAMEZAWA Hiroyuki
Quoted 2 lines · On Thu, 15 Nov 2007 20:25:45 -0800 Ethan Solomita <[email protected]> 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.
Quoted 7 lines
Quoted 4 lines
Quoted 1 line
Quoted 1 line
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 isVM_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 [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>