On 5/27/20 3:05 AM, Alex Bennée wrote:
> +static uintptr_t pgd_find_hole_fallback(uintptr_t guest_size, uintptr_t brk, 
> long align)
> +{
> +    uintptr_t base;
> +
> +    /* Start at the bottom and work our way up */
> +    base = mmap_min_addr;
> +
> +    while (true) {
> +        uintptr_t align_start, end;
> +        align_start = ROUND_UP(base, align);
> +        end = align_start + guest_size;
> +
> +        /* if brk is anywhere in the range give ourselves some room to grow. 
> */
> +        if (align_start <= brk && brk < end) {
> +            base += 16 * MiB;

You should skip the entire brk region with base = brk + 16 * MiB.

> +            base += qemu_host_page_size;

If align < qemu_host_page_size, then we'll try the same page multiple times.
Better as base = align_start + qemu_host_page_size.

Or even base = ROUND_UP(base, align) right at the beginning.


r~

Reply via email to