Skip to content

Commit 90167e9

Browse files
lrq-maxIngo Molnar
authored andcommitted
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 <[email protected]> Signed-off-by: Ingo Molnar <[email protected]> Cc: Nikunj A Dadhania <[email protected]> Cc: Kirill A. Shutemov <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Ingo Molnar <[email protected]>
1 parent 21f546a commit 90167e9

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

arch/x86/kernel/sev.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -938,7 +938,7 @@ static int snp_set_vmsa(void *va, bool vmsa)
938938
#define INIT_LDTR_ATTRIBS (SVM_SELECTOR_P_MASK | 2)
939939
#define INIT_TR_ATTRIBS (SVM_SELECTOR_P_MASK | 3)
940940

941-
static void *snp_alloc_vmsa_page(void)
941+
static void *snp_alloc_vmsa_page(int cpu)
942942
{
943943
struct page *p;
944944

@@ -950,7 +950,7 @@ static void *snp_alloc_vmsa_page(void)
950950
*
951951
* Allocate an 8k page which is also 8k-aligned.
952952
*/
953-
p = alloc_pages(GFP_KERNEL_ACCOUNT | __GFP_ZERO, 1);
953+
p = alloc_pages_node(cpu_to_node(cpu), GFP_KERNEL_ACCOUNT | __GFP_ZERO, 1);
954954
if (!p)
955955
return NULL;
956956

@@ -1019,7 +1019,7 @@ static int wakeup_cpu_via_vmgexit(u32 apic_id, unsigned long start_ip)
10191019
* #VMEXIT of that vCPU would wipe out all of the settings being done
10201020
* here.
10211021
*/
1022-
vmsa = (struct sev_es_save_area *)snp_alloc_vmsa_page();
1022+
vmsa = (struct sev_es_save_area *)snp_alloc_vmsa_page(cpu);
10231023
if (!vmsa)
10241024
return -ENOMEM;
10251025

@@ -1341,7 +1341,7 @@ static void __init alloc_runtime_data(int cpu)
13411341
{
13421342
struct sev_es_runtime_data *data;
13431343

1344-
data = memblock_alloc(sizeof(*data), PAGE_SIZE);
1344+
data = memblock_alloc_node(sizeof(*data), PAGE_SIZE, cpu_to_node(cpu));
13451345
if (!data)
13461346
panic("Can't allocate SEV-ES runtime data");
13471347

0 commit comments

Comments
 (0)