From patchwork Tue Jun 8 11:45:17 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Quentin Perret X-Patchwork-Id: 12306687 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.9 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_ADSP_CUSTOM_MED,DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS, URIBL_BLOCKED,USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 0FFADC47082 for ; Tue, 8 Jun 2021 12:20:49 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id D08FE61182 for ; Tue, 8 Jun 2021 12:20:48 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org D08FE61182 Authentication-Results: mail.kernel.org; dmarc=fail (p=reject dis=none) header.from=google.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:Cc:To:From:Subject:References: Mime-Version:Message-Id:In-Reply-To:Date:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=MGi/BXwSpYhbw37JbGfKQaBY6aocJdbe5sxVzT2yR+E=; b=U8jhGrrknzn6KvOg+I0xIhqK/c zeTAYOAdR5oY2cBx41Jvf7vEvUkK2IT3bRVbi4QVFzqaCyM0+P5yAq9HkYu5HTwlWgnkyNl7/zjYJ afhXnRyhp1vAVPXb3kZ6sJA43mI4gIL9OPg41ojkrVDXmbPe8j0LxndkQKNaTvZaw/ivZULkioEli /dQ++/5lqsnNLOz0KsJ26qFkUeDVSZWwOOLMDdW5FkoegN97+IH6beNrFLspM8e5IAMeYZlna7WZT Q/a97VMLDaX57wiSE4hi0VhT8LxeFUaBCFEtJ9p7gSNensPBP9OL+YaeyX7yqPmR6QdYqoJZ3RwoP 6Vk2+hkA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1lqagg-008I2V-1x; Tue, 08 Jun 2021 12:18:30 +0000 Received: from mail-wm1-f74.google.com ([209.85.128.74]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1lqaBt-0086fS-Dj for linux-arm-kernel@lists.infradead.org; Tue, 08 Jun 2021 11:46:42 +0000 Received: by mail-wm1-f74.google.com with SMTP id k5-20020a05600c1c85b02901ac8b854c50so645464wms.5 for ; Tue, 08 Jun 2021 04:46:38 -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=5BNxXykWbSSzvgU2PyfVwBVhSOGhRGpGA/8JFAOEVmg=; b=RpPiV66cUY0ERU4ts0ZWRLX6HM855EURR0LBhraB/GG2HQQvfPX5fQ0d+wqECu1yLq BsE7Qc/3grhd+Y7hO/9tzN2u4M7IuO5K5lTpp/JBQnQGhV3/G1ye2lIf895dn6H3e3be wS0Ei7PbgSVXOUPIOPom6v5UkiPp56iUJV37nQoNTAEKbcMhVn/gyg8Sn//+5g5KmWj3 lKFXL1+52EY0b01a6d8k5AOOqf/kDkJSPiz/bLZqz3mIMK/siOA8lcAZXWXMUFDBTg7F VdqnAvUR2UCk5v0EQhE2ze7cx0VNHSnDWjZGyxerqm3ql6BNqZ8v4RfO8LSfHiNFDdWf oGAw== 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=5BNxXykWbSSzvgU2PyfVwBVhSOGhRGpGA/8JFAOEVmg=; b=Su6Mezn6669Pk0CJcZuArHm1GvrMIWqAVtKh7hkqkUgaFYL3QncXFnHehhCmKiGba3 AiRJpvc8hQguC2hB+C+4zpCnUttAEJAdr0SMp0GF+ai84w5K2Aeb+rnZK5WeW1/sLIxy 3MkcRJE1HmnYRiFZlTVmTNgCz8pIHzAvywLDvNzjrmTdMrC4xEQPW+UoL9RvBU507QMR Le0+e1whDT/NpQRi3fugqm/PRn2UpQ2lC+hHLyrjZCcCS/awTyHQP4EI+cdO1+aq1w/P xSnMmK3VmBmpKhq7OOmnT7RtXx/kk7+duAs6wVj61FwPMrwFKO7Tob3W/vk9gXQmB2Rb im/A== X-Gm-Message-State: AOAM532F/QgTvrse2MZ2sAqZClHaQ0DxvH4Bn7FhyqdKvA1YTjq7jpe3 9mEb0uE1zcgejCPJ9mHS87RRMsWi0fQI X-Google-Smtp-Source: ABdhPJxY0xFXprzkSg2IzWugfcreotUMtjfhIgxJAyEAb/go+uRuv0+nLOY4lwHHvo9KG8qAO8hAvcdRsU0b X-Received: from r2d2-qp.c.googlers.com ([fda3:e722:ac3:cc00:28:9cb1:c0a8:1652]) (user=qperret job=sendgmr) by 2002:a7b:cb0b:: with SMTP id u11mr307833wmj.0.1623152737523; Tue, 08 Jun 2021 04:45:37 -0700 (PDT) Date: Tue, 8 Jun 2021 11:45:17 +0000 In-Reply-To: <20210608114518.748712-1-qperret@google.com> Message-Id: <20210608114518.748712-7-qperret@google.com> Mime-Version: 1.0 References: <20210608114518.748712-1-qperret@google.com> X-Mailer: git-send-email 2.32.0.rc1.229.g3e70b5a671-goog Subject: [PATCH v3 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 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210608_044641_507746_94535C50 X-CRM114-Status: GOOD ( 15.79 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.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);