From: Ma Wupeng mawupeng1@huawei.com
Reserve kabi in preparation for gmem.
Ma Wupeng (3): mm: gmem: kabi reserve for gmem mm: gmem: Introduce new node state N_HETEROGENEOUS openeuler_defconfig: enable CONFIG_GMEM by default
arch/arm64/configs/openeuler_defconfig | 1 + arch/x86/configs/openeuler_defconfig | 1 + drivers/base/node.c | 6 ++++++ include/linux/device.h | 4 ++++ include/linux/mm.h | 8 ++++++++ include/linux/mm_types.h | 5 +++++ include/linux/nodemask.h | 3 +++ mm/Kconfig | 14 ++++++++++++++ mm/page_alloc.c | 3 +++ 9 files changed, 45 insertions(+)
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
From: Ma Wupeng mawupeng1@huawei.com
euleros inclusion category: feature bugzilla: https://gitee.com/openeuler/kernel/issues/I8VAVV CVE: NA
--------------------------------
Introduce new node state N_HETEROGENEOUS to indicate heterogeneous memory devices.
Signed-off-by: Ma Wupeng mawupeng1@huawei.com --- drivers/base/node.c | 6 ++++++ include/linux/nodemask.h | 3 +++ mm/page_alloc.c | 3 +++ 3 files changed, 12 insertions(+)
diff --git a/drivers/base/node.c b/drivers/base/node.c index 493d533f8375..aa4d2ca266aa 100644 --- a/drivers/base/node.c +++ b/drivers/base/node.c @@ -928,6 +928,9 @@ static struct node_attr node_state_attr[] = { [N_CPU] = _NODE_ATTR(has_cpu, N_CPU), [N_GENERIC_INITIATOR] = _NODE_ATTR(has_generic_initiator, N_GENERIC_INITIATOR), +#ifdef CONFIG_GMEM + [N_HETEROGENEOUS] = _NODE_ATTR(has_hetero_memory, N_HETEROGENEOUS), +#endif };
static struct attribute *node_state_attrs[] = { @@ -940,6 +943,9 @@ static struct attribute *node_state_attrs[] = { &node_state_attr[N_MEMORY].attr.attr, &node_state_attr[N_CPU].attr.attr, &node_state_attr[N_GENERIC_INITIATOR].attr.attr, +#ifdef CONFIG_GMEM + &node_state_attr[N_HETEROGENEOUS].attr.attr, +#endif NULL };
diff --git a/include/linux/nodemask.h b/include/linux/nodemask.h index 8d07116caaf1..56dd145de01f 100644 --- a/include/linux/nodemask.h +++ b/include/linux/nodemask.h @@ -407,6 +407,9 @@ enum node_states { N_MEMORY, /* The node has memory(regular, high, movable) */ N_CPU, /* The node has one or more cpus */ N_GENERIC_INITIATOR, /* The node has one or more Generic Initiators */ +#ifdef CONFIG_GMEM + N_HETEROGENEOUS, /* The node has heterogeneous memory */ +#endif NR_NODE_STATES };
diff --git a/mm/page_alloc.c b/mm/page_alloc.c index 42e434224e67..9b5c42b706cf 100644 --- a/mm/page_alloc.c +++ b/mm/page_alloc.c @@ -192,6 +192,9 @@ EXPORT_SYMBOL(latent_entropy); nodemask_t node_states[NR_NODE_STATES] __read_mostly = { [N_POSSIBLE] = NODE_MASK_ALL, [N_ONLINE] = { { [0] = 1UL } }, +#ifdef CONFIG_GMEM + [N_HETEROGENEOUS] = NODE_MASK_NONE, +#endif #ifndef CONFIG_NUMA [N_NORMAL_MEMORY] = { { [0] = 1UL } }, #ifdef CONFIG_HIGHMEM
From: Ma Wupeng mawupeng1@huawei.com
euleros inclusion category: feature bugzilla: https://gitee.com/openeuler/kernel/issues/I8VAVV CVE: NA
--------------------------------
Enable gmem related configs.
Signed-off-by: Ma Wupeng mawupeng1@huawei.com --- arch/arm64/configs/openeuler_defconfig | 1 + arch/x86/configs/openeuler_defconfig | 1 + 2 files changed, 2 insertions(+)
diff --git a/arch/arm64/configs/openeuler_defconfig b/arch/arm64/configs/openeuler_defconfig index 703fe5bc2535..fec4bc9cc5b5 100644 --- a/arch/arm64/configs/openeuler_defconfig +++ b/arch/arm64/configs/openeuler_defconfig @@ -1148,6 +1148,7 @@ CONFIG_ARCH_SUPPORTS_PER_VMA_LOCK=y CONFIG_PER_VMA_LOCK=y CONFIG_LOCK_MM_AND_FIND_VMA=y CONFIG_MEMORY_RELIABLE=y +CONFIG_GMEM=y
# # Data Access Monitoring diff --git a/arch/x86/configs/openeuler_defconfig b/arch/x86/configs/openeuler_defconfig index c9e816e54003..ad7f1dedd2b6 100644 --- a/arch/x86/configs/openeuler_defconfig +++ b/arch/x86/configs/openeuler_defconfig @@ -1163,6 +1163,7 @@ CONFIG_LRU_GEN=y CONFIG_ARCH_SUPPORTS_PER_VMA_LOCK=y CONFIG_PER_VMA_LOCK=y CONFIG_LOCK_MM_AND_FIND_VMA=y +CONFIG_GMEM=y
# # Data Access Monitoring
反馈: 您发送到kernel@openeuler.org的补丁/补丁集,已成功转换为PR! PR链接地址: https://gitee.com/openeuler/kernel/pulls/3952 邮件列表地址:https://mailweb.openeuler.org/hyperkitty/list/kernel@openeuler.org/message/D...
FeedBack: The patch(es) which you have sent to kernel@openeuler.org mailing list has been converted to a pull request successfully! Pull request link: https://gitee.com/openeuler/kernel/pulls/3952 Mailing list address: https://mailweb.openeuler.org/hyperkitty/list/kernel@openeuler.org/message/D...
你这个预留思路有问题啊。
你怎么定义了特性 CONFIG_GMEM,来控制预留啊, 而且你特性模块没有进来,这个 CONFIG 就开了,也不合适啊。
如果要 kabi 预留,就通用的预留就行了。
On 2024/1/12 9:03, Wupeng Ma wrote:
From: Ma Wupeng mawupeng1@huawei.com
Reserve kabi in preparation for gmem.
Ma Wupeng (3): mm: gmem: kabi reserve for gmem mm: gmem: Introduce new node state N_HETEROGENEOUS openeuler_defconfig: enable CONFIG_GMEM by default
arch/arm64/configs/openeuler_defconfig | 1 + arch/x86/configs/openeuler_defconfig | 1 + drivers/base/node.c | 6 ++++++ include/linux/device.h | 4 ++++ include/linux/mm.h | 8 ++++++++ include/linux/mm_types.h | 5 +++++ include/linux/nodemask.h | 3 +++ mm/Kconfig | 14 ++++++++++++++ mm/page_alloc.c | 3 +++ 9 files changed, 45 insertions(+)
On 2024/1/12 11:09, Xie XiuQi wrote:
你这个预留思路有问题啊。
你怎么定义了特性 CONFIG_GMEM,来控制预留啊, 而且你特性模块没有进来,这个 CONFIG 就开了,也不合适啊。
如果要 kabi 预留,就通用的预留就行了。
这个预留是专门给 GMEM 预留,GMEM现在还没和进来,先把KABI预留好,预计这个月尽快合入。 如果 GMEM 占用 通用预留也不太合适
On 2024/1/12 9:03, Wupeng Ma wrote:
From: Ma Wupeng mawupeng1@huawei.com
Reserve kabi in preparation for gmem.
Ma Wupeng (3): mm: gmem: kabi reserve for gmem mm: gmem: Introduce new node state N_HETEROGENEOUS openeuler_defconfig: enable CONFIG_GMEM by default
arch/arm64/configs/openeuler_defconfig | 1 + arch/x86/configs/openeuler_defconfig | 1 + drivers/base/node.c | 6 ++++++ include/linux/device.h | 4 ++++ include/linux/mm.h | 8 ++++++++ include/linux/mm_types.h | 5 +++++ include/linux/nodemask.h | 3 +++ mm/Kconfig | 14 ++++++++++++++ mm/page_alloc.c | 3 +++ 9 files changed, 45 insertions(+)