xen/heap: pass order to free_heap_pages() in heap init
authorHongyan Xia <hongyxia@amazon.com>
Wed, 24 Feb 2021 18:43:13 +0000 (18:43 +0000)
committerJulien Grall <jgrall@amazon.com>
Wed, 20 Jul 2022 18:26:19 +0000 (19:26 +0100)
commit72b02bc75b47a7f74d82f812fcbebf0f729f77a8
treefffc27070150620f25f472a3d35d87894230a049
parent24a53060bd375ab7e95eda9417bb66d821524c59
xen/heap: pass order to free_heap_pages() in heap init

The idea is to split the range into multiple aligned power-of-2 regions
which only needs to call free_heap_pages() once each. We check the least
significant set bit of the start address and use its bit index as the
order of this increment. This makes sure that each increment is both
power-of-2 and properly aligned, which can be safely passed to
free_heap_pages(). Of course, the order also needs to be sanity checked
against the upper bound and MAX_ORDER.

Tested on a nested environment on c5.metal with various amount
of RAM and CONFIG_DEBUG=n. Time for end_boot_allocator() to complete:
            Before         After
    - 90GB: 1445 ms         96 ms
    -  8GB:  126 ms          8 ms
    -  4GB:   62 ms          4 ms

Signed-off-by: Hongyan Xia <hongyxia@amazon.com>
Signed-off-by: Julien Grall <jgrall@amazon.com>
Reviewed-by: Wei Chen <Wei.Chen@arm.com>
Reviewed-by: Jan Beulich <jbeulich@suse.com>
xen/common/page_alloc.c