Skip to content

Commit

Permalink
do_mremap() untangling, part 3
Browse files Browse the repository at this point in the history
Take the check for being able to expand vma in place into a separate
helper.

Acked-by: Russell King <rmk+kernel@arm.linux.org.uk>
Acked-by: Hugh Dickins <hugh.dickins@tiscali.co.uk>
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
  • Loading branch information
Al Viro committed Dec 11, 2009
1 parent ecc1a89 commit 1a0ef85
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions mm/mremap.c
Original file line number Diff line number Diff line change
Expand Up @@ -366,6 +366,17 @@ static unsigned long mremap_to(unsigned long addr,
return ret;
}

static int vma_expandable(struct vm_area_struct *vma, unsigned long delta)
{
unsigned long max_addr = TASK_SIZE;
if (vma->vm_next)
max_addr = vma->vm_next->vm_start;
if (max_addr - vma->vm_end < delta)
return 0;
/* we need to do arch-specific checks here */
return 1;
}

/*
* Expand (or shrink) an existing mapping, potentially moving it at the
* same time (controlled by the MREMAP_MAYMOVE flag and available VM space)
Expand Down Expand Up @@ -430,11 +441,8 @@ unsigned long do_mremap(unsigned long addr,
/* old_len exactly to the end of the area..
*/
if (old_len == vma->vm_end - addr) {
unsigned long max_addr = TASK_SIZE;
if (vma->vm_next)
max_addr = vma->vm_next->vm_start;
/* can we just expand the current mapping? */
if (max_addr - addr >= new_len) {
if (vma_expandable(vma, new_len - old_len)) {
int pages = (new_len - old_len) >> PAGE_SHIFT;

vma_adjust(vma, vma->vm_start,
Expand Down

0 comments on commit 1a0ef85

Please sign in to comment.