From patchwork Mon Apr 15 03:36:14 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Li RongQing X-Patchwork-Id: 13629426 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 1558FC4345F for ; Mon, 15 Apr 2024 03:36:44 +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:MIME-Version:List-Subscribe:List-Help: List-Post:List-Archive:List-Unsubscribe:List-Id:Message-Id:Date:Subject:Cc:To :From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References: List-Owner; bh=MSROsWocDu4pe2GtDO3t/6zOZZ/cwaGLYy1LcN/sCjQ=; b=t5e7nmWhh5JMsj F3qjJGL08S3A35MBGBK+jmAw/PGENyN+ljvQhQhZE1aBPMCcj85H0GILjK+q9myKSsXuW6WOjoTrs /AcLWH+0rfynKwxD266ZMkFV0EAUsjgmReaWr6hxfs7yEF5qOeBv5DQ855PUQmaPl0hK3bxmyIYxF xUS9W3WXLF0KA94YajYF2rnkey5nQ1gH4tsRn7wdk+VSnps8/omfTYkNDqRldY84/2oLQLC2uEqdi /bnpleGKrmoWGeNTFRdbgqf4oXgkCJUazUXP6C9i5KQKC1G8c1sDrUkzdeUYCLqalWp+nhgmDLsmE eq3cP3bRLSZYlWHoDuVA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rwD8w-00000006sg0-3Alj; Mon, 15 Apr 2024 03:36:30 +0000 Received: from mx315.baidu.com ([180.101.52.204] helo=njjs-sys-mailin01.njjs.baidu.com) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rwD8r-00000006sem-2eRT for linux-arm-kernel@lists.infradead.org; Mon, 15 Apr 2024 03:36:28 +0000 Received: from localhost (bjhw-sys-rpm015653cc5.bjhw.baidu.com [10.227.53.39]) by njjs-sys-mailin01.njjs.baidu.com (Postfix) with ESMTP id C0BEB7F00044; Mon, 15 Apr 2024 11:36:16 +0800 (CST) From: Li RongQing To: maz@kernel.org, oliver.upton@linux.dev, james.morse@arm.com, suzuki.poulose@arm.com, yuzenghui@huawei.com, catalin.marinas@arm.com, will@kernel.org, linux-arm-kernel@lists.infradead.org, kvmarm@lists.linux.dev Cc: Li RongQing Subject: [PATCH] KVM: arm64: Consider NUMA affinity when allocating per-CPU stack_page Date: Mon, 15 Apr 2024 11:36:14 +0800 Message-Id: <20240415033614.43518-1-lirongqing@baidu.com> X-Mailer: git-send-email 2.9.4 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240414_203625_847488_55E4E68D X-CRM114-Status: UNSURE ( 9.23 ) X-CRM114-Notice: Please train this message. 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: , MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org per-CPU stack_page are dominantly accessed from their own local CPUs, so allocate them node-local to improve performance. Signed-off-by: Li RongQing --- arch/arm64/kvm/arm.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/arch/arm64/kvm/arm.c b/arch/arm64/kvm/arm.c index c4a0a35..d745d01 100644 --- a/arch/arm64/kvm/arm.c +++ b/arch/arm64/kvm/arm.c @@ -2330,15 +2330,15 @@ static int __init init_hyp_mode(void) * Allocate stack pages for Hypervisor-mode */ for_each_possible_cpu(cpu) { - unsigned long stack_page; + struct page *page; - stack_page = __get_free_page(GFP_KERNEL); - if (!stack_page) { + page = alloc_pages_node(cpu_to_node(cpu), GFP_KERNEL, 0); + if (!page) { err = -ENOMEM; goto out_err; } - per_cpu(kvm_arm_hyp_stack_page, cpu) = stack_page; + per_cpu(kvm_arm_hyp_stack_page, cpu) = page_address(page); } /*