Re: [PATCH RFC 10/13] mm/huge_memory: allow splitting mappingless swap cache folios

From: Zi Yan

Date: Sat Aug 08 2026 - 22:35:49 EST


On Fri Aug 7, 2026 at 5:17 PM EDT, Kairui Song via B4 Relay wrote:
> From: Kairui Song <kasong@xxxxxxxxxxx>
>
> Lift the restriction that kept swap cache folios without a mapping
> from being split. All the underlying infrastructure is sound against
> that with a few more tweaks, no reason to block it anymore.
>
> Also rename the split helper, which now handles mappingless swap
> cache folios that are yet to be anon, or may actually belong to
> shmem. In either case there is not much difference in how they would
> be split.
>
> A non-anon swap cache folio that still has a mapping (e.g. a shmem
> swap cache folio) remains rejected up front: it would need both its
> page cache and swap cache entries updated on split, which the split
> helpers do not do, and there would be little benefit in doing so.
>
> Signed-off-by: Kairui Song <kasong@xxxxxxxxxxx>
> ---
> mm/huge_memory.c | 40 +++++++++++++++++++++++-----------------
> 1 file changed, 23 insertions(+), 17 deletions(-)
>
> diff --git a/mm/huge_memory.c b/mm/huge_memory.c
> index ab2bb29748d3..b80d0db63225 100644
> --- a/mm/huge_memory.c
> +++ b/mm/huge_memory.c
> @@ -3881,12 +3881,10 @@ int folio_check_splittable(struct folio *folio, unsigned int new_order,
> VM_WARN_ON_FOLIO(!folio_test_locked(folio), folio);
> /*
> * Folios that just got truncated cannot get split. Signal to the
> - * caller that there was a race.
> - *
> - * TODO: this will also currently refuse folios without a mapping in the
> - * swapcache (shmem or to-be-anon folios).
> + * caller that there was a race. A mappingless swap cache folio
> + * has no page cache entries to update, so it is fine to split.
> */
> - if (!folio->mapping && !is_anon)
> + if (!folio->mapping && !is_swapcache)
> return -EBUSY;
>
> /* order-1 is not supported for anonymous THP. */
> @@ -3931,11 +3929,12 @@ static unsigned int folio_cache_ref_count(const struct folio *folio)
> return folio_nr_pages(folio);
> }
>
> -static int __folio_freeze_split_unmap_anon(struct folio *folio, unsigned int new_order,
> - struct page *split_at, bool do_lru, bool unmap,
> - struct list_head *list, enum split_type split_type)
> +static int __folio_freeze_split_unmap(struct folio *folio, unsigned int new_order,
> + struct page *split_at, bool do_lru, bool anon_unmap,
> + struct list_head *list, enum split_type split_type)

I have not figured out a good name for it, but it definitely needs a
function kdoc to explain what it does, since it is no longer a simple
anon only function. It is better to add the documentation for this one
and file one when they are introduced and modify anon one's comment
here.



--
Best Regards,
Yan, Zi