Messages in this thread | | | From | Vitaly Mayatskikh <> | Subject | different conditions in arch_get_unmapped_area_topdown | Date | Thu, 05 Jun 2008 14:43:55 +0200 |
| |
Hi!
Here's do-while loop from generic arch_get_unmapped_area_topdown() from mm/mmap.c:
do { /* * Lookup failure means no vma is above this address, * else if new region fits below vma->vm_start, * return with success: */ vma = find_vma(mm, addr); if (!vma || addr+len <= vma->vm_start) /* remember the address as a hint for next time */ return (mm->free_area_cache = addr); /* remember the largest hole we saw so far */ if (addr + mm->cached_hole_size < vma->vm_start) mm->cached_hole_size = vma->vm_start - addr; /* try just below the current vma->vm_start */ addr = vma->vm_start-len; } while (len < vma->vm_start);
And here's from arch/x86/mm/hugetlbpage.c:
do { /* * Lookup failure means no vma is above this address, * i.e. return with success: */ if (!(vma = find_vma_prev(mm, addr, &prev_vma))) return addr; /* * new region fits between prev_vma->vm_end and * vma->vm_start, use it: */ if (addr + len <= vma->vm_start && (!prev_vma || (addr >= prev_vma->vm_end))) { /* remember the address as a hint for next time */ mm->cached_hole_size = largest_hole; return (mm->free_area_cache = addr); } else { /* pull free_area_cache down to the first hole */ if (mm->free_area_cache == vma->vm_end) { mm->free_area_cache = vma->vm_start; mm->cached_hole_size = largest_hole; } } /* remember the largest hole we saw so far */ if (addr + largest_hole < vma->vm_start) largest_hole = vma->vm_start - addr;
/* try just below the current vma->vm_start */ addr = (vma->vm_start - len) & HPAGE_MASK; } while (len <= vma->vm_start);
Why conditions in "while" differ from each other? Can the second case lead to infinite loop?
Thanks! -- wbr, Vitaly
| |