rmap 36 mprotect use vma_merge
Subsystems (3)
PATCH 52/57 rmap 36 mprotect use vma_merge
From: Hugh Dickins <[email protected]>
Earlier on, in 2.6.6, we took the vma merging code out of mremap.c and let it rely on vma_merge instead (via copy_vma). Now take the vma merging code out of mprotect.c and let it rely on vma_merge too: so vma_merge becomes the sole vma merging engine. The fruit of this consolidation is that mprotect now merges file-backed vmas naturally. Make this change now because anon_vma will complicate the vma merging rules, let's keep them all in one place.
vma_merge remains where the decisions are made, whether to merge with prev and/or next; but now [addr,end) may be the latter part of prev, or first part or whole of next, whereas before it was always a new area.
vma_adjust carries out vma_merge's decision, but when sliding the boundary between vma and next, must temporarily remove next from the prio_tree too. And it turned out (by oops) to have a surer idea of whether next needs to be removed than vma_merge, so the fput and freeing moves into vma_adjust.
Too much decipherment of what's going on at the start of vma_adjust? Yes, and there's a delicate assumption that you may use vma_adjust in sliding a boundary, or splitting in two, or growing a vma (mremap uses it in that way), but not for simply shrinking a vma. Which is so, and must be so (how could pages mapped in the part to go, be zapped without first splitting?), but would feel better with some protection.
__vma_unlink can then be moved from mm.h to mmap.c, and mm.h's more misleading than helpful can_vma_merge is deleted.
---
25-akpm/include/linux/mm.h | 29 +------ 25-akpm/mm/mmap.c | 172 +++++++++++++++++++++++++++++++++------------ 25-akpm/mm/mprotect.c | 110 ++++++---------------------- 3 files changed, 159 insertions(+), 152 deletions(-)
include/linux/mm.h renamed from include/linux/mm.h~rmap-36-mprotect-use-vma_merge +6 -23
@@ -607,7 +607,12 @@ struct vm_area_struct *vma_prio_tree_nex/* mmap.c */ extern void vma_adjust (struct vm_area_struct *vma,unsigned long start, -unsigned long end,pgoff_t pgoff,struct vm_area_struct *next); +unsigned long end,pgoff_t pgoff,struct vm_area_struct *insert); +extern struct vm_area_struct *vma_merge (struct mm_struct *, +struct vm_area_struct *prev,unsigned long addr,unsigned long end, +unsigned long vm_flags,struct file *,pgoff_t ,struct mempolicy *); +extern int split_vma (struct mm_struct *, +struct vm_area_struct *,unsigned long addr,int new_below);extern void insert_vm_struct (struct mm_struct *,struct vm_area_struct *);extern void __vma_link_rb (struct mm_struct *,struct vm_area_struct *,struct rb_node **,struct rb_node *);
@@ -638,26 +643,6 @@ extern int do_munmap(struct mm_struct *,extern unsigned long do_brk (unsigned long ,unsigned long ); -static inline void -__vma_unlink (struct mm_struct *mm,struct vm_area_struct *vma, -struct vm_area_struct *prev) -{ - prev->vm_next = vma->vm_next; -rb_erase (&vma->vm_rb, &mm->mm_rb); -if (mm->mmap_cache == vma) - mm->mmap_cache = prev; -} - -static inline int -can_vma_merge (struct vm_area_struct *vma,unsigned long vm_flags) -{ -#ifdef CONFIG_MMU -if (!vma->vm_file && vma->vm_flags == vm_flags) -return 1 ; -#endif -return 0 ; -} -/* filemap.c */ extern unsigned long page_unuse (struct page *);extern void truncate_inode_pages (struct address_space *,loff_t );
@@ -691,8 +676,6 @@ extern int expand_stack(struct vm_area_sextern struct vm_area_struct *find_vma (struct mm_struct * mm,unsigned long addr);extern struct vm_area_struct *find_vma_prev (struct mm_struct * mm,unsigned long addr,struct vm_area_struct **pprev); -extern int split_vma (struct mm_struct * mm,struct vm_area_struct * vma, -unsigned long addr,int new_below);/* Look up the first VMA which intersects the interval start_addr..end_addr-1, NULL if none. Assume start_addr < end_addr. */
mm/mmap.c renamed from mm/mmap.c~rmap-36-mprotect-use-vma_merge +127 -45
252 lines not on this page · raw message
mm/mprotect.c renamed from mm/mprotect.c~rmap-36-mprotect-use-vma_merge +26 -84
171 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>