KVM: arm64: Use less bits for hyp_page refcount

The hyp_page refcount is currently encoded on 4 bytes even though we
never need to count that many objects in a page. Make it 2 bytes to save
some space in the vmemmap.

As overflows are more likely to happen as well, make sure to catch those
with a BUG in the increment function.

Signed-off-by: Quentin Perret <qperret@google.com>
Signed-off-by: Marc Zyngier <maz@kernel.org>
Link: https://lore.kernel.org/r/20210608114518.748712-8-qperret@google.com
This commit is contained in:
Quentin Perret 2021-06-08 11:45:18 +00:00 committed by Marc Zyngier
parent 87ec060673
commit 6929586d8e
2 changed files with 2 additions and 1 deletions

View File

@ -8,7 +8,7 @@
#include <linux/types.h>
struct hyp_page {
unsigned int refcount;
unsigned short refcount;
unsigned short order;
};

View File

@ -146,6 +146,7 @@ static struct hyp_page *__hyp_extract_page(struct hyp_pool *pool,
static inline void hyp_page_ref_inc(struct hyp_page *p)
{
BUG_ON(p->refcount == USHRT_MAX);
p->refcount++;
}