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 80bacc4da324..af0ac70dd1bc 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 0bc3c7c191a5..354a86c6d2b3 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>
@@ -936,6 +937,10 @@ struct mm_struct { #endif /* CONFIG_LRU_GEN */ #ifdef CONFIG_SHARE_POOL struct sp_group_master *sp_group_master; +#endif +#ifdef CONFIG_GMEM + KABI_RESERVE(gmem_0) + KABI_RESERVE(gmem_1) #endif } __randomize_layout;
diff --git a/mm/Kconfig b/mm/Kconfig index c277bb069ab7..01e461337495 100644 --- a/mm/Kconfig +++ b/mm/Kconfig @@ -1348,6 +1348,20 @@ config CLEAR_FREELIST_PAGE To enable this feature, kernel parameter "clear_freelist" also needs to be added.
+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