linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
* [RFC PATCH] arm64: Kconfig: enable ARCH_WANTS_THP_SWAP for all pagesizes
@ 2025-12-26  6:38 Weilin Tong
  2025-12-26  6:52 ` Barry Song
  0 siblings, 1 reply; 10+ messages in thread
From: Weilin Tong @ 2025-12-26  6:38 UTC (permalink / raw)
  To: Catalin Marinas, Will Deacon
  Cc: linux-arm-kernel, linux-kernel, Andrew Morton, David Hildenbrand,
	linux-mm, baolin.wang, Weilin Tong

Currently, ARCH_WANTS_THP_SWAP was limited to 4K page size ARM64 kernels, but
large folios requiring swapping also exist in other page size configurations
(e.g. 64K). Without this config, large folios in these kernels cannot be swapped
out.

Here we enable ARCH_WANTS_THP_SWAP for all ARM64 page sizes.

Signed-off-by: Weilin Tong <tongweilin@linux.alibaba.com>
---
 arch/arm64/Kconfig | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/arm64/Kconfig b/arch/arm64/Kconfig
index 93173f0a09c7..58f7b4405f81 100644
--- a/arch/arm64/Kconfig
+++ b/arch/arm64/Kconfig
@@ -120,7 +120,7 @@ config ARM64
 	select ARCH_WANT_LD_ORPHAN_WARN
 	select ARCH_WANTS_EXECMEM_LATE
 	select ARCH_WANTS_NO_INSTR
-	select ARCH_WANTS_THP_SWAP if ARM64_4K_PAGES
+	select ARCH_WANTS_THP_SWAP
 	select ARCH_HAS_UBSAN
 	select ARM_AMBA
 	select ARM_ARCH_TIMER
-- 
2.43.7



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

* Re: [RFC PATCH] arm64: Kconfig: enable ARCH_WANTS_THP_SWAP for all pagesizes
  2025-12-26  6:38 [RFC PATCH] arm64: Kconfig: enable ARCH_WANTS_THP_SWAP for all pagesizes Weilin Tong
@ 2025-12-26  6:52 ` Barry Song
  2025-12-26  8:18   ` Weilin Tong
                     ` (2 more replies)
  0 siblings, 3 replies; 10+ messages in thread
From: Barry Song @ 2025-12-26  6:52 UTC (permalink / raw)
  To: Weilin Tong
  Cc: Catalin Marinas, Will Deacon, linux-arm-kernel, linux-kernel,
	Andrew Morton, David Hildenbrand, linux-mm, baolin.wang

On Fri, Dec 26, 2025 at 7:39 PM Weilin Tong
<tongweilin@linux.alibaba.com> wrote:
>
> Currently, ARCH_WANTS_THP_SWAP was limited to 4K page size ARM64 kernels, but
> large folios requiring swapping also exist in other page size configurations
> (e.g. 64K). Without this config, large folios in these kernels cannot be swapped
> out.
>
> Here we enable ARCH_WANTS_THP_SWAP for all ARM64 page sizes.

I no longer recall why this was not enabled for sizes other than
4 KB in commit d0637c505f8a ("arm64: enable THP_SWAP for arm64"), but
it appears to be fine, and the swap cluster size should also be
more friendly to PMD alignment.


#ifdef CONFIG_THP_SWAP
#define SWAPFILE_CLUSTER        HPAGE_PMD_NR
#define swap_entry_order(order) (order)
#else
#define SWAPFILE_CLUSTER        256
#define swap_entry_order(order) 0
#endif

