rmap 8 unmap nonlinear
Subsystems (3)
PATCH 8/57 rmap 8 unmap nonlinear
From: Hugh Dickins <[email protected]>
The previous patch let the ptes of file pages be located via page ->mapping->i_mmap and i_mmap_shared lists of vmas; which works well unless the vma is VM_NONLINEAR - one in which sys_remap_file_pages has been used to place pages in unexpected places, to avoid an explosion of distinct unmergable vmas. Such pages were effectively locked in memory.
page_referenced_file is already skipping nonlinear vmas, they'd just waste its time, and age unfairly any pages in their proper positions. Now extend try_to_unmap_file, to persuade it to swap from nonlinears.
Ignoring the page requested, try to unmap cluster of 32 neighbouring ptes (in worst case all empty slots) in a nonlinear vma, then move on to the next vma; stopping when we've unmapped at least as many maps as the requested page had (vague guide of how hard to try), or have reached the end. With large sparse nonlinear vmas, this could take a long time:
inserted a cond_resched while no locks are held, unusual at this level but I think okay, shrink_list does so.
Use vm_private_data a little like the old mm->swap_address, as a cursor recording how far we got, so we don't attack the same ptes next time around (earlier tried inserting an empty marker vma in the list, but that got messy). How well this will work on real- life nonlinear vmas remains to be seen, but should work better than locking them all in memory, or swapping everything out all the time.
Existing users of vm_private_data have either VM_RESERVED or VM_DONTEXPAND set, both of which are in the VM_SPECIAL category where we never try to merge vmas: so removed the vm_private_data test from is_mergeable_vma, so we can still merge VM_NONLINEARs. Of course, we could instead add another field to vm_area_struct.
---
25-akpm/mm/fremap.c | 7 +- 25-akpm/mm/mmap.c | 2 25-akpm/mm/rmap.c | 178 +++++++++++++++++++++++++++++++++++++++++++++++++++- 3 files changed, 182 insertions(+), 5 deletions(-)
mm/fremap.c renamed from mm/fremap.c~rmap-8-unmap-nonlinear +5 -2
@@ -186,15 +186,18 @@ asmlinkage long sys_remap_file_pages(uns/* * Make sure the vma is shared, that it supports prefaulting, * and that the remapped range is valid and fully within -* the single existing vma: +* the single existing vma. vm_private_data is used as a +* swapout cursor in a VM_NONLINEAR vma (unless VM_RESERVED +* or VM_LOCKED, but VM_LOCKED could be revoked later on). */ if (vma && (vma->vm_flags &VM_SHARED ) && + (!vma->vm_private_data || (vma->vm_flags &VM_RESERVED )) && vma->vm_ops && vma->vm_ops->populate && end > start && start >= vma->vm_start && end <= vma->vm_end) {/* Must set VM_NONLINEAR before any pages are populated. */ -if (pgoff != ((start - vma->vm_start) >>PAGE_SHIFT ) + vma->vm_pgoff) +if (pgoff !=linear_page_index (vma, start)) vma->vm_flags |=VM_NONLINEAR ;/* ->populate can take a long time, so downgrade the lock. */
mm/mmap.c renamed from mm/mmap.c~rmap-8-unmap-nonlinear +0 -2
@@ -333,8 +333,6 @@ static inline int is_mergeable_vma(strucreturn 0 ;if (vma->vm_flags != vm_flags)return 0 ; -if (vma->vm_private_data) -return 0 ;return 1 ; }
mm/rmap.c renamed from mm/rmap.c~rmap-8-unmap-nonlinear +177 -1
203 lines not on this page · raw message
_
--
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>