diff --git a/arch/arm64/configs/openeuler_defconfig b/arch/arm64/configs/openeuler_defconfig index eb65de2f5a09756c247982ecd278703d91d2fd48..a2717f8f5fce5960482a7f29523b1b2576fabec1 100644 --- a/arch/arm64/configs/openeuler_defconfig +++ b/arch/arm64/configs/openeuler_defconfig @@ -1139,6 +1139,7 @@ CONFIG_ARCH_HAS_ZONE_DMA_SET=y CONFIG_ZONE_DMA=y CONFIG_ZONE_DMA32=y CONFIG_ZONE_DEVICE=y +CONFIG_ZONE_EXTMEM=y CONFIG_HMM_MIRROR=y CONFIG_GET_FREE_REGION=y CONFIG_DEVICE_PRIVATE=y diff --git a/include/linux/gfp.h b/include/linux/gfp.h index 83a75c7344c35cb918e91cf56a9d8fec32cff489..85f9c8f263acc9b9975056e506fa0f1fd0e984be 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 40cfd2f0600f7a497313015427286221baf924ff..655157b32fa611c926f3d3b14665278c7b83c4df 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 37962289a7a55058170f74bf71f04d932b197d0f..998a5c59032578583448470135978ac190dc8a76 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 748c774c1c97d873b40d4a59462c09df3ded23e2..b6a44aa8e33c6b89a15b07d5303d441c8c71d60b 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 da0ac870a3a98896b713df6f56ee3920106cf7f3..c68eb753d97a17dcb6ded3629ed09cad84c8e183 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