Received: by 2002:ab2:7407:0:b0:1f4:b336:87c4 with SMTP id e7csp196601lqn; Thu, 11 Apr 2024 20:17:11 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCWGRKIRRZL3jUJ3b2V5y8Z0nDwkJSnWuJCBkrMRbTXz7iFOSVLZ+2jR+7gp4i3lEtq2MIcMWiayxEO1bwg8hl9BzGgdrWhYpW7UJqPAwA== X-Google-Smtp-Source: AGHT+IGwyv4X8TS7jU8wEHvq0qUNTSoo7KBpk97+6M+31eFks4ZBu1XGCtNYi0SRf5aAuhQrB6Cj X-Received: by 2002:a05:6870:4597:b0:22e:dfbc:4d90 with SMTP id y23-20020a056870459700b0022edfbc4d90mr1386846oao.5.1712891830818; Thu, 11 Apr 2024 20:17:10 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1712891830; cv=pass; d=google.com; s=arc-20160816; b=0iMs6uI99QMLNXhvT3UnmFI+NWKMF/7fvd0kXxWict457vpKF9MMB75ENMT4wb3PMc Yq/RMNNdLVPVmYsgxZ/CkhhZgK9Xbn497pzfZdylrITv/o2HaS1Fn7vJ1VW8IHxUSr4U S8Kx8AR02tezcaqlpDSUL4/Q5hB9AptglsYcapF92YOJLomlKXsNnvY/4QNWFBbXcwM8 N42F2ZiP0a2jO95BMfIa69nkPsliGKhm7BZ7lZMhAHDCD3gq0qAUMcQM4sKPid2h1DVP u7lClpehG8DZS9UwfhyEA9yjXUkQ7h31GeaRHtZ4nqdpxG4jaxKyme/1X1I8H232bA0y 1RNg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-unsubscribe:list-subscribe:list-id:precedence:message-id:date :subject:cc:to:from; bh=Cwv+D9K29xmc/90+xN/1VagrqMcCmZRIYGMuX3bi+qo=; fh=sCfFVBuY9ektHD/YKZrsp/A2qX1he7IhW+r/7z+/yw8=; b=zs8uregv8uOIjFCGfo3UviNudvnuyh7GfYDPLrJuk81R/1hweXp/Sp8liTu2Ajboh1 o0Gb0rkF9R+zBKEmfiqqQX81vt3in3JAF/fqcEWlUURVc4EeCFDWeHGUfPMm4NJbP1zU d65beagXxrbiVSCl+KhQDYAHfTtM7wGFg97bVX8693vRhosKuAJcwRbpkVekMKzigFbA 7yNkgKqR7a5Qp28+VzAVEhQbpgZVRqU359qWJ8ojq2Sv0dPwCDP0ocSdOzZ6Lt4phGmi NBqy/Nq2oFgKUVLd8JhPUw8ea3ANZJ5+EDtoH/FkbPh7jjkg0dWip+hSd2Hu59U9pyWd qwIw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1 spf=pass spfdomain=baidu.com dmarc=pass fromdomain=baidu.com); spf=pass (google.com: domain of linux-kernel+bounces-141852-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-141852-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=baidu.com Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id gd6-20020a056a00830600b006eaa8f9b018si2477832pfb.241.2024.04.11.20.17.10 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 11 Apr 2024 20:17:10 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-141852-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; arc=pass (i=1 spf=pass spfdomain=baidu.com dmarc=pass fromdomain=baidu.com); spf=pass (google.com: domain of linux-kernel+bounces-141852-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-141852-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=baidu.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id 7B9F4286B77 for ; Fri, 12 Apr 2024 03:17:10 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 03623156C2; Fri, 12 Apr 2024 03:17:06 +0000 (UTC) Received: from njjs-sys-mailin01.njjs.baidu.com (mx309.baidu.com [180.101.52.12]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 8AFEA12E4E for ; Fri, 12 Apr 2024 03:16:58 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=180.101.52.12 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712891825; cv=none; b=Wl5mTXtHmwRfZgHhbPUuV/C2Oex/JekBAJ2SU8utIrUVnhCWI7ZXWlIIe1eFFgcxmTXcafJmmzq+kduAPt6JBWTxLwqTfQdSrRqYFIaqsCw/7jq+/3zjm+tddkK7jvmZgSjC1L3tVSvhxfci6ZLFxVQfUh1lWKCghURrQGwvkmE= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712891825; c=relaxed/simple; bh=ZbqwmPgrkigCftAY4kWOWC9DW9S6DixYjAuHCk5fars=; h=From:To:Cc:Subject:Date:Message-Id; b=iEc3erhkJhUVVZgn8E4N6jKIpGy3aFMqXg450oQuRb9bY/AiGkr7dsjd9KskUfwekbUqaLMArry2qf68tJa3ZBnrMHZwY6GcDbcuZY26tspjiuyVr5TRc4/inClGzd0AWY9vENZ6mImCZLQON9K9UJWXIjwhRylQkZd13dZDxn4= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=baidu.com; spf=pass smtp.mailfrom=baidu.com; arc=none smtp.client-ip=180.101.52.12 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=baidu.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=baidu.com Received: from localhost (bjhw-sys-rpm015653cc5.bjhw.baidu.com [10.227.53.39]) by njjs-sys-mailin01.njjs.baidu.com (Postfix) with ESMTP id 462317F00043; Fri, 12 Apr 2024 11:01:32 +0800 (CST) From: Li RongQing To: tglx@linutronix.de, mingo@redhat.com, bp@alien8.de, dave.hansen@linux.intel.com, x86@kernel.org, peterz@infradead.org, linux-kernel@vger.kernel.org Cc: Li RongQing Subject: [PATCH] x86/sev: take NUMA node into account when allocating memory for per-CPU variables Date: Fri, 12 Apr 2024 11:01:30 +0800 Message-Id: <20240412030130.49704-1-lirongqing@baidu.com> X-Mailer: git-send-email 2.9.4 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: per-CPU variables are dominantly accessed from their own local CPUs, so allocate them node-local to improve performance. Signed-off-by: Li RongQing --- arch/x86/kernel/sev.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/arch/x86/kernel/sev.c b/arch/x86/kernel/sev.c index 7e1e63cc..dfe7c69 100644 --- a/arch/x86/kernel/sev.c +++ b/arch/x86/kernel/sev.c @@ -938,7 +938,7 @@ static int snp_set_vmsa(void *va, bool vmsa) #define INIT_LDTR_ATTRIBS (SVM_SELECTOR_P_MASK | 2) #define INIT_TR_ATTRIBS (SVM_SELECTOR_P_MASK | 3) -static void *snp_alloc_vmsa_page(void) +static void *snp_alloc_vmsa_page(int cpu) { struct page *p; @@ -950,7 +950,7 @@ static void *snp_alloc_vmsa_page(void) * * Allocate an 8k page which is also 8k-aligned. */ - p = alloc_pages(GFP_KERNEL_ACCOUNT | __GFP_ZERO, 1); + p = alloc_pages_node(cpu_to_node(cpu), GFP_KERNEL_ACCOUNT | __GFP_ZERO, 1); if (!p) return NULL; @@ -1019,7 +1019,7 @@ static int wakeup_cpu_via_vmgexit(u32 apic_id, unsigned long start_ip) * #VMEXIT of that vCPU would wipe out all of the settings being done * here. */ - vmsa = (struct sev_es_save_area *)snp_alloc_vmsa_page(); + vmsa = (struct sev_es_save_area *)snp_alloc_vmsa_page(cpu); if (!vmsa) return -ENOMEM; @@ -1341,7 +1341,7 @@ static void __init alloc_runtime_data(int cpu) { struct sev_es_runtime_data *data; - data = memblock_alloc(sizeof(*data), PAGE_SIZE); + data = memblock_alloc_node(sizeof(*data), PAGE_SIZE, cpu_to_node(cpu)); if (!data) panic("Can't allocate SEV-ES runtime data"); -- 2.9.4