* [PATCH] x86/sev: take NUMA node into account when allocating memory for per-CPU variables
@ 2024-04-12 3:01 Li RongQing
2024-04-12 9:30 ` [tip: x86/cpu] x86/sev: Take NUMA node into account when allocating memory for per-CPU SEV data tip-bot2 for Li RongQing
2024-04-12 10:21 ` [tip: x86/merge] " tip-bot2 for Li RongQing
0 siblings, 2 replies; 3+ messages in thread
From: Li RongQing @ 2024-04-12 3:01 UTC (permalink / raw)
To: tglx, mingo, bp, dave.hansen, x86, peterz, linux-kernel; +Cc: Li RongQing
per-CPU variables are dominantly accessed from their own local CPUs,
so allocate them node-local to improve performance.
Signed-off-by: Li RongQing <lirongqing@baidu.com>
---
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
^ permalink raw reply related [flat|nested] 3+ messages in thread
* [tip: x86/cpu] x86/sev: Take NUMA node into account when allocating memory for per-CPU SEV data
2024-04-12 3:01 [PATCH] x86/sev: take NUMA node into account when allocating memory for per-CPU variables Li RongQing
@ 2024-04-12 9:30 ` tip-bot2 for Li RongQing
2024-04-12 10:21 ` [tip: x86/merge] " tip-bot2 for Li RongQing
1 sibling, 0 replies; 3+ messages in thread
From: tip-bot2 for Li RongQing @ 2024-04-12 9:30 UTC (permalink / raw)
To: linux-tip-commits
Cc: Li RongQing, Ingo Molnar, Nikunj A Dadhania, Kirill A. Shutemov,
x86, linux-kernel
The following commit has been merged into the x86/cpu branch of tip:
Commit-ID: 426565279f161631cbb4b925660540bdb65f2201
Gitweb: https://git.kernel.org/tip/426565279f161631cbb4b925660540bdb65f2201
Author: Li RongQing <lirongqing@baidu.com>
AuthorDate: Fri, 12 Apr 2024 11:01:30 +08:00
Committer: Ingo Molnar <mingo@kernel.org>
CommitterDate: Fri, 12 Apr 2024 11:25:26 +02:00
x86/sev: Take NUMA node into account when allocating memory for per-CPU SEV data
per-CPU SEV data is dominantly accessed from their own local CPUs,
so allocate them node-local to improve performance.
Signed-off-by: Li RongQing <lirongqing@baidu.com>
Signed-off-by: Ingo Molnar <mingo@kernel.org>
Cc: Nikunj A Dadhania <nikunj@amd.com>
Cc: Kirill A. Shutemov <kirill.shutemov@linux.intel.com>
Link: https://lore.kernel.org/r/20240412030130.49704-1-lirongqing@baidu.com
---
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 38ad066..995f944 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");
^ permalink raw reply related [flat|nested] 3+ messages in thread
* [tip: x86/merge] x86/sev: Take NUMA node into account when allocating memory for per-CPU SEV data
2024-04-12 3:01 [PATCH] x86/sev: take NUMA node into account when allocating memory for per-CPU variables Li RongQing
2024-04-12 9:30 ` [tip: x86/cpu] x86/sev: Take NUMA node into account when allocating memory for per-CPU SEV data tip-bot2 for Li RongQing
@ 2024-04-12 10:21 ` tip-bot2 for Li RongQing
1 sibling, 0 replies; 3+ messages in thread
From: tip-bot2 for Li RongQing @ 2024-04-12 10:21 UTC (permalink / raw)
To: linux-tip-commits
Cc: Li RongQing, Ingo Molnar, Nikunj A Dadhania, Kirill A. Shutemov,
x86, linux-kernel
The following commit has been merged into the x86/merge branch of tip:
Commit-ID: 90167e96588df747c9b47a04ebac59b71e3b413f
Gitweb: https://git.kernel.org/tip/90167e96588df747c9b47a04ebac59b71e3b413f
Author: Li RongQing <lirongqing@baidu.com>
AuthorDate: Fri, 12 Apr 2024 11:01:30 +08:00
Committer: Ingo Molnar <mingo@kernel.org>
CommitterDate: Fri, 12 Apr 2024 12:12:11 +02:00
x86/sev: Take NUMA node into account when allocating memory for per-CPU SEV data
per-CPU SEV data is dominantly accessed from their own local CPUs,
so allocate them node-local to improve performance.
Signed-off-by: Li RongQing <lirongqing@baidu.com>
Signed-off-by: Ingo Molnar <mingo@kernel.org>
Cc: Nikunj A Dadhania <nikunj@amd.com>
Cc: Kirill A. Shutemov <kirill.shutemov@linux.intel.com>
Link: https://lore.kernel.org/r/20240412030130.49704-1-lirongqing@baidu.com
Signed-off-by: Ingo Molnar <mingo@kernel.org>
---
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 38ad066..995f944 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");
^ permalink raw reply related [flat|nested] 3+ messages in thread
end of thread, other threads:[~2024-04-12 10:21 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-04-12 3:01 [PATCH] x86/sev: take NUMA node into account when allocating memory for per-CPU variables Li RongQing
2024-04-12 9:30 ` [tip: x86/cpu] x86/sev: Take NUMA node into account when allocating memory for per-CPU SEV data tip-bot2 for Li RongQing
2024-04-12 10:21 ` [tip: x86/merge] " tip-bot2 for Li RongQing
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).