>
> Signed-off-by: Weilin Tong <tongweilin@linux.alibaba.com>
> ---
>  arch/arm64/Kconfig | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/arch/arm64/Kconfig b/arch/arm64/Kconfig
> index 93173f0a09c7..58f7b4405f81 100644
> --- a/arch/arm64/Kconfig
> +++ b/arch/arm64/Kconfig
> @@ -120,7 +120,7 @@ config ARM64
>         select ARCH_WANT_LD_ORPHAN_WARN
>         select ARCH_WANTS_EXECMEM_LATE
>         select ARCH_WANTS_NO_INSTR
> -       select ARCH_WANTS_THP_SWAP if ARM64_4K_PAGES
> +       select ARCH_WANTS_THP_SWAP
>         select ARCH_HAS_UBSAN
>         select ARM_AMBA
>         select ARM_ARCH_TIMER
> --
> 2.43.7

Thanks
Barry


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

* Re: [RFC PATCH] arm64: Kconfig: enable ARCH_WANTS_THP_SWAP for all pagesizes
  2025-12-26  6:52 ` Barry Song
@ 2025-12-26  8:18   ` Weilin Tong
  2025-12-26  8:31     ` Barry Song
  2025-12-26  8:31   ` Weilin Tong
  2026-01-08 18:29   ` Will Deacon
  2 siblings, 1 reply; 10+ messages in thread
From: Weilin Tong @ 2025-12-26  8:18 UTC (permalink / raw)
  To: Barry Song
  Cc: Catalin Marinas, Will Deacon, linux-arm-kernel, linux-kernel,
	Andrew Morton, David Hildenbrand, linux-mm, baolin.wang

[-- Attachment #1: Type: text/plain, Size: 2249 bytes --]


在 2025/12/26 14:52, Barry Song 写道:
> On Fri, Dec 26, 2025 at 7:39 PM Weilin Tong
> <tongweilin@linux.alibaba.com> wrote:
>> Currently, ARCH_WANTS_THP_SWAP was limited to 4K page size ARM64 kernels, but
>> large folios requiring swapping also exist in other page size configurations
>> (e.g. 64K). Without this config, large folios in these kernels cannot be swapped
>> out.
>>
>> Here we enable ARCH_WANTS_THP_SWAP for all ARM64 page sizes.
> I no longer recall why this was not enabled for sizes other than
> 4 KB in commit d0637c505f8a ("arm64: enable THP_SWAP for arm64"), but
> it appears to be fine, and the swap cluster size should also be
> more friendly to PMD alignment.
>
>
> #ifdef CONFIG_THP_SWAP
> #define SWAPFILE_CLUSTER        HPAGE_PMD_NR
> #define swap_entry_order(order) (order)
> #else
> #define SWAPFILE_CLUSTER        256
> #define swap_entry_order(order) 0
> #endif
>

Thank you very much for taking the time to review this patch during the holiday. Wishing you a happy holiday as well!

I appreciate you pointing out this optimization. 
We initially noticed the issue because, on ARM64 kernels with 64K page size, 
if large folios are used in shmem, they cannot be swapped out as a whole during shmem_writeout() 
due to the config limitation,
and are forced to split instead—which is something we wanted to avoid.

It seems that this change will help enable better swap operations for large folios. Thank you again for your feedback!


>> Signed-off-by: Weilin Tong<tongweilin@linux.alibaba.com>
>> ---
>>   arch/arm64/Kconfig | 2 +-
>>   1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/arch/arm64/Kconfig b/arch/arm64/Kconfig
>> index 93173f0a09c7..58f7b4405f81 100644
>> --- a/arch/arm64/Kconfig
>> +++ b/arch/arm64/Kconfig
>> @@ -120,7 +120,7 @@ config ARM64
>>          select ARCH_WANT_LD_ORPHAN_WARN
>>          select ARCH_WANTS_EXECMEM_LATE
>>          select ARCH_WANTS_NO_INSTR
>> -       select ARCH_WANTS_THP_SWAP if ARM64_4K_PAGES
>> +       select ARCH_WANTS_THP_SWAP
>>          select ARCH_HAS_UBSAN
>>          select ARM_AMBA
>>          select ARM_ARCH_TIMER
>> --
>> 2.43.7
> Thanks
> Barry

[-- Attachment #2: Type: text/html, Size: 4722 bytes --]

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

* Re: [RFC PATCH] arm64: Kconfig: enable ARCH_WANTS_THP_SWAP for all pagesizes
  2025-12-26  8:18   ` Weilin Tong
