Messages in this thread Patch in this message | | | Date | Tue, 5 Jun 2001 21:41:07 +0400 | From | Ivan Kokshaysky <> | Subject | Re: [patch] Re: Linux 2.4.5-ac6 |
| |
On Tue, Jun 05, 2001 at 05:11:01PM +0200, Maciej W. Rozycki wrote: > Iterating over memory areas twice is ugly.
Hmm, yes. However, your patch isn't pretty, too. You may check the same area twice, and won't satisfy requested address > TASK_UNMAPPED_BASE. What do you think about following? Everything is scanned only once, and returned address matches specified one as close as possible.
Ivan.
--- linux/mm/mmap.c.orig Mon Jun 4 14:19:02 2001 +++ linux/mm/mmap.c Tue Jun 5 21:05:23 2001 @@ -398,22 +398,30 @@ 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; 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) + goto scan_low; + addr_limit = addr; + for (vma = find_vma(current->mm, addr); ; vma = vma->vm_next) { + if (TASK_SIZE - len < addr) + break; + if (!vma || addr + len <= vma->vm_start) + return addr; + addr = vma->vm_end; + } } addr = PAGE_ALIGN(TASK_UNMAPPED_BASE); +scan_low: for (vma = find_vma(current->mm, addr); ; vma = vma->vm_next) { /* At this point: (!vma || addr < vma->vm_end). */ - if (TASK_SIZE - len < addr) + if (addr_limit < addr) return -ENOMEM; if (!vma || addr + len <= vma->vm_start) return addr; - 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/
| |