Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 189833
b: refs/heads/master
c: 287d97a
h: refs/heads/master
i:
  189831: 9ee34fa
v: v3
  • Loading branch information
Linus Torvalds committed Apr 13, 2010
1 parent 003ee89 commit be3f894
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 17 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: d0e9fe1758f222f13ec893f856552d81a10d266d
refs/heads/master: 287d97ac032136724143cde8d5964b414d562ee3
24 changes: 8 additions & 16 deletions trunk/mm/mmap.c
Original file line number Diff line number Diff line change
Expand Up @@ -507,27 +507,28 @@ int vma_adjust(struct vm_area_struct *vma, unsigned long start,
struct address_space *mapping = NULL;
struct prio_tree_root *root = NULL;
struct file *file = vma->vm_file;
struct anon_vma *anon_vma = NULL;
long adjust_next = 0;
int remove_next = 0;

if (next && !insert) {
struct vm_area_struct *exporter = NULL;

if (end >= next->vm_end) {
/*
* vma expands, overlapping all the next, and
* perhaps the one after too (mprotect case 6).
*/
again: remove_next = 1 + (end > next->vm_end);
end = next->vm_end;
anon_vma = next->anon_vma;
exporter = next;
importer = vma;
} else if (end > next->vm_start) {
/*
* vma expands, overlapping part of the next:
* mprotect case 5 shifting the boundary up.
*/
adjust_next = (end - next->vm_start) >> PAGE_SHIFT;
anon_vma = next->anon_vma;
exporter = next;
importer = vma;
} else if (end < vma->vm_end) {
/*
Expand All @@ -536,28 +537,19 @@ again: remove_next = 1 + (end > next->vm_end);
* mprotect case 4 shifting the boundary down.
*/
adjust_next = - ((vma->vm_end - end) >> PAGE_SHIFT);
anon_vma = next->anon_vma;
exporter = vma;
importer = next;
}
}

/*
* When changing only vma->vm_end, we don't really need anon_vma lock.
*/
if (vma->anon_vma && (insert || importer || start != vma->vm_start))
anon_vma = vma->anon_vma;
if (anon_vma) {
/*
* Easily overlooked: when mprotect shifts the boundary,
* make sure the expanding vma has anon_vma set if the
* shrinking vma had, to cover any anon pages imported.
*/
if (importer && !importer->anon_vma) {
/* Block reverse map lookups until things are set up. */
if (anon_vma_clone(importer, vma)) {
if (exporter && exporter->anon_vma && !importer->anon_vma) {
if (anon_vma_clone(importer, exporter))
return -ENOMEM;
}
importer->anon_vma = anon_vma;
importer->anon_vma = exporter->anon_vma;
}
}

Expand Down

0 comments on commit be3f894

Please sign in to comment.