@ 2025-12-26  8:31     ` Barry Song
  2025-12-26  8:40       ` Weilin Tong
  0 siblings, 1 reply; 10+ messages in thread
From: Barry Song @ 2025-12-26  8:31 UTC (permalink / raw)
  To: Weilin Tong
  Cc: Catalin Marinas, Will Deacon, linux-arm-kernel, linux-kernel,
	Andrew Morton, David Hildenbrand, linux-mm, baolin.wang

On Fri, Dec 26, 2025 at 9:18 PM Weilin Tong
<tongweilin@linux.alibaba.com> wrote:
>
>
> 在 2025/12/26 14:52, Barry Song 写道:
>
> On Fri, Dec 26, 2025 at 7:39 PM Weilin Tong
> <tongweilin@linux.alibaba.com> wrote:
>
> Currently, ARCH_WANTS_THP_SWAP was limited to 4K page size ARM64 kernels, but
> large folios requiring swapping also exist in other page size configurations
> (e.g. 64K). Without this config, large folios in these kernels cannot be swapped
> out.
>
> Here we enable ARCH_WANTS_THP_SWAP for all ARM64 page sizes.
>
> I no longer recall why this was not enabled for sizes other than
> 4 KB in commit d0637c505f8a ("arm64: enable THP_SWAP for arm64"), but
> it appears to be fine, and the swap cluster size should also be
> more friendly to PMD alignment.
>
>
> #ifdef CONFIG_THP_SWAP
> #define SWAPFILE_CLUSTER        HPAGE_PMD_NR
> #define swap_entry_order(order) (order)
> #else
> #define SWAPFILE_CLUSTER        256
> #define swap_entry_order(order) 0
> #endif
>
>
> Thank you very much for taking the time to review this patch during the holiday. Wishing you a happy holiday as well!
>
> I appreciate you pointing out this optimization. We initially noticed the issue because, on ARM64 kernels with 64K page size, if large folios are used in shmem, they cannot be swapped out as a whole during shmem_writeout() due to the config limitation,
> and are forced to split instead—which is something we wanted to avoid.
>
> It seems that this change will help enable better swap operations for large folios. Thank you again for your feedback!

Right, I believe this is the correct direction. Just double-check that
the MTE-related functionality works. Take a look at commit
f238b8c33c6738 ("arm64: mm: swap: support THP_SWAP on hardware with MTE").


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

* Re: [RFC PATCH] arm64: Kconfig: enable ARCH_WANTS_THP_SWAP for all pagesizes
  2025-12-26  6:52 ` Barry Song
  2025-12-26  8:18   ` Weilin Tong
@ 2025-12-26  8:31   ` Weilin Tong
  2026-01-08 18:29   ` Will Deacon
  2 siblings, 0 replies; 10+ messages in thread
From: Weilin Tong @ 2025-12-26  8:31 UTC (permalink / raw)
  To: Barry Song
  Cc: Catalin Marinas, Will Deacon, linux-arm-kernel, linux-kernel,
	Andrew Morton, David Hildenbrand, linux-mm, baolin.wang


在 2025/12/26 14:52, Barry Song 写道:
> On Fri, Dec 26, 2025 at 7:39 PM Weilin Tong
> <tongweilin@linux.alibaba.com> wrote:
>> Currently, ARCH_WANTS_THP_SWAP was limited to 4K page size ARM64 kernels, but
>> large folios requiring swapping also exist in other page size configurations
>> (e.g. 64K). Without this config, large folios in these kernels cannot be swapped
>> out.
>>
>> Here we enable ARCH_WANTS_THP_SWAP for all ARM64 page sizes.
> I no longer recall why this was not enabled for sizes other than
> 4 KB in commit d0637c505f8a ("arm64: enable THP_SWAP for arm64"), but
> it appears to be fine, and the swap cluster size should also be
> more friendly to PMD alignment.
>
>
> #ifdef CONFIG_THP_SWAP
> #define SWAPFILE_CLUSTER        HPAGE_PMD_NR
> #define swap_entry_order(order) (order)
> #else
> #define SWAPFILE_CLUSTER        256
> #define swap_entry_order(order) 0
> #endif
Thank you very much for taking the time to review this patch during the 
holiday.
Wishing you a happy holiday as well!

