From: Ma Wupeng mawupeng1@huawei.com
euleros inclusion category: feature bugzilla: https://gitee.com/openeuler/kernel/issues/I8VAVV CVE: NA
--------------------------------
Reserve kabi in preparation for gmem.
Signed-off-by: Ma Wupeng mawupeng1@huawei.com --- include/linux/device.h | 4 ++++ include/linux/mm.h | 8 ++++++++ include/linux/mm_types.h | 5 +++++ mm/Kconfig | 14 ++++++++++++++ 4 files changed, 31 insertions(+)
diff --git a/include/linux/device.h b/include/linux/device.h index 56d93a1ffb7b..f88b261652d5 100644 --- a/include/linux/device.h +++ b/include/linux/device.h @@ -31,6 +31,7 @@ #include <linux/device/class.h> #include <linux/device/driver.h> #include <linux/cleanup.h> +#include <linux/kabi.h> #include <asm/device.h>
struct device; @@ -805,6 +806,9 @@ struct device { #ifdef CONFIG_DMA_OPS_BYPASS bool dma_ops_bypass : 1; #endif +#ifdef CONFIG_GMEM + KABI_RESERVE(gmem_0) +#endif };
/** diff --git a/include/linux/mm.h b/include/linux/mm.h index c00def598f95..5c49fb4091d7 100644 --- a/include/linux/mm.h +++ b/include/linux/mm.h @@ -327,12 +327,14 @@ extern unsigned int kobjsize(const void *objp); #define VM_HIGH_ARCH_BIT_3 35 /* bit only usable on 64-bit architectures */ #define VM_HIGH_ARCH_BIT_4 36 /* bit only usable on 64-bit architectures */ #define VM_HIGH_ARCH_BIT_5 37 /* bit only usable on 64-bit architectures */ +#define VM_HIGH_ARCH_BIT_24 56 /* bit only usable on 64-bit architectures */ #define VM_HIGH_ARCH_0 BIT(VM_HIGH_ARCH_BIT_0) #define VM_HIGH_ARCH_1 BIT(VM_HIGH_ARCH_BIT_1) #define VM_HIGH_ARCH_2 BIT(VM_HIGH_ARCH_BIT_2) #define VM_HIGH_ARCH_3 BIT(VM_HIGH_ARCH_BIT_3) #define VM_HIGH_ARCH_4 BIT(VM_HIGH_ARCH_BIT_4) #define VM_HIGH_ARCH_5 BIT(VM_HIGH_ARCH_BIT_5) +#define VM_HIGH_ARCH_24 BIT(VM_HIGH_ARCH_BIT_24) #endif /* CONFIG_ARCH_USES_HIGH_VMA_FLAGS */
#ifdef CONFIG_ARCH_HAS_PKEYS @@ -363,6 +365,12 @@ extern unsigned int kobjsize(const void *objp); # define VM_SHADOW_STACK VM_NONE #endif
+#ifdef CONFIG_GMEM +#define VM_PEER_SHARED VM_HIGH_ARCH_24 +#else +#define VM_PEER_SHARED VM_NONE +#endif + #if defined(CONFIG_X86) # define VM_PAT VM_ARCH_1 /* PAT reserves whole VMA at once (x86) */ #elif defined(CONFIG_PPC) diff --git a/include/linux/mm_types.h b/include/linux/mm_types.h index a077f60819d9..7aca9dc3c242 100644 --- a/include/linux/mm_types.h +++ b/include/linux/mm_types.h @@ -19,6 +19,7 @@ #include <linux/workqueue.h> #include <linux/seqlock.h> #include <linux/percpu_counter.h> +#include <linux/kabi.h>
#include <asm/mmu.h>
@@ -940,6 +941,10 @@ struct mm_struct { #ifdef CONFIG_MEMORY_RELIABLE /* total used reliable pages */ atomic_long_t reliable_nr_page; +#endif +#ifdef CONFIG_GMEM + KABI_RESERVE(gmem_0) + KABI_RESERVE(gmem_1) #endif } __randomize_layout;
diff --git a/mm/Kconfig b/mm/Kconfig index 2df11b146c84..2f53a2787acb 100644 --- a/mm/Kconfig +++ b/mm/Kconfig @@ -1365,6 +1365,20 @@ config MEMORY_RELIABLE To enable this function, mirrored memory is needed and "kernelcore=reliable" need to be added in kernel parameters.
+config GMEM + bool "generalized memory management for external memory devices" + depends on (ARM64 || X86_64) && MMU && TRANSPARENT_HUGEPAGE + select ARCH_USES_HIGH_VMA_FLAGS + default y + help + Supporting GMEM (generalized memory management) for external memory + devices + + GMEM extends Linux MM to share its machine-independent MM code. Only + high-level interface is provided for device drivers. This prevents + accelerator drivers from reinventing the wheel, but relies on drivers to + implement their hardware-dependent functions declared by GMEM. + source "mm/damon/Kconfig"
endmenu