Linux s390 Architecture development
 help / color / mirror / Atom feed
* [PATCH] s390/mm: Allow hugepage migration for s390
@ 2026-11-06 17:08 Gerald Schaefer
  2026-11-06 17:28 ` sashiko-bot
  2026-11-11 16:09 ` Alexander Gordeev
  0 siblings, 2 replies; 5+ messages in thread
From: Gerald Schaefer @ 2026-11-06 17:08 UTC (permalink / raw)
  To: linux-s390
  Cc: Alexander Gordeev, Heiko Carstens, Christian Borntraeger,
	Ilya Leoshkevich

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.

Signed-off-by: Gerald Schaefer <gerald.schaefer@linux.ibm.com>
---
 arch/s390/Kconfig               |  1 +
 arch/s390/include/asm/hugetlb.h |  5 +++++
 arch/s390/mm/hugetlbpage.c      | 14 +++++++++++++-
 3 files changed, 19 insertions(+), 1 deletion(-)

diff --git a/arch/s390/Kconfig b/arch/s390/Kconfig
index 612885228824..e3a704f423f3 100644
--- a/arch/s390/Kconfig
+++ b/arch/s390/Kconfig
@@ -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
diff --git a/arch/s390/include/asm/hugetlb.h b/arch/s390/include/asm/hugetlb.h
index aea754b67c89..356a18a75d99 100644
--- a/arch/s390/include/asm/hugetlb.h
+++ b/arch/s390/include/asm/hugetlb.h
@@ -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_AT
 void set_huge_pte_at(struct mm_struct *mm, unsigned long addr,
 		     pte_t *ptep, pte_t pte, unsigned long sz);
diff --git a/arch/s390/mm/hugetlbpage.c b/arch/s390/mm/hugetlbpage.c
index f84aa9265430..ce61f8738465 100644
--- a/arch/s390/mm/hugetlbpage.c
+++ b/arch/s390/mm/hugetlbpage.c
@@ -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
-- 
2.53.0


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH] s390/mm: Allow hugepage migration for s390
  2026-11-06 17:08 [PATCH] s390/mm: Allow hugepage migration for s390 Gerald Schaefer
@ 2026-11-06 17:28 ` sashiko-bot
  2026-11-11 16:09 ` Alexander Gordeev
  1 sibling, 0 replies; 5+ messages in thread
From: sashiko-bot @ 2026-11-06 17:28 UTC (permalink / raw)
  To: Gerald Schaefer, linux-s390
  Cc: Heiko Carstens, Vasily Gorbik, Alexander Gordeev,
	Christian Borntraeger

> 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.
> 
> Signed-off-by: Gerald Schaefer <gerald.schaefer@linux.ibm.com>

Sashiko has reviewed this patch and found no issues.

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261106170844.4079771-1-gerald.schaefer@linux.ibm.com?part=1


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] s390/mm: Allow hugepage migration for s390
  2026-11-06 17:08 [PATCH] s390/mm: Allow hugepage migration for s390 Gerald Schaefer
  2026-11-06 17:28 ` sashiko-bot
@ 2026-11-11 16:09 ` Alexander Gordeev
  2026-11-11 17:21   ` Gerald Schaefer
  1 sibling, 1 reply; 5+ messages in thread
From: Alexander Gordeev @ 2026-11-11 16:09 UTC (permalink / raw)
  To: Gerald Schaefer
  Cc: linux-s390, Heiko Carstens, Christian Borntraeger,
	Ilya Leoshkevich

On Fri, Nov 06, 2026 at 06:08:44PM +0100, Gerald Schaefer wrote:
> 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.
> 
> Signed-off-by: Gerald Schaefer <gerald.schaefer@linux.ibm.com>
> ---
>  arch/s390/Kconfig               |  1 +
>  arch/s390/include/asm/hugetlb.h |  5 +++++
>  arch/s390/mm/hugetlbpage.c      | 14 +++++++++++++-
>  3 files changed, 19 insertions(+), 1 deletion(-)
> 
> diff --git a/arch/s390/Kconfig b/arch/s390/Kconfig
> index 612885228824..e3a704f423f3 100644
> --- a/arch/s390/Kconfig
> +++ b/arch/s390/Kconfig
> @@ -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
> diff --git a/arch/s390/include/asm/hugetlb.h b/arch/s390/include/asm/hugetlb.h
> index aea754b67c89..356a18a75d99 100644
> --- a/arch/s390/include/asm/hugetlb.h
> +++ b/arch/s390/include/asm/hugetlb.h
> @@ -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_AT
>  void set_huge_pte_at(struct mm_struct *mm, unsigned long addr,
>  		     pte_t *ptep, pte_t pte, unsigned long sz);
> diff --git a/arch/s390/mm/hugetlbpage.c b/arch/s390/mm/hugetlbpage.c
> index f84aa9265430..ce61f8738465 100644
> --- a/arch/s390/mm/hugetlbpage.c
> +++ b/arch/s390/mm/hugetlbpage.c
> @@ -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

Could you please use IS_ENABLED() instead?

> +bool arch_hugetlb_migration_supported(struct hstate *h)
> +{
> +	return __hugetlb_valid_size(huge_page_size(h));
> +}
> +#endif

Otherwise, LGTM.

Thanks!

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] s390/mm: Allow hugepage migration for s390
  2026-11-11 16:09 ` Alexander Gordeev
@ 2026-11-11 17:21   ` Gerald Schaefer
  2026-11-11 17:33     ` Gerald Schaefer
  0 siblings, 1 reply; 5+ messages in thread
From: Gerald Schaefer @ 2026-11-11 17:21 UTC (permalink / raw)
  To: Alexander Gordeev
  Cc: linux-s390, Heiko Carstens, Christian Borntraeger,
	Ilya Leoshkevich

On Wed, 11 Nov 2026 17:09:45 +0100
Alexander Gordeev <agordeev@linux.ibm.com> wrote:

[...]
> > @@ -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.

> 
> > +bool arch_hugetlb_migration_supported(struct hstate *h)
> > +{
> > +	return __hugetlb_valid_size(huge_page_size(h));
> > +}
> > +#endif
> 
> Otherwise, LGTM.
> 
> Thanks!


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] s390/mm: Allow hugepage migration for s390
  2026-11-11 17:21   ` Gerald Schaefer
@ 2026-11-11 17:33     ` Gerald Schaefer
  0 siblings, 0 replies; 5+ messages in thread
From: Gerald Schaefer @ 2026-11-11 17:33 UTC (permalink / raw)
  To: Alexander Gordeev
  Cc: linux-s390, Heiko Carstens, Christian Borntraeger,
	Ilya Leoshkevich

On Wed, 11 Nov 2026 18:21:49 +0100
Gerald Schaefer <gerald.schaefer@linux.ibm.com> wrote:

> On Wed, 11 Nov 2026 17:09:45 +0100
> Alexander Gordeev <agordeev@linux.ibm.com> wrote:
> 
> [...]
> > > @@ -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.

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.

> 
> > 
> > > +bool arch_hugetlb_migration_supported(struct hstate *h)
> > > +{
> > > +	return __hugetlb_valid_size(huge_page_size(h));
> > > +}
> > > +#endif
> > 
> > Otherwise, LGTM.
> > 
> > Thanks!
> 
> 


^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2026-11-11 17:33 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-06 17:08 [PATCH] s390/mm: Allow hugepage migration for s390 Gerald Schaefer
2026-11-06 17:28 ` sashiko-bot
2026-11-11 16:09 ` Alexander Gordeev
2026-11-11 17:21   ` Gerald Schaefer
2026-11-11 17:33     ` Gerald Schaefer

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox