s390/mm: Allow hugepage migration for s390
Gerald Schaefer
maintainerPATCH 1/1 s390/mm: Allow hugepage migration for s390
After hugetlbfs PTE_MARKER support for s390 introduced region-third and segment table swap entries, it is possible to also allow hugepage migration for s390.
This fixes the problem that hugetlbfs pages could not be allocated from ZONE_MOVABLE memory, which is often used in combination with memory hotplug. Therefore, without support for hugepage migration, a large portion of system memory could be unavailable for hugetlbfs page allocations.
Besides selecting ARCH_ENABLE_HUGEPAGE_MIGRATION, this only requires definition of arch_hugetlb_migration_supported(), which can make use of the existing arch_hugetlb_valid_size() function, similar to other architectures.
--- arch/s390/Kconfig | 1 + arch/s390/include/asm/hugetlb.h | 5 +++++ arch/s390/mm/hugetlbpage.c | 14 +++++++++++++- 3 files changed, 19 insertions(+), 1 deletion(-)
arch/s390/Kconfig +1 -0
@@ -83,6 +83,7 @@ config S390 select ALTERNATE_USER_ADDRESS_SPACE select ARCH_32BIT_USTAT_F_TINODE select ARCH_CORRECT_STACKTRACE_ON_KRETPROBE + select ARCH_ENABLE_HUGEPAGE_MIGRATION if HUGETLB_PAGE && MIGRATION select ARCH_ENABLE_MEMORY_HOTPLUG if SPARSEMEM select ARCH_ENABLE_SPLIT_PMD_PTLOCK if PGTABLE_LEVELS > 2 select ARCH_HAS_PMD_SOFTLEAVES if TRANSPARENT_HUGEPAGE
arch/s390/include/asm/hugetlb.h +5 -0
@@ -17,6 +17,11 @@#define hugepages_supported () cpu_has_edat1() +#ifdef CONFIG_ARCH_ENABLE_HUGEPAGE_MIGRATION +bool arch_hugetlb_migration_supported (struct hstate *h); +#define arch_hugetlb_migration_supported arch_hugetlb_migration_supported +#endif +#define __HAVE_ARCH_HUGE_SET_HUGE_PTE_ATvoid set_huge_pte_at (struct mm_struct *mm,unsigned long addr,pte_t *ptep,pte_t pte,unsigned long sz);
arch/s390/mm/hugetlbpage.c +13 -1
@@ -224,7 +224,7 @@ pte_t *huge_pte_offset(struct mm_struct *mm,return (pte_t *) pmdp; } -bool __init arch_hugetlb_valid_size (unsigned long size) +static bool __hugetlb_valid_size (unsigned long size) {if (cpu_has_edat1 () && size ==PMD_SIZE )return true;
@@ -241,3 +241,15 @@ unsigned int __init arch_hugetlb_cma_order(void)return 0 ; } + +bool __init arch_hugetlb_valid_size (unsigned long size) +{ +return __hugetlb_valid_size (size); +} + +#ifdef CONFIG_ARCH_ENABLE_HUGEPAGE_MIGRATION +bool arch_hugetlb_migration_supported (struct hstate *h) +{ +return __hugetlb_valid_size (huge_page_size (h)); +} +#endif
Signature · 1 line
2.53.0
[email protected]
AI reviewSashiko has reviewed this patch and found no issues.
Quoted 10 lines
After hugetlbfs
PTE_MARKERsupport for s390 introduced region-third and segment table swap entries, it is possible to also allow hugepage migration for s390.This fixes the problem that hugetlbfs pages could not be allocated from
ZONE_MOVABLEmemory, which is often used in combination with memory hotplug. Therefore, without support for hugepage migration, a large portion of system memory could be unavailable for hugetlbfs page allocations.
Quoted 6 lines
Besides selecting
ARCH_ENABLE_HUGEPAGE_MIGRATION, this only requires definition ofarch_hugetlb_migration_supported(), which can make use of the existingarch_hugetlb_valid_size()function, similar to other architectures.Signed-off-by Gerald Schaefer <[email protected]>
Sashiko has reviewed this patch and found no issues.
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=1
Alexander Gordeev
maintainerQuoted 64 lines · Gerald Schaefer
After hugetlbfs
PTE_MARKERsupport for s390 introduced region-third and segment table swap entries, it is possible to also allow hugepage migration for s390.This fixes the problem that hugetlbfs pages could not be allocated from
ZONE_MOVABLEmemory, which is often used in combination with memory hotplug. Therefore, without support for hugepage migration, a large portion of system memory could be unavailable for hugetlbfs page allocations.Besides selecting
ARCH_ENABLE_HUGEPAGE_MIGRATION, this only requires definition ofarch_hugetlb_migration_supported(), which can make use of the existingarch_hugetlb_valid_size()function, similar to other architectures.Signed-off-by Gerald Schaefer <[email protected]>--- arch/s390/Kconfig | 1 + arch/s390/include/asm/hugetlb.h | 5 +++++ arch/s390/mm/hugetlbpage.c | 14 +++++++++++++- 3 files changed, 19 insertions(+), 1 deletion(-)arch/s390/Kconfig +1
-0@@ -83,6 +83,7 @@ config S390 select ALTERNATE_USER_ADDRESS_SPACE select ARCH_32BIT_USTAT_F_TINODE select ARCH_CORRECT_STACKTRACE_ON_KRETPROBE + select ARCH_ENABLE_HUGEPAGE_MIGRATION if HUGETLB_PAGE && MIGRATION select ARCH_ENABLE_MEMORY_HOTPLUG if SPARSEMEM select ARCH_ENABLE_SPLIT_PMD_PTLOCK if PGTABLE_LEVELS > 2 select ARCH_HAS_PMD_SOFTLEAVES if TRANSPARENT_HUGEPAGEarch/s390/include/asm/hugetlb.h +5
-0@@ -17,6 +17,11 @@#define hugepages_supported () cpu_has_edat1() +#ifdef CONFIG_ARCH_ENABLE_HUGEPAGE_MIGRATION +bool arch_hugetlb_migration_supported (struct hstate *h); +#define arch_hugetlb_migration_supported arch_hugetlb_migration_supported +#endif +#define __HAVE_ARCH_HUGE_SET_HUGE_PTE_ATvoid set_huge_pte_at (struct mm_struct *mm,unsigned long addr,pte_t *ptep,pte_t pte,unsigned long sz);arch/s390/mm/hugetlbpage.c +1
-1@@ -224,7 +224,7 @@ pte_t *huge_pte_offset(struct mm_struct *mm,return (pte_t *) pmdp; } -bool __init arch_hugetlb_valid_size (unsigned long size) +static bool __hugetlb_valid_size (unsigned long size) {if (cpu_has_edat1 () && size ==PMD_SIZE )return true;
arch/s390/mm/hugetlbpage.c unsigned int __init arch_hugetlb_cma_order(void) · line 250
Quoted 10 lines
arch/s390/mm/hugetlbpage.c +7
-0@@ -241,3 +241,15 @@ unsigned int __init arch_hugetlb_cma_order(void)return 0 ; } + +bool __init arch_hugetlb_valid_size (unsigned long size) +{ +return __hugetlb_valid_size (size); +} + +#ifdef CONFIG_ARCH_ENABLE_HUGEPAGE_MIGRATION
Could you please use IS_ENABLED() instead?
arch/s390/mm/hugetlbpage.c unsigned int __init arch_hugetlb_cma_order(void) · line 255
Quoted 5 lines
arch/s390/mm/hugetlbpage.c +5
-0+bool arch_hugetlb_migration_supported (struct hstate *h) +{ +return __hugetlb_valid_size (huge_page_size (h)); +} +#endif
Otherwise, LGTM.
Thanks!
Gerald Schaefer
maintainerOn Wed, 11 Nov 2026 17:09:45 +0100
Alexander Gordeev <[email protected]> wrote:
[...]
Quoted 13 lines
arch/s390/mm/hugetlbpage.c unsigned int __init arch_hugetlb_cma_order(void) · line 250
Quoted 11 lines
arch/s390/mm/hugetlbpage.c +7
-0@@ -241,3 +241,15 @@ unsigned int __init arch_hugetlb_cma_order(void)return 0 ; } + +bool __init arch_hugetlb_valid_size (unsigned long size) +{ +return __hugetlb_valid_size (size); +} + +#ifdef CONFIG_ARCH_ENABLE_HUGEPAGE_MIGRATION Could you please use
IS_ENABLED()instead?
Does the benefit mentioned in Documentation/process/coding-style.rst for usage "within code" also apply in such a case, i.e. not within code?
Or are there other benefits or coding style requirements? Just wondering, because I never saw that in such a case where a whole function is behind such an #ifdef.
Quoted 10 lines
arch/s390/mm/hugetlbpage.c unsigned int __init arch_hugetlb_cma_order(void) · line 255
Quoted 6 lines
arch/s390/mm/hugetlbpage.c +5
-0+bool arch_hugetlb_migration_supported (struct hstate *h) +{ +return __hugetlb_valid_size (huge_page_size (h)); +} +#endif Otherwise, LGTM.
Thanks!
Gerald Schaefer
maintainerQuoted 18 lines · On Wed, 11 Nov 2026 18:21:49 +0100 Gerald Schaefer…
On Wed, 11 Nov 2026 17:09:45 +0100
Alexander Gordeev <[email protected]> wrote:[...]
Quoted 13 lines
arch/s390/mm/hugetlbpage.c unsigned int __init arch_hugetlb_cma_order(void) · line 250
Quoted 11 lines
arch/s390/mm/hugetlbpage.c +7
-0@@ -241,3 +241,15 @@ unsigned int __init arch_hugetlb_cma_order(void)return 0 ; } + +bool __init arch_hugetlb_valid_size (unsigned long size) +{ +return __hugetlb_valid_size (size); +} + +#ifdef CONFIG_ARCH_ENABLE_HUGEPAGE_MIGRATION Could you please use
IS_ENABLED()instead?
Quoted 7 lines
Does the benefit mentioned in
Documentation/process/coding-style.rstfor usage "within code" also apply in such a case, i.e. not within code?Or are there other benefits or coding style requirements? Just wondering, because I never saw that in such a case where a whole function is behind such an #ifdef.
Ah ok, there is of course some code in the function, and it is not (yet) referencing symbols that will not exist if the condition is not met. So I guess it also makes some sense here. Will send a v2.
Quoted 13 lines
Quoted 11 lines
arch/s390/mm/hugetlbpage.c unsigned int __init arch_hugetlb_cma_order(void) · line 255
Quoted 7 lines
arch/s390/mm/hugetlbpage.c +5
-0+bool arch_hugetlb_migration_supported (struct hstate *h) +{ +return __hugetlb_valid_size (huge_page_size (h)); +} +#endif Otherwise, LGTM.
Thanks!