Skip to content

Commit

Permalink
mm: use vm_unmapped_area() on frv architecture
Browse files Browse the repository at this point in the history
Update the frv arch_get_unmapped_area function to make use of
vm_unmapped_area() instead of implementing a brute force search.

Signed-off-by: Michel Lespinasse <walken@google.com>
Acked-by: Rik van Riel <riel@redhat.com>
Acked-by: David Howells <dhowells@redhat.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
  • Loading branch information
Michel Lespinasse authored and Linus Torvalds committed Feb 28, 2013
1 parent 309a85b commit e759a79
Showing 1 changed file with 17 additions and 32 deletions.
49 changes: 17 additions & 32 deletions arch/frv/mm/elf-fdpic.c
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr, unsi
unsigned long pgoff, unsigned long flags)
{
struct vm_area_struct *vma;
unsigned long limit;
struct vm_unmapped_area_info info;

if (len > TASK_SIZE)
return -ENOMEM;
Expand All @@ -79,39 +79,24 @@ unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr, unsi
}

/* search between the bottom of user VM and the stack grow area */
addr = PAGE_SIZE;
limit = (current->mm->start_stack - 0x00200000);
if (addr + len <= limit) {
limit -= len;

if (addr <= limit) {
vma = find_vma(current->mm, PAGE_SIZE);
for (; vma; vma = vma->vm_next) {
if (addr > limit)
break;
if (addr + len <= vma->vm_start)
goto success;
addr = vma->vm_end;
}
}
}
info.flags = 0;
info.length = len;
info.low_limit = PAGE_SIZE;
info.high_limit = (current->mm->start_stack - 0x00200000);
info.align_mask = 0;
info.align_offset = 0;
addr = vm_unmapped_area(&info);
if (!(addr & ~PAGE_MASK))
goto success;
VM_BUG_ON(addr != -ENOMEM);

/* search from just above the WorkRAM area to the top of memory */
addr = PAGE_ALIGN(0x80000000);
limit = TASK_SIZE - len;
if (addr <= limit) {
vma = find_vma(current->mm, addr);
for (; vma; vma = vma->vm_next) {
if (addr > limit)
break;
if (addr + len <= vma->vm_start)
goto success;
addr = vma->vm_end;
}

if (!vma && addr <= limit)
goto success;
}
info.low_limit = PAGE_ALIGN(0x80000000);
info.high_limit = TASK_SIZE;
addr = vm_unmapped_area(&info);
if (!(addr & ~PAGE_MASK))
goto success;
VM_BUG_ON(addr != -ENOMEM);

#if 0
printk("[area] l=%lx (ENOMEM) f='%s'\n",
Expand Down

0 comments on commit e759a79

Please sign in to comment.