hulk inclusion category: feature bugzilla: https://gitee.com/openeuler/kernel/issues/I91BZS
--------------------------------
There are many memory media, and some memory is dedicated. To distinguish it from oridinary memory, add new zone_type ZONE_EXTMEM to manage it.
This patch is only for reserving new zone type to avoid kabi broken.
Signed-off-by: Liu Shixin liushixin2@huawei.com --- include/linux/gfp.h | 24 ++++++++++++++++-------- include/linux/mmzone.h | 3 +++ include/trace/events/mmflags.h | 7 +++++++ mm/Kconfig | 12 ++++++++++++ mm/page_alloc.c | 6 ++++++ 5 files changed, 44 insertions(+), 8 deletions(-)
diff --git a/include/linux/gfp.h b/include/linux/gfp.h index 83a75c7344c3..85f9c8f263ac 100644 --- a/include/linux/gfp.h +++ b/include/linux/gfp.h @@ -98,15 +98,21 @@ static inline bool gfpflags_allow_blocking(const gfp_t gfp_flags) #error GFP_ZONES_SHIFT too large to create GFP_ZONE_TABLE integer #endif
+#if GFP_ZONES_SHIFT >= 3 +#define TABLE_TYPE(X) ((uint64_t)X) +#else +#define TABLE_TYPE(X) X +#endif + #define GFP_ZONE_TABLE ( \ - (ZONE_NORMAL << 0 * GFP_ZONES_SHIFT) \ - | (OPT_ZONE_DMA << ___GFP_DMA * GFP_ZONES_SHIFT) \ - | (OPT_ZONE_HIGHMEM << ___GFP_HIGHMEM * GFP_ZONES_SHIFT) \ - | (OPT_ZONE_DMA32 << ___GFP_DMA32 * GFP_ZONES_SHIFT) \ - | (ZONE_NORMAL << ___GFP_MOVABLE * GFP_ZONES_SHIFT) \ - | (OPT_ZONE_DMA << (___GFP_MOVABLE | ___GFP_DMA) * GFP_ZONES_SHIFT) \ - | (ZONE_MOVABLE << (___GFP_MOVABLE | ___GFP_HIGHMEM) * GFP_ZONES_SHIFT)\ - | (OPT_ZONE_DMA32 << (___GFP_MOVABLE | ___GFP_DMA32) * GFP_ZONES_SHIFT)\ + (TABLE_TYPE(ZONE_NORMAL) << 0 * GFP_ZONES_SHIFT) \ + | (TABLE_TYPE(OPT_ZONE_DMA) << ___GFP_DMA * GFP_ZONES_SHIFT) \ + | (TABLE_TYPE(OPT_ZONE_HIGHMEM) << ___GFP_HIGHMEM * GFP_ZONES_SHIFT) \ + | (TABLE_TYPE(OPT_ZONE_DMA32) << ___GFP_DMA32 * GFP_ZONES_SHIFT) \ + | (TABLE_TYPE(ZONE_NORMAL) << ___GFP_MOVABLE * GFP_ZONES_SHIFT) \ + | (TABLE_TYPE(OPT_ZONE_DMA) << (___GFP_MOVABLE | ___GFP_DMA) * GFP_ZONES_SHIFT) \ + | (TABLE_TYPE(ZONE_MOVABLE) << (___GFP_MOVABLE | ___GFP_HIGHMEM) * GFP_ZONES_SHIFT) \ + | (TABLE_TYPE(OPT_ZONE_DMA32) << (___GFP_MOVABLE | ___GFP_DMA32) * GFP_ZONES_SHIFT) \ )
/* @@ -143,6 +149,8 @@ static inline enum zone_type gfp_zone(gfp_t flags) return z; }
+#undef TABLE_TYPE + /* * There is only one page-allocator function, and two main namespaces to * it. The alloc_page*() variants return 'struct page *' and as such diff --git a/include/linux/mmzone.h b/include/linux/mmzone.h index 40cfd2f0600f..655157b32fa6 100644 --- a/include/linux/mmzone.h +++ b/include/linux/mmzone.h @@ -777,6 +777,9 @@ enum zone_type { * access. */ ZONE_HIGHMEM, +#endif +#ifdef CONFIG_ZONE_EXTMEM + ZONE_EXTMEM, #endif /* * ZONE_MOVABLE is similar to ZONE_NORMAL, except that it contains diff --git a/include/trace/events/mmflags.h b/include/trace/events/mmflags.h index 37962289a7a5..998a5c590325 100644 --- a/include/trace/events/mmflags.h +++ b/include/trace/events/mmflags.h @@ -275,11 +275,18 @@ IF_HAVE_VM_USWAP(VM_USWAP, "userswap" ) \ #define IFDEF_ZONE_HIGHMEM(X) #endif
+#ifdef CONFIG_ZONE_EXTMEM +#define IFDEF_ZONE_EXTMEM(X) X +#else +#define IFDEF_ZONE_EXTMEM(X) +#endif + #define ZONE_TYPE \ IFDEF_ZONE_DMA( EM (ZONE_DMA, "DMA")) \ IFDEF_ZONE_DMA32( EM (ZONE_DMA32, "DMA32")) \ EM (ZONE_NORMAL, "Normal") \ IFDEF_ZONE_HIGHMEM( EM (ZONE_HIGHMEM,"HighMem")) \ + IFDEF_ZONE_EXTMEM( EM (ZONE_EXTMEM, "ExtMem")) \ EMe(ZONE_MOVABLE,"Movable")
#define LRU_NAMES \ diff --git a/mm/Kconfig b/mm/Kconfig index 748c774c1c97..b6a44aa8e33c 100644 --- a/mm/Kconfig +++ b/mm/Kconfig @@ -1060,6 +1060,18 @@ config ZONE_DEVICE
If FS_DAX is enabled, then say Y.
+config ZONE_EXTMEM + bool "Extension memory hotplug support" + default n + depends on MEMORY_HOTPLUG + depends on MEMORY_HOTREMOVE + depends on ARM64 + help + Extension memory hotplug support allows for customizing memory + policy such as UB or CXL memory, mirroring memory, etc. + + If unsure, say N. + # # Helpers to mirror range of the CPU page tables of a process into device page # tables. diff --git a/mm/page_alloc.c b/mm/page_alloc.c index da0ac870a3a9..c68eb753d97a 100644 --- a/mm/page_alloc.c +++ b/mm/page_alloc.c @@ -252,6 +252,9 @@ static int sysctl_lowmem_reserve_ratio[MAX_NR_ZONES] = { [ZONE_NORMAL] = 32, #ifdef CONFIG_HIGHMEM [ZONE_HIGHMEM] = 0, +#endif +#ifdef CONFIG_ZONE_EXTMEM + [ZONE_EXTMEM] = 0, #endif [ZONE_MOVABLE] = 0, }; @@ -266,6 +269,9 @@ char * const zone_names[MAX_NR_ZONES] = { "Normal", #ifdef CONFIG_HIGHMEM "HighMem", +#endif +#ifdef CONFIG_ZONE_EXTMEM + "ExtMem", #endif "Movable", #ifdef CONFIG_ZONE_DEVICE