Messages in this thread Patch in this message |  | | Date | Sat, 9 Jun 2001 14:14:45 +0400 | | From | Ivan Kokshaysky <> | | Subject | Re: [patch] Re: Linux 2.4.5-ac6 |
| |
On Fri, Jun 08, 2001 at 06:08:46PM +0200, Maciej W. Rozycki wrote: > Still it has two loops...
Ok, here is a single loop version.
Ivan.
--- 2.4.5-ac11/mm/mmap.c Fri Jun 8 15:59:35 2001 +++ linux/mm/mmap.c Sat Jun 9 12:50:05 2001 @@ -398,27 +398,37 @@ free_vma: static inline unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr, unsigned long len, unsigned long pgoff, unsigned long flags) { struct vm_area_struct *vma; + unsigned long addr_limit = TASK_SIZE - len; + unsigned long addr1 = 0; if (len > TASK_SIZE) return -ENOMEM; if (addr) { addr = PAGE_ALIGN(addr); - vma = find_vma(current->mm, addr); - if (TASK_SIZE - len >= addr && - (!vma || addr + len <= vma->vm_start)) - return addr; + if (addr > TASK_UNMAPPED_BASE) + addr1 = addr; + goto find_free_area; } + +default_area: addr = PAGE_ALIGN(TASK_UNMAPPED_BASE); +find_free_area: for (vma = find_vma(current->mm, addr); ; vma = vma->vm_next) { /* At this point: (!vma || addr < vma->vm_end). */ - if (TASK_SIZE - len < addr) - return -ENOMEM; + if (addr_limit < addr) + break; if (!vma || addr + len <= vma->vm_start) return addr; addr = vma->vm_end; } + if (addr1) { + /* No unmapped areas above addr; try below it */ + addr_limit = addr1; + goto default_area; + } + return -ENOMEM; } #else extern unsigned long arch_get_unmapped_area(struct file *, unsigned long, unsigned long, unsigned long, unsigned long); --- 2.4.5-ac11/include/linux/binfmts.h Mon Jun 4 14:19:00 2001 +++ linux/include/linux/binfmts.h Mon Jun 4 20:24:50 2001 @@ -32,6 +32,9 @@ struct linux_binprm{ unsigned long loader, exec; }; +/* Forward declaration */ +struct mm_struct; + /* * This structure defines the functions that are used to load the binary formats that * linux accepts. - To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
|  |