I appreciate you pointing out this optimization. We initially noticed 
the issue because,
on ARM64 kernels with 64K page size, if large folios are used in shmem, 
they cannot be
swapped out as a whole during shmem_writeout() due to the config 
limitation, and are forced
to split instead — which is something we wanted to avoid.

It seems that this change will help enable better swap operations for 
large folios.
Thank you again for your feedback!

>> Signed-off-by: Weilin Tong <tongweilin@linux.alibaba.com>
>> ---
>>   arch/arm64/Kconfig | 2 +-
>>   1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/arch/arm64/Kconfig b/arch/arm64/Kconfig
>> index 93173f0a09c7..58f7b4405f81 100644
>> --- a/arch/arm64/Kconfig
>> +++ b/arch/arm64/Kconfig
>> @@ -120,7 +120,7 @@ config ARM64
>>          select ARCH_WANT_LD_ORPHAN_WARN
>>          select ARCH_WANTS_EXECMEM_LATE
>>          select ARCH_WANTS_NO_INSTR
>> -       select ARCH_WANTS_THP_SWAP if ARM64_4K_PAGES
>> +       select ARCH_WANTS_THP_SWAP
>>          select ARCH_HAS_UBSAN
>>          select ARM_AMBA
>>          select ARM_ARCH_TIMER
>> --
>> 2.43.7
> Thanks
> Barry


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

* Re: [RFC PATCH] arm64: Kconfig: enable ARCH_WANTS_THP_SWAP for all pagesizes
  2025-12-26  8:31     ` Barry Song
@ 2025-12-26  8:40       ` Weilin Tong
  0 siblings, 0 replies; 10+ messages in thread
From: Weilin Tong @ 2025-12-26  8:40 UTC (permalink / raw)
  To: Barry Song
  Cc: Catalin Marinas, Will Deacon, linux-arm-kernel, linux-kernel,
	Andrew Morton, David Hildenbrand, linux-mm, baolin.wang


在 2025/12/26 16:31, Barry Song 写道:
> On Fri, Dec 26, 2025 at 9:18 PM Weilin Tong
> <tongweilin@linux.alibaba.com> wrote:
>>
>> 在 2025/12/26 14:52, Barry Song 写道:
>>
>> On Fri, Dec 26, 2025 at 7:39 PM Weilin Tong
>> <tongweilin@linux.alibaba.com> wrote:
>>
>> Currently, ARCH_WANTS_THP_SWAP was limited to 4K page size ARM64 kernels, but
>> large folios requiring swapping also exist in other page size configurations
>> (e.g. 64K). Without this config, large folios in these kernels cannot be swapped
>> out.
>>
>> Here we enable ARCH_WANTS_THP_SWAP for all ARM64 page sizes.
>>
>> I no longer recall why this was not enabled for sizes other than
>> 4 KB in commit d0637c505f8a ("arm64: enable THP_SWAP for arm64"), but
>> it appears to be fine, and the swap cluster size should also be
>> more friendly to PMD alignment.
>>
>>
>> #ifdef CONFIG_THP_SWAP
>> #define SWAPFILE_CLUSTER        HPAGE_PMD_NR
>> #define swap_entry_order(order) (order)
>> #else
>> #define SWAPFILE_CLUSTER        256
>> #define swap_entry_order(order) 0
>> #endif
>>
>>
>> Thank you very much for taking the time to review this patch during the holiday. Wishing you a happy holiday as well!
>>
>> I appreciate you pointing out this optimization. We initially noticed the issue because, on ARM64 kernels with 64K page size, if large folios are used in shmem, they cannot be swapped out as a whole during shmem_writeout() due to the config limitation,
>> and are forced to split instead—which is something we wanted to avoid.
>>
>> It seems that this change will help enable better swap operations for large folios. Thank you again for your feedback!
> Right, I believe this is the correct direction. Just double-check that
> the MTE-related functionality works. Take a look at commit
> f238b8c33c6738 ("arm64: mm: swap: support THP_SWAP on hardware with MTE").
Thanks, I will take a look.


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

