Commit 34b43a88 authored by Quentin Perret's avatar Quentin Perret Committed by Marc Zyngier

KVM: arm64: pkvm: Fix hyp_pool max order

The EL2 page allocator in protected mode maintains a per-pool max order
value to optimize allocations when the memory region it covers is small.
However, the max order value is currently under-estimated whenever the
number of pages in the region is a power of two. Fix the estimation.
Signed-off-by: default avatarQuentin Perret <qperret@google.com>
Acked-by: default avatarWill Deacon <will@kernel.org>
Signed-off-by: default avatarMarc Zyngier <maz@kernel.org>
Link: https://lore.kernel.org/r/20211208152300.2478542-2-qperret@google.com
parent d58071a8
...@@ -241,7 +241,7 @@ int hyp_pool_init(struct hyp_pool *pool, u64 pfn, unsigned int nr_pages, ...@@ -241,7 +241,7 @@ int hyp_pool_init(struct hyp_pool *pool, u64 pfn, unsigned int nr_pages,
int i; int i;
hyp_spin_lock_init(&pool->lock); hyp_spin_lock_init(&pool->lock);
pool->max_order = min(MAX_ORDER, get_order(nr_pages << PAGE_SHIFT)); pool->max_order = min(MAX_ORDER, get_order((nr_pages + 1) << PAGE_SHIFT));
for (i = 0; i < pool->max_order; i++) for (i = 0; i < pool->max_order; i++)
INIT_LIST_HEAD(&pool->free_area[i]); INIT_LIST_HEAD(&pool->free_area[i]);
pool->range_start = phys; pool->range_start = phys;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment