aboutsummaryrefslogtreecommitdiffstats
path: root/Documentation/vm
diff options
context:
space:
mode:
authorIngo Molnar <mingo@elte.hu>2009-01-10 21:43:52 -0500
committerIngo Molnar <mingo@elte.hu>2009-01-10 21:43:52 -0500
commit99cd7074891f87c49660e3b2880564324a4733ac (patch)
tree903d2665bcb445f1f265d1adf7a99f265bcefc15 /Documentation/vm
parente8a9cbf6ae620d9e5ba9cb42001c033287a284a3 (diff)
parentc59765042f53a79a7a65585042ff463b69cb248c (diff)
Merge commit 'v2.6.29-rc1' into tracing/urgent
Diffstat (limited to 'Documentation/vm')
-rw-r--r--Documentation/vm/unevictable-lru.txt63
1 files changed, 18 insertions, 45 deletions
diff --git a/Documentation/vm/unevictable-lru.txt b/Documentation/vm/unevictable-lru.txt
index 125eed560e5a..0706a7282a8c 100644
--- a/Documentation/vm/unevictable-lru.txt
+++ b/Documentation/vm/unevictable-lru.txt
@@ -137,13 +137,6 @@ shrink_page_list() where they will be detected when vmscan walks the reverse
137map in try_to_unmap(). If try_to_unmap() returns SWAP_MLOCK, shrink_page_list() 137map in try_to_unmap(). If try_to_unmap() returns SWAP_MLOCK, shrink_page_list()
138will cull the page at that point. 138will cull the page at that point.
139 139
140Note that for anonymous pages, shrink_page_list() attempts to add the page to
141the swap cache before it tries to unmap the page. To avoid this unnecessary
142consumption of swap space, shrink_page_list() calls try_to_munlock() to check
143whether any VM_LOCKED vmas map the page without attempting to unmap the page.
144If try_to_munlock() returns SWAP_MLOCK, shrink_page_list() will cull the page
145without consuming swap space. try_to_munlock() will be described below.
146
147To "cull" an unevictable page, vmscan simply puts the page back on the lru 140To "cull" an unevictable page, vmscan simply puts the page back on the lru
148list using putback_lru_page()--the inverse operation to isolate_lru_page()-- 141list using putback_lru_page()--the inverse operation to isolate_lru_page()--
149after dropping the page lock. Because the condition which makes the page 142after dropping the page lock. Because the condition which makes the page
@@ -190,8 +183,8 @@ several places:
190 in the VM_LOCKED flag being set for the vma. 183 in the VM_LOCKED flag being set for the vma.
1913) in the fault path, if mlocked pages are "culled" in the fault path, 1843) in the fault path, if mlocked pages are "culled" in the fault path,
192 and when a VM_LOCKED stack segment is expanded. 185 and when a VM_LOCKED stack segment is expanded.
1934) as mentioned above, in vmscan:shrink_page_list() with attempting to 1864) as mentioned above, in vmscan:shrink_page_list() when attempting to
194 reclaim a page in a VM_LOCKED vma--via try_to_unmap() or try_to_munlock(). 187 reclaim a page in a VM_LOCKED vma via try_to_unmap().
195 188
196Mlocked pages become unlocked and rescued from the unevictable list when: 189Mlocked pages become unlocked and rescued from the unevictable list when:
197 190
@@ -260,9 +253,9 @@ mlock_fixup() filters several classes of "special" vmas:
260 253
2612) vmas mapping hugetlbfs page are already effectively pinned into memory. 2542) vmas mapping hugetlbfs page are already effectively pinned into memory.
262 We don't need nor want to mlock() these pages. However, to preserve the 255 We don't need nor want to mlock() these pages. However, to preserve the
263 prior behavior of mlock()--before the unevictable/mlock changes--mlock_fixup() 256 prior behavior of mlock()--before the unevictable/mlock changes--
264 will call make_pages_present() in the hugetlbfs vma range to allocate the 257 mlock_fixup() will call make_pages_present() in the hugetlbfs vma range
265 huge pages and populate the ptes. 258 to allocate the huge pages and populate the ptes.
266 259
2673) vmas with VM_DONTEXPAND|VM_RESERVED are generally user space mappings of 2603) vmas with VM_DONTEXPAND|VM_RESERVED are generally user space mappings of
268 kernel pages, such as the vdso page, relay channel pages, etc. These pages 261 kernel pages, such as the vdso page, relay channel pages, etc. These pages
@@ -322,7 +315,7 @@ __mlock_vma_pages_range()--the same function used to mlock a vma range--
322passing a flag to indicate that munlock() is being performed. 315passing a flag to indicate that munlock() is being performed.
323 316
324Because the vma access protections could have been changed to PROT_NONE after 317Because the vma access protections could have been changed to PROT_NONE after
325faulting in and mlocking some pages, get_user_pages() was unreliable for visiting 318faulting in and mlocking pages, get_user_pages() was unreliable for visiting
326these pages for munlocking. Because we don't want to leave pages mlocked(), 319these pages for munlocking. Because we don't want to leave pages mlocked(),
327get_user_pages() was enhanced to accept a flag to ignore the permissions when 320get_user_pages() was enhanced to accept a flag to ignore the permissions when
328fetching the pages--all of which should be resident as a result of previous 321fetching the pages--all of which should be resident as a result of previous
@@ -416,8 +409,8 @@ Mlocked Pages: munmap()/exit()/exec() System Call Handling
416When unmapping an mlocked region of memory, whether by an explicit call to 409When unmapping an mlocked region of memory, whether by an explicit call to
417munmap() or via an internal unmap from exit() or exec() processing, we must 410munmap() or via an internal unmap from exit() or exec() processing, we must
418munlock the pages if we're removing the last VM_LOCKED vma that maps the pages. 411munlock the pages if we're removing the last VM_LOCKED vma that maps the pages.
419Before the unevictable/mlock changes, mlocking did not mark the pages in any way, 412Before the unevictable/mlock changes, mlocking did not mark the pages in any
420so unmapping them required no processing. 413way, so unmapping them required no processing.
421 414
422To munlock a range of memory under the unevictable/mlock infrastructure, the 415To munlock a range of memory under the unevictable/mlock infrastructure, the
423munmap() hander and task address space tear down function call 416munmap() hander and task address space tear down function call
@@ -517,12 +510,10 @@ couldn't be mlocked.
517Mlocked pages: try_to_munlock() Reverse Map Scan 510Mlocked pages: try_to_munlock() Reverse Map Scan
518 511
519TODO/FIXME: a better name might be page_mlocked()--analogous to the 512TODO/FIXME: a better name might be page_mlocked()--analogous to the
520page_referenced() reverse map walker--especially if we continue to call this 513page_referenced() reverse map walker.
521from shrink_page_list(). See related TODO/FIXME below.
522 514
523When munlock_vma_page()--see "Mlocked Pages: munlock()/munlockall() System 515When munlock_vma_page()--see "Mlocked Pages: munlock()/munlockall()
524Call Handling" above--tries to munlock a page, or when shrink_page_list() 516System Call Handling" above--tries to munlock a page, it needs to
525encounters an anonymous page that is not yet in the swap cache, they need to
526determine whether or not the page is mapped by any VM_LOCKED vma, without 517determine whether or not the page is mapped by any VM_LOCKED vma, without
527actually attempting to unmap all ptes from the page. For this purpose, the 518actually attempting to unmap all ptes from the page. For this purpose, the
528unevictable/mlock infrastructure introduced a variant of try_to_unmap() called 519unevictable/mlock infrastructure introduced a variant of try_to_unmap() called
@@ -535,10 +526,7 @@ for VM_LOCKED vmas. When such a vma is found for anonymous pages and file
535pages mapped in linear VMAs, as in the try_to_unmap() case, the functions 526pages mapped in linear VMAs, as in the try_to_unmap() case, the functions
536attempt to acquire the associated mmap semphore, mlock the page via 527attempt to acquire the associated mmap semphore, mlock the page via
537mlock_vma_page() and return SWAP_MLOCK. This effectively undoes the 528mlock_vma_page() and return SWAP_MLOCK. This effectively undoes the
538pre-clearing of the page's PG_mlocked done by munlock_vma_page() and informs 529pre-clearing of the page's PG_mlocked done by munlock_vma_page.
539shrink_page_list() that the anonymous page should be culled rather than added
540to the swap cache in preparation for a try_to_unmap() that will almost
541certainly fail.
542 530
543If try_to_unmap() is unable to acquire a VM_LOCKED vma's associated mmap 531If try_to_unmap() is unable to acquire a VM_LOCKED vma's associated mmap
544semaphore, it will return SWAP_AGAIN. This will allow shrink_page_list() 532semaphore, it will return SWAP_AGAIN. This will allow shrink_page_list()
@@ -557,10 +545,7 @@ However, the scan can terminate when it encounters a VM_LOCKED vma and can
557successfully acquire the vma's mmap semphore for read and mlock the page. 545successfully acquire the vma's mmap semphore for read and mlock the page.
558Although try_to_munlock() can be called many [very many!] times when 546Although try_to_munlock() can be called many [very many!] times when
559munlock()ing a large region or tearing down a large address space that has been 547munlock()ing a large region or tearing down a large address space that has been
560mlocked via mlockall(), overall this is a fairly rare event. In addition, 548mlocked via mlockall(), overall this is a fairly rare event.
561although shrink_page_list() calls try_to_munlock() for every anonymous page that
562it handles that is not yet in the swap cache, on average anonymous pages will
563have very short reverse map lists.
564 549
565Mlocked Page: Page Reclaim in shrink_*_list() 550Mlocked Page: Page Reclaim in shrink_*_list()
566 551
@@ -588,8 +573,8 @@ Some examples of these unevictable pages on the LRU lists are:
588 munlock_vma_page() was forced to let the page back on to the normal 573 munlock_vma_page() was forced to let the page back on to the normal
589 LRU list for vmscan to handle. 574 LRU list for vmscan to handle.
590 575
591shrink_inactive_list() also culls any unevictable pages that it finds 576shrink_inactive_list() also culls any unevictable pages that it finds on
592on the inactive lists, again diverting them to the appropriate zone's unevictable 577the inactive lists, again diverting them to the appropriate zone's unevictable
593lru list. shrink_inactive_list() should only see SHM_LOCKed pages that became 578lru list. shrink_inactive_list() should only see SHM_LOCKed pages that became
594SHM_LOCKed after shrink_active_list() had moved them to the inactive list, or 579SHM_LOCKed after shrink_active_list() had moved them to the inactive list, or
595pages mapped into VM_LOCKED vmas that munlock_vma_page() couldn't isolate from 580pages mapped into VM_LOCKED vmas that munlock_vma_page() couldn't isolate from
@@ -597,19 +582,7 @@ the lru to recheck via try_to_munlock(). shrink_inactive_list() won't notice
597the latter, but will pass on to shrink_page_list(). 582the latter, but will pass on to shrink_page_list().
598 583
599shrink_page_list() again culls obviously unevictable pages that it could 584shrink_page_list() again culls obviously unevictable pages that it could
600encounter for similar reason to shrink_inactive_list(). As already discussed, 585encounter for similar reason to shrink_inactive_list(). Pages mapped into
601shrink_page_list() proactively looks for anonymous pages that should have
602PG_mlocked set but don't--these would not be detected by page_evictable()--to
603avoid adding them to the swap cache unnecessarily. File pages mapped into
604VM_LOCKED vmas but without PG_mlocked set will make it all the way to 586VM_LOCKED vmas but without PG_mlocked set will make it all the way to
605try_to_unmap(). shrink_page_list() will divert them to the unevictable list when 587try_to_unmap(). shrink_page_list() will divert them to the unevictable list
606try_to_unmap() returns SWAP_MLOCK, as discussed above. 588when try_to_unmap() returns SWAP_MLOCK, as discussed above.
607
608TODO/FIXME: If we can enhance the swap cache to reliably remove entries
609with page_count(page) > 2, as long as all ptes are mapped to the page and
610not the swap entry, we can probably remove the call to try_to_munlock() in
611shrink_page_list() and just remove the page from the swap cache when
612try_to_unmap() returns SWAP_MLOCK. Currently, remove_exclusive_swap_page()
613doesn't seem to allow that.
614
615