* Re: [RFC PATCH] arm64: Kconfig: enable ARCH_WANTS_THP_SWAP for all pagesizes
  2025-12-26  6:52 ` Barry Song
  2025-12-26  8:18   ` Weilin Tong
  2025-12-26  8:31   ` Weilin Tong
@ 2026-01-08 18:29   ` Will Deacon
  2026-01-08 23:11     ` Barry Song
  2 siblings, 1 reply; 10+ messages in thread
From: Will Deacon @ 2026-01-08 18:29 UTC (permalink / raw)
  To: Barry Song
  Cc: Weilin Tong, Catalin Marinas, linux-arm-kernel, linux-kernel,
	Andrew Morton, David Hildenbrand, linux-mm, baolin.wang

On Fri, Dec 26, 2025 at 07:52:44PM +1300, Barry Song wrote:
> On Fri, Dec 26, 2025 at 7:39 PM Weilin Tong
> <tongweilin@linux.alibaba.com> wrote:
> >
> > Currently, ARCH_WANTS_THP_SWAP was limited to 4K page size ARM64 kernels, but
> > large folios requiring swapping also exist in other page size configurations
> > (e.g. 64K). Without this config, large folios in these kernels cannot be swapped
> > out.
> >
> > Here we enable ARCH_WANTS_THP_SWAP for all ARM64 page sizes.
> 
> I no longer recall why this was not enabled for sizes other than
> 4 KB in commit d0637c505f8a ("arm64: enable THP_SWAP for arm64"), but
> it appears to be fine, and the swap cluster size should also be
> more friendly to PMD alignment.

You seemed to be worried about I/O latency in your original post:

https://lore.kernel.org/all/20220524071403.128644-1-21cnbao@gmail.com/

Will


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

* Re: [RFC PATCH] arm64: Kconfig: enable ARCH_WANTS_THP_SWAP for all pagesizes
  2026-01-08 18:29   ` Will Deacon
@ 2026-01-08 23:11     ` Barry Song
  2026-01-09  8:32       ` Weilin Tong
  0 siblings, 1 reply; 10+ messages in thread
From: Barry Song @ 2026-01-08 23:11 UTC (permalink / raw)
  To: Will Deacon
  Cc: Weilin Tong, Catalin Marinas, linux-arm-kernel, linux-kernel,
	Andrew Morton, David Hildenbrand, linux-mm, baolin.wang

On Fri, Jan 9, 2026 at 7:29 AM Will Deacon <will@kernel.org> wrote:
>
> On Fri, Dec 26, 2025 at 07:52:44PM +1300, Barry Song wrote:
> > On Fri, Dec 26, 2025 at 7:39 PM Weilin Tong
> > <tongweilin@linux.alibaba.com> wrote:
> > >
> > > Currently, ARCH_WANTS_THP_SWAP was limited to 4K page size ARM64 kernels, but
> > > large folios requiring swapping also exist in other page size configurations
> > > (e.g. 64K). Without this config, large folios in these kernels cannot be swapped
> > > out.
> > >
> > > Here we enable ARCH_WANTS_THP_SWAP for all ARM64 page sizes.
> >
> > I no longer recall why this was not enabled for sizes other than
> > 4 KB in commit d0637c505f8a ("arm64: enable THP_SWAP for arm64"), but
> > it appears to be fine, and the swap cluster size should also be
> > more friendly to PMD alignment.
>
> You seemed to be worried about I/O latency in your original post:
>
> https://lore.kernel.org/all/20220524071403.128644-1-21cnbao@gmail.com/

