Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp444087pxj; Wed, 2 Jun 2021 03:08:33 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxkNEaht097871kYXYXUoenIP94jngJLhuVsPyKb0ax8biIBuFoQdiLds9lKy+hfB2TIkID X-Received: by 2002:a17:906:1311:: with SMTP id w17mr30187189ejb.6.1622628513092; Wed, 02 Jun 2021 03:08:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1622628513; cv=none; d=google.com; s=arc-20160816; b=a5wrGWV1vJx508IMRYX18o2P/LzuVb229reNBb21SNk1dloCd25iI+eHQj1hJ4BGMC K4Lv5gf93Tk5DosTk5+3pEHoyrWTa/h+EqEjAf+bkfvVSBcU1UpYBnEdDA0xBzx8P6u4 7JxpscxrhKP4AYikLbWPU3dvRveTnqZs1eIGwgBjC9Exb+gCZWsJF+pQuF9G5lOf8V10 xK4j0ZgPeJLE5UiTuQCQlYgKs1vRiRZCIrckpOysnuk2n2WkD7U4eheJKiy+vhK853zJ qx+GKaT3SS6CasJ3eYAbAWHFqRTLJJrmvsVxGqhwCrSAEnBTY62sgylqGZZ+nI2A6SmL rifw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:from:subject:references:mime-version :message-id:in-reply-to:date:dkim-signature; bh=Ge7hgJuDR1OpL3eSXNKyct/Yzp2Tl/Woy/7gBbj6zjQ=; b=k4E4pfmDdZJ26hIeM+OuQLQYyDvVSljlAMhQis9jCajtGnMjrXX31t0fh3GeBS6sTO 1iqs16tindVpQTDWL+1TaoFWUJQofohLttwzg0HRU84uGUOAs4mgULa4EG6kIlptdIAz O84ip7+qaFvT6yZA3PxFm/e+UvxewJxWsR6cf5bYAHHl2Dc0O1A/wUjYFJw2XZ5wimG/ 5GRBhFZ1zuX4jBn90bHlz1uSL3qGPvVXTckUPerpG0ds0mYa+laIip17cXppWe+XW93t aVaTABGGHT3SHSArqzPtBqyFm+U6wdvuNWDJ0A1H9dc8ylm0G+8U9Ott3UXFbv+lrcKZ MGnw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b="SGe/vI9/"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id op2si9642571ejb.522.2021.06.02.03.08.09; Wed, 02 Jun 2021 03:08:33 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b="SGe/vI9/"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232288AbhFBJpz (ORCPT + 99 others); Wed, 2 Jun 2021 05:45:55 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58528 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232208AbhFBJps (ORCPT ); Wed, 2 Jun 2021 05:45:48 -0400 Received: from mail-qk1-x749.google.com (mail-qk1-x749.google.com [IPv6:2607:f8b0:4864:20::749]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2546FC06174A for ; Wed, 2 Jun 2021 02:44:04 -0700 (PDT) Received: by mail-qk1-x749.google.com with SMTP id s4-20020a3790040000b02902fa7aa987e8so1203320qkd.14 for ; Wed, 02 Jun 2021 02:44:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:in-reply-to:message-id:mime-version:references:subject:from:to :cc; bh=Ge7hgJuDR1OpL3eSXNKyct/Yzp2Tl/Woy/7gBbj6zjQ=; b=SGe/vI9/qoCqTrH+bcIEubNmK7H5mOii/6aJ7flU0VvoG+l9VpXBTcsBtOfu9zM6Le 7rG86QSqJXdsMmuUrCOYSJY45EaW1zs86TqCiEjOMym4hEd27qd7N1ER72U0Fldirwtk YpiawF0q6cWlEBkdfwtCXrVyUgcpsXlUf6eKEkGBNu5881nqHe+QVg31Bk84i7XPLYom NPJ+n940IN6ugXYoxgScSNzm9aVvwIieFCWVKCi2awubsPBuTyDkz89BFag6+HJgeehc RdF8TuSXEjWNX2szcC9S2t6MQwm8yO/xuEG76vjbEmFccD5UL3F13X6RH/r1n6e2q5wy r82w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=Ge7hgJuDR1OpL3eSXNKyct/Yzp2Tl/Woy/7gBbj6zjQ=; b=uAfuFKh/JZ9pZfesEsdjpEaLiaCHRXwDTCi4/j0ZLemMZodAmuUCmwSasmOr1PdsjY irEWnehsLK9DUV8/z5z1TI/JZZCI7w36naPdA/SBT2LDKfDQZ+D1wK0Ot0+feXfGUo6T 4rdiZZSklJYhVxZD661s8rWSlX436xuMxV0jCP2nAYRcD3v/NphIUP8ZERDZ1DsArR5H AmYsCstTdE6EVDAXak11LOLkDqHTcztzAOGlp4awzm8bTTM40BRIa0cws/8yHH7jsWni gfQtWwGegdiI056NRsiglQOpN/u22ADLbXkILKNI+Y2o3uybgnRDJ4Ms6Kw8HPa00GZK Makg== X-Gm-Message-State: AOAM531KCq5Kz57GMRr5g8Ua2NLh8WuQpMvVy31Y1ooljkLtyudYfNM/ 7GThnKAbzlsvW6IH+QyFE3IJTueKDJnE X-Received: from r2d2-qp.c.googlers.com ([fda3:e722:ac3:cc00:28:9cb1:c0a8:1652]) (user=qperret job=sendgmr) by 2002:a05:6214:2125:: with SMTP id r5mr27655598qvc.28.1622627044088; Wed, 02 Jun 2021 02:44:04 -0700 (PDT) Date: Wed, 2 Jun 2021 09:43:46 +0000 In-Reply-To: <20210602094347.3730846-1-qperret@google.com> Message-Id: <20210602094347.3730846-7-qperret@google.com> Mime-Version: 1.0 References: <20210602094347.3730846-1-qperret@google.com> X-Mailer: git-send-email 2.32.0.rc0.204.g9fa02ecfa5-goog Subject: [PATCH v2 6/7] KVM: arm64: Use less bits for hyp_page order From: Quentin Perret To: maz@kernel.org, will@kernel.org, james.morse@arm.com, alexandru.elisei@arm.com, catalin.marinas@arm.com, suzuki.poulose@arm.com Cc: linux-arm-kernel@lists.infradead.org, kvmarm@lists.cs.columbia.edu, kernel-team@android.com, linux-kernel@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 --- arch/arm64/kvm/hyp/include/nvhe/gfp.h | 6 +++--- arch/arm64/kvm/hyp/include/nvhe/memory.h | 2 +- arch/arm64/kvm/hyp/nvhe/page_alloc.c | 12 ++++++------ 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/arch/arm64/kvm/hyp/include/nvhe/gfp.h b/arch/arm64/kvm/hyp/include/nvhe/gfp.h index 3ea7bfb6c380..fb0f523d1492 100644 --- a/arch/arm64/kvm/hyp/include/nvhe/gfp.h +++ b/arch/arm64/kvm/hyp/include/nvhe/gfp.h @@ -7,7 +7,7 @@ #include #include -#define HYP_NO_ORDER UINT_MAX +#define HYP_NO_ORDER USHRT_MAX struct hyp_pool { /* @@ -19,11 +19,11 @@ struct hyp_pool { struct list_head free_area[MAX_ORDER]; phys_addr_t range_start; phys_addr_t range_end; - unsigned int max_order; + unsigned short max_order; }; /* Allocation */ -void *hyp_alloc_pages(struct hyp_pool *pool, unsigned int order); +void *hyp_alloc_pages(struct hyp_pool *pool, unsigned short order); void hyp_get_page(struct hyp_pool *pool, void *addr); void hyp_put_page(struct hyp_pool *pool, void *addr); diff --git a/arch/arm64/kvm/hyp/include/nvhe/memory.h b/arch/arm64/kvm/hyp/include/nvhe/memory.h index 991636be2f46..3fe34fa30ea4 100644 --- a/arch/arm64/kvm/hyp/include/nvhe/memory.h +++ b/arch/arm64/kvm/hyp/include/nvhe/memory.h @@ -9,7 +9,7 @@ struct hyp_page { unsigned int refcount; - unsigned int order; + unsigned short order; }; extern u64 __hyp_vmemmap; diff --git a/arch/arm64/kvm/hyp/nvhe/page_alloc.c b/arch/arm64/kvm/hyp/nvhe/page_alloc.c index e3689def7033..be07055bbc10 100644 --- a/arch/arm64/kvm/hyp/nvhe/page_alloc.c +++ b/arch/arm64/kvm/hyp/nvhe/page_alloc.c @@ -32,7 +32,7 @@ u64 __hyp_vmemmap; */ static struct hyp_page *__find_buddy_nocheck(struct hyp_pool *pool, struct hyp_page *p, - unsigned int order) + unsigned short order) { phys_addr_t addr = hyp_page_to_phys(p); @@ -51,7 +51,7 @@ static struct hyp_page *__find_buddy_nocheck(struct hyp_pool *pool, /* Find a buddy page currently available for allocation */ static struct hyp_page *__find_buddy_avail(struct hyp_pool *pool, struct hyp_page *p, - unsigned int order) + unsigned short order) { struct hyp_page *buddy = __find_buddy_nocheck(pool, p, order); @@ -93,7 +93,7 @@ static inline struct hyp_page *node_to_page(struct list_head *node) static void __hyp_attach_page(struct hyp_pool *pool, struct hyp_page *p) { - unsigned int order = p->order; + unsigned short order = p->order; struct hyp_page *buddy; memset(hyp_page_to_virt(p), 0, PAGE_SIZE << p->order); @@ -123,7 +123,7 @@ static void __hyp_attach_page(struct hyp_pool *pool, static struct hyp_page *__hyp_extract_page(struct hyp_pool *pool, struct hyp_page *p, - unsigned int order) + unsigned short order) { struct hyp_page *buddy; @@ -192,9 +192,9 @@ void hyp_get_page(struct hyp_pool *pool, void *addr) hyp_spin_unlock(&pool->lock); } -void *hyp_alloc_pages(struct hyp_pool *pool, unsigned int order) +void *hyp_alloc_pages(struct hyp_pool *pool, unsigned short order) { - unsigned int i = order; + unsigned short i = order; struct hyp_page *p; hyp_spin_lock(&pool->lock); -- 2.32.0.rc0.204.g9fa02ecfa5-goog