Skip to content

Commit 87ec060

Browse files
Quentin PerretMarc Zyngier
authored andcommitted
KVM: arm64: Use less bits for hyp_page order
The hyp_page order is currently encoded on 4 bytes even though it is guaranteed to be smaller than this. Make it 2 bytes to reduce the hyp vmemmap overhead. Signed-off-by: Quentin Perret <qperret@google.com> Signed-off-by: Marc Zyngier <maz@kernel.org> Link: https://lore.kernel.org/r/20210608114518.748712-7-qperret@google.com
1 parent d978b9c commit 87ec060

3 files changed

Lines changed: 10 additions & 10 deletions

File tree

arch/arm64/kvm/hyp/include/nvhe/gfp.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
#include <nvhe/memory.h>
88
#include <nvhe/spinlock.h>
99

10-
#define HYP_NO_ORDER UINT_MAX
10+
#define HYP_NO_ORDER USHRT_MAX
1111

1212
struct hyp_pool {
1313
/*
@@ -19,11 +19,11 @@ struct hyp_pool {
1919
struct list_head free_area[MAX_ORDER];
2020
phys_addr_t range_start;
2121
phys_addr_t range_end;
22-
unsigned int max_order;
22+
unsigned short max_order;
2323
};
2424

2525
/* Allocation */
26-
void *hyp_alloc_pages(struct hyp_pool *pool, unsigned int order);
26+
void *hyp_alloc_pages(struct hyp_pool *pool, unsigned short order);
2727
void hyp_get_page(struct hyp_pool *pool, void *addr);
2828
void hyp_put_page(struct hyp_pool *pool, void *addr);
2929

arch/arm64/kvm/hyp/include/nvhe/memory.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99

1010
struct hyp_page {
1111
unsigned int refcount;
12-
unsigned int order;
12+
unsigned short order;
1313
};
1414

1515
extern u64 __hyp_vmemmap;

arch/arm64/kvm/hyp/nvhe/page_alloc.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ u64 __hyp_vmemmap;
3232
*/
3333
static struct hyp_page *__find_buddy_nocheck(struct hyp_pool *pool,
3434
struct hyp_page *p,
35-
unsigned int order)
35+
unsigned short order)
3636
{
3737
phys_addr_t addr = hyp_page_to_phys(p);
3838

@@ -51,7 +51,7 @@ static struct hyp_page *__find_buddy_nocheck(struct hyp_pool *pool,
5151
/* Find a buddy page currently available for allocation */
5252
static struct hyp_page *__find_buddy_avail(struct hyp_pool *pool,
5353
struct hyp_page *p,
54-
unsigned int order)
54+
unsigned short order)
5555
{
5656
struct hyp_page *buddy = __find_buddy_nocheck(pool, p, order);
5757

@@ -93,7 +93,7 @@ static inline struct hyp_page *node_to_page(struct list_head *node)
9393
static void __hyp_attach_page(struct hyp_pool *pool,
9494
struct hyp_page *p)
9595
{
96-
unsigned int order = p->order;
96+
unsigned short order = p->order;
9797
struct hyp_page *buddy;
9898

9999
memset(hyp_page_to_virt(p), 0, PAGE_SIZE << p->order);
@@ -123,7 +123,7 @@ static void __hyp_attach_page(struct hyp_pool *pool,
123123

124124
static struct hyp_page *__hyp_extract_page(struct hyp_pool *pool,
125125
struct hyp_page *p,
126-
unsigned int order)
126+
unsigned short order)
127127
{
128128
struct hyp_page *buddy;
129129

@@ -192,9 +192,9 @@ void hyp_get_page(struct hyp_pool *pool, void *addr)
192192
hyp_spin_unlock(&pool->lock);
193193
}
194194

195-
void *hyp_alloc_pages(struct hyp_pool *pool, unsigned int order)
195+
void *hyp_alloc_pages(struct hyp_pool *pool, unsigned short order)
196196
{
197-
unsigned int i = order;
197+
unsigned short i = order;
198198
struct hyp_page *p;
199199

200200
hyp_spin_lock(&pool->lock);

0 commit comments

Comments
 (0)