Will, thanks for pointing this out! With a 16KB page size, a PMD
covers 32MB; with 64KB pages, a PMD covers 512MB. So, Weilin, are
we ready to wait for 32MB or 512MB to be written out before
memory can be reclaimed? By splitting, we can reclaim memory
earlier while only part of it has been swapped out.

While splitting down to order-0 is not ideal, splitting to a
relatively larger order appears to strike a balance between I/O
latency and swap performance. Anyway, I don't know :-)

Thanks
Barry


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

* Re: [RFC PATCH] arm64: Kconfig: enable ARCH_WANTS_THP_SWAP for all pagesizes
  2026-01-08 23:11     ` Barry Song
@ 2026-01-09  8:32       ` Weilin Tong
  2026-01-09  9:59         ` Barry Song
  0 siblings, 1 reply; 10+ messages in thread
From: Weilin Tong @ 2026-01-09  8:32 UTC (permalink / raw)
  To: Barry Song, Will Deacon
  Cc: Catalin Marinas, linux-arm-kernel, linux-kernel, Andrew Morton,
	David Hildenbrand, linux-mm, baolin.wang


在 2026/1/9 07:11, Barry Song 写道:
> On Fri, Jan 9, 2026 at 7:29 AM Will Deacon <will@kernel.org> wrote:
>> On Fri, Dec 26, 2025 at 07:52:44PM +1300, Barry Song wrote:
>>> On Fri, Dec 26, 2025 at 7:39 PM Weilin Tong
>>> <tongweilin@linux.alibaba.com> wrote:
>>>> Currently, ARCH_WANTS_THP_SWAP was limited to 4K page size ARM64 kernels, but
>>>> large folios requiring swapping also exist in other page size configurations
>>>> (e.g. 64K). Without this config, large folios in these kernels cannot be swapped
>>>> out.
>>>>
>>>> Here we enable ARCH_WANTS_THP_SWAP for all ARM64 page sizes.
>>> I no longer recall why this was not enabled for sizes other than
>>> 4 KB in commit d0637c505f8a ("arm64: enable THP_SWAP for arm64"), but
>>> it appears to be fine, and the swap cluster size should also be
>>> more friendly to PMD alignment.
>> You seemed to be worried about I/O latency in your original post:
>>
>> https://lore.kernel.org/all/20220524071403.128644-1-21cnbao@gmail.com/
> Will, thanks for pointing this out! With a 16KB page size, a PMD
> covers 32MB; with 64KB pages, a PMD covers 512MB. So, Weilin, are
> we ready to wait for 32MB or 512MB to be written out before
> memory can be reclaimed? By splitting, we can reclaim memory
> earlier while only part of it has been swapped out.

I got your point. In our production envs using 64K pagesize kernel, we 
only enable 2M and below size

mthp, so swapping out as a whole is a better way. Or maybe we can set 
the SWAPFILE_CLUSTER by arch.

I will do some tests of this concern.

Thanks a lot.

> While splitting down to order-0 is not ideal, splitting to a
> relatively larger order appears to strike a balance between I/O
> latency and swap performance. Anyway, I don't know :-)
>
> Thanks
> Barry


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

* Re: [RFC PATCH] arm64: Kconfig: enable ARCH_WANTS_THP_SWAP for all pagesizes
  2026-01-09  8:32       ` Weilin Tong
