From: Artem Kuzin <artem.kuzin@xxxxxxxxxx> Co-developed-by: Nikita Panov <nikita.panov@xxxxxxxxxxxxxxxxxxx> Signed-off-by: Nikita Panov <nikita.panov@xxxxxxxxxxxxxxxxxxx> Co-developed-by: Alexander Grubnikov <alexander.grubnikov@xxxxxxxxxx> Signed-off-by: Alexander Grubnikov <alexander.grubnikov@xxxxxxxxxx> Signed-off-by: Artem Kuzin <artem.kuzin@xxxxxxxxxx> --- include/linux/mm_types.h | 11 ++++++++++- mm/Kconfig | 10 ++++++++++ 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/include/linux/mm_types.h b/include/linux/mm_types.h index 7d30dc4ff0ff..1fafb8425994 100644 --- a/include/linux/mm_types.h +++ b/include/linux/mm_types.h @@ -22,6 +22,8 @@ #include <asm/mmu.h> +#include <linux/numa.h> + #ifndef AT_VECTOR_SIZE_ARCH #define AT_VECTOR_SIZE_ARCH 0 #endif @@ -626,7 +628,14 @@ struct mm_struct { unsigned long mmap_compat_legacy_base; #endif unsigned long task_size; /* size of task vm space */ - pgd_t * pgd; +#ifndef CONFIG_KERNEL_REPLICATION + pgd_t *pgd; +#else + union { + pgd_t *pgd; + pgd_t *pgd_numa[MAX_NUMNODES]; + }; +#endif #ifdef CONFIG_MEMBARRIER /** diff --git a/mm/Kconfig b/mm/Kconfig index 09130434e30d..5fe5b3ba7f99 100644 --- a/mm/Kconfig +++ b/mm/Kconfig @@ -1236,6 +1236,16 @@ config LOCK_MM_AND_FIND_VMA bool depends on !STACK_GROWSUP +config KERNEL_REPLICATION + bool "Enable kernel text and ro-data replication between NUMA nodes" + default n + depends on (X86_64 && !(KASAN && X86_5LEVEL)) && MMU && NUMA && !MAXSMP + + help + Creates per-NUMA node replicas of kernel text and rodata sections. + Page tables are replicated partially, according to replicated kernel memory range. + If unsure, say "n". + source "mm/damon/Kconfig" endmenu -- 2.34.1