Re: [RFC PATCH] mm: Avoiding split large folios if swap has no space
From: Barry Song
Date: Fri Jun 19 2026 - 19:01:51 EST
On Fri, Jun 19, 2026 at 10:02 PM David Hildenbrand (Arm)
<david@xxxxxxxxxx> wrote:
>
> On 6/19/26 00:17, Barry Song (Xiaomi) wrote:
> > When swap is disabled or exhausted, swap slot allocation
> > may fail during swapout, causing large folios to be split
> > into small folios. The splitting is reasonable when we
> > truly fail to obtain contiguous swap slots, but it is
> > pointless in the no-space case.
> >
> > A simple way to reproduce this is to invoke MADV_PAGEOUT on
> > a system with mTHP enabled but without swap configured.
>
> Would we ever run into that code without MADV_PAGEOUT, or is that a
> MADV_PAGEOUT-special thing?
>
> I recall that can_reclaim_anon_pages() would make vmscan skip such code, but
> it's tricky.
I guess there could also be cases such as
get_nr_swap_pages() == 1 while folio_nr_pages() > 1,
for example, where can_reclaim_anon_pages() cannot help.
Best Regards
Barry