@ 2026-01-09  9:59         ` Barry Song
  0 siblings, 0 replies; 10+ messages in thread
From: Barry Song @ 2026-01-09  9:59 UTC (permalink / raw)
  To: Weilin Tong
  Cc: Will Deacon, Catalin Marinas, linux-arm-kernel, linux-kernel,
	Andrew Morton, David Hildenbrand, linux-mm, baolin.wang

On Fri, Jan 9, 2026 at 4:32 PM Weilin Tong <tongweilin@linux.alibaba.com> wrote:
>
>
> 在 2026/1/9 07:11, Barry Song 写道:
> > On Fri, Jan 9, 2026 at 7:29 AM Will Deacon <will@kernel.org> wrote:
> >> On Fri, Dec 26, 2025 at 07:52:44PM +1300, Barry Song wrote:
> >>> On Fri, Dec 26, 2025 at 7:39 PM Weilin Tong
> >>> <tongweilin@linux.alibaba.com> wrote:
> >>>> Currently, ARCH_WANTS_THP_SWAP was limited to 4K page size ARM64 kernels, but
> >>>> large folios requiring swapping also exist in other page size configurations
> >>>> (e.g. 64K). Without this config, large folios in these kernels cannot be swapped
> >>>> out.
> >>>>
> >>>> Here we enable ARCH_WANTS_THP_SWAP for all ARM64 page sizes.
> >>> I no longer recall why this was not enabled for sizes other than
> >>> 4 KB in commit d0637c505f8a ("arm64: enable THP_SWAP for arm64"), but
> >>> it appears to be fine, and the swap cluster size should also be
> >>> more friendly to PMD alignment.
> >> You seemed to be worried about I/O latency in your original post:
> >>
> >> https://lore.kernel.org/all/20220524071403.128644-1-21cnbao@gmail.com/
> > Will, thanks for pointing this out! With a 16KB page size, a PMD
> > covers 32MB; with 64KB pages, a PMD covers 512MB. So, Weilin, are
> > we ready to wait for 32MB or 512MB to be written out before
> > memory can be reclaimed? By splitting, we can reclaim memory
> > earlier while only part of it has been swapped out.
>
> I got your point. In our production envs using 64K pagesize kernel, we
> only enable 2M and below size

If mTHP is enabled only for sizes below 2 MB, the patch makes
perfect sense. However, the problem is that we do not know how
others configure their systems.

>
> mthp, so swapping out as a whole is a better way. Or maybe we can set
> the SWAPFILE_CLUSTER by arch.

Even for 512 MB or 32 MB PMD folios, it would be perfectly fine
for SWAPFILE_CLUSTER to match the PMD folio size, given the
assumption that the swap table should be PAGE_SIZE.

>
> I will do some tests of this concern.

Right. It would be helpful to have some test data—for example,
with larger folios like 16 MB, 32 MB, or 64 MB—to see what
happens when memory reclamation kicks in.

One possible option is to call
split_huge_page_to_list_to_order(&folio->page, list,
                                get_order(SZ_2M));

for paging out.But this looks rather ugly :-)

On the other hand, if users configure mTHP to, for example,
128 MB, swapping out and reclaiming the entire 128 MB folio
could actually help with memory de-fragmentation.
So perhaps users should tolerate the I/O latency in this
case?

>
> Thanks a lot.
>
> > While splitting down to order-0 is not ideal, splitting to a
> > relatively larger order appears to strike a balance between I/O
> > latency and swap performance. Anyway, I don't know :-)
> >

Thanks
Barry


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

end of thread, other threads:[~2026-01-09  9:59 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-12-26  6:38 [RFC PATCH] arm64: Kconfig: enable ARCH_WANTS_THP_SWAP for all pagesizes Weilin Tong
2025-12-26  6:52 ` Barry Song
2025-12-26  8:18   ` Weilin Tong
2025-12-26  8:31     ` Barry Song
2025-12-26  8:40       ` Weilin Tong
2025-12-26  8:31   ` Weilin Tong
2026-01-08 18:29   ` Will Deacon
2026-01-08 23:11     ` Barry Song
2026-01-09  8:32       ` Weilin Tong
2026-01-09  9:59         ` Barry Song

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