From patchwork Wed Dec 8 15:22:54 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Quentin Perret X-Patchwork-Id: 12695376 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org 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 smtp.lore.kernel.org (Postfix) with ESMTPS id 9FFC5C433F5 for ; Wed, 8 Dec 2021 15:32:15 +0000 (UTC) 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=uK1B7dZE49rTXBoLmlZuWiEi0nSJTHrzlnI2Zf0M5/w=; b=cLzUV+pcDcL6G8UXNGrLYEL227 gij/KOU2qV33AZTpedroTpVNyiIenY3h0XXP7dQ8NkL5mzdddW6yw0DPk7UQt9P9qIycdOAkCFfSJ uJhVQUOC/egG1BYey+shWxrgPJkEDu3+ubp8HbjrSB1oci6aKSKEXUjr4SVMcz8Vn1VtuFDzHDjJL BUmh5Us0XwfMNZWoFjU6jm5J3bgYvggRK0tmZMdr9CVW5852KAdcI+sN9ahe+UL5JeueSTLGKO5GH K05CkV8IcPCUTLVBn5WxF2lUWo23hrsQy7YJYlJ95Jh09VNHs9YCQKrfIzeeORZmm1uvdjtIX34X3 mcAD9DcA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1muytm-00DGCC-6H; Wed, 08 Dec 2021 15:30:26 +0000 Received: from mail-wm1-x34a.google.com ([2a00:1450:4864:20::34a]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1muymi-00DCfn-GH for linux-arm-kernel@lists.infradead.org; Wed, 08 Dec 2021 15:23:09 +0000 Received: by mail-wm1-x34a.google.com with SMTP id 69-20020a1c0148000000b0033214e5b021so1460966wmb.3 for ; Wed, 08 Dec 2021 07:23:06 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=date:in-reply-to:message-id:mime-version:references:subject:from:to :cc; bh=r27uQnQQtVbS3yI0XEL7/R9cqNgVk61W5XrAJ0Nw0Ww=; b=naFD9LicXyODJErTfR403GKq7ei5lGkVN74aV1AhQuJdG7N+BLYc8N+bJ37PaGYh39 SdctqEgFuCTMuF5FWpGFNJe/hL1KT7NEPGKmw8HIn2GMoXMiktzuHvhDjfo+P9wZLdDt 5mw45WlmYwCXT+ULUp/dRM12JoD6391Z4YYbBoWBD6E9W4TdWHwOmw+tuxk8VfsoPUFq FlUeaULBj+v/FzA7O1ubmKEHblv0W4KcYDQGhFM7mk6rf2k4sbm5nlj1FelFQx4kRRdl NCC26n15GXzmRdPue/vf6hJbdDqylJoqp5mGGTGvvUXzyNqZvoRj2euYDhHpZumkY6tV 0qIg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=r27uQnQQtVbS3yI0XEL7/R9cqNgVk61W5XrAJ0Nw0Ww=; b=EWrrzyO8FSv+xTuaOkMO5SVBA8aSV3hzYypMK6FwmKf4lgUxk1YWJxNM5aQ8t7hlnQ Eld1XdRTootvw4NSj2o2MF+hnuunN9TW+8+tcXQOki2Hj2RCMeD2ikVNFzDfO3/WFLDQ MYVHmcfOnO8dOJfXsgVhsTWxxyWl/WAlhIJrp2rZO3ZqSX+0WFhdSHEMVQSgKkV964kA eGb0obg86btzdgeNl36Sjg+UvMZFN4nTMAV7veMlv9k6peW1E9CwhAZcWXy5RYhfMy1z Y3u4RXPfSxn6rSugAFL+XXGqbLQjBJYFufI+/Kldq6slDXRWmO2VWAWtTeGfb+wCgLRx Xb6Q== X-Gm-Message-State: AOAM532pX1k56mW6FiPMb6ojtv/Qk4Bx80Ak4g80xvVC6vqpVn/BNSjs +Pc+DoXV9arh6z0u5Kwl8dBqV1OTa7jF X-Google-Smtp-Source: ABdhPJyVBhdRR4oxaKYKZEdM1jxQ1KGBiBeRjA9M0nAxRA3k7kRNUlf5UDHP+FOncXY+IqD/xhb12Q9Uy29Q X-Received: from luke.lon.corp.google.com ([2a00:79e0:d:210:c718:14b8:982a:57d5]) (user=qperret job=sendgmr) by 2002:a5d:4d8b:: with SMTP id b11mr58840186wru.393.1638976985582; Wed, 08 Dec 2021 07:23:05 -0800 (PST) Date: Wed, 8 Dec 2021 15:22:54 +0000 In-Reply-To: <20211208152300.2478542-1-qperret@google.com> Message-Id: <20211208152300.2478542-2-qperret@google.com> Mime-Version: 1.0 References: <20211208152300.2478542-1-qperret@google.com> X-Mailer: git-send-email 2.34.1.400.ga245620fadb-goog Subject: [PATCH 1/6] KVM: arm64: pkvm: Fix hyp_pool max order From: Quentin Perret To: Marc Zyngier , James Morse , Alexandru Elisei , Suzuki K Poulose , Catalin Marinas , Will Deacon Cc: linux-arm-kernel@lists.infradead.org, kvmarm@lists.cs.columbia.edu, linux-kernel@vger.kernel.org, kernel-team@android.com, qperret@google.com X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20211208_072308_581075_54A23931 X-CRM114-Status: GOOD ( 12.42 ) 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 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: Quentin Perret Acked-by: Will Deacon --- arch/arm64/kvm/hyp/nvhe/page_alloc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/arm64/kvm/hyp/nvhe/page_alloc.c b/arch/arm64/kvm/hyp/nvhe/page_alloc.c index 0bd7701ad1df..543cad6c376a 100644 --- a/arch/arm64/kvm/hyp/nvhe/page_alloc.c +++ b/arch/arm64/kvm/hyp/nvhe/page_alloc.c @@ -241,7 +241,7 @@ int hyp_pool_init(struct hyp_pool *pool, u64 pfn, unsigned int nr_pages, int i; 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++) INIT_LIST_HEAD(&pool->free_area[i]); pool->range_start = phys;