Skip to contentSkip to conversation

rmap 15: vma_adjust

PATCH In review [email protected] 1 participant 1 message May 22, 2004

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 30/57 rmap 15: vma_adjust

From: Hugh Dickins <[email protected]>

If file-based vmas are to be kept in a tree, according to the file offsets they map, then adjusting the vma's start pgoff or its end involves repositioning in the tree, while holding i_shared_lock (and page_table_lock). We used to avoid that if possible, e.g. when just moving end; but if we're heading that way, let's now tidy up vma_merge and split_vma, and do all the locking and adjustment in a new helper vma_adjust. And please, let's call the next vma in vma_merge "next" rather than "prev".

Since these patches are diffed over 2.6.6-rc2-mm2, they include the NUMA mpolicy mods which you'll have to remove to go earlier in the series, sorry for that nuisance. I have intentionally changed the one vma_mpol_equal to mpol_equal, to make the merge cases more alike.

---

 25-akpm/include/linux/mm.h |    2 
 25-akpm/mm/mmap.c          |  161 ++++++++++++++++++++++-----------------------
 25-akpm/mm/mremap.c        |    7 +
 3 files changed, 87 insertions(+), 83 deletions(-)
include/linux/mm.h renamed from include/linux/mm.h~rmap-15-vma_adjust +2 -0
diff -puN include/linux/mm.h~rmap-15-vma_adjust include/linux/mm.h
@@ -588,6 +588,8 @@ extern void si_meminfo(struct sysinfo * 
 extern void si_meminfo_node(struct sysinfo *val, int nid);
 
 /* 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);
 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 *);
mm/mmap.c renamed from mm/mmap.c~rmap-15-vma_adjust +81 -80

228 lines not on this page · raw message

mm/mremap.c renamed from mm/mremap.c~rmap-15-vma_adjust +4 -3
diff -puN mm/mremap.c~rmap-15-vma_adjust mm/mremap.c
@@ -391,9 +391,10 @@ unsigned long do_mremap(unsigned long ad
 		/* can we just expand the current mapping? */
 		if (max_addr - addr >= new_len) {
 			int pages = (new_len - old_len) >> PAGE_SHIFT;
-			spin_lock(&vma->vm_mm->page_table_lock);
-			vma->vm_end = addr + new_len;
-			spin_unlock(&vma->vm_mm->page_table_lock);
+
+			vma_adjust(vma, vma->vm_start,
+				addr + new_len, vma->vm_pgoff, NULL);
+
 			current->mm->total_vm += pages;
 			if (vma->vm_flags & VM_LOCKED) {
 				current->mm->locked_vm += pages;

_
--
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>