Re: [PATCH v3 11/18] mm/huge_memory: allow splitting mappingless swap cache folios
From: Kairui Song
Date: Thu Aug 27 2026 - 13:42:37 EST
On Fri, Aug 28, 2026 at 12:41 AM David Hildenbrand (Arm)
<david@xxxxxxxxxx> wrote:
> > + if (anon_vma) {
> > if (!ret && !folio_is_device_private(folio))
> > ttu_flags = TTU_USE_SHARED_ZEROPAGE;
> > remap_page(folio, 1 << old_order, ttu_flags);
> > @@ -4259,6 +4261,7 @@ static int __folio_split(struct folio *folio, unsigned int new_order,
> > struct page *split_at, struct page *lock_at,
> > struct list_head *list, enum split_type split_type)
> > {
> > + bool is_swapcache = folio_test_swapcache(folio);
> > struct folio *end_folio = folio_next(folio);
> > bool is_anon = folio_test_anon(folio);
> > int old_order = folio_order(folio);
> > @@ -4285,8 +4288,11 @@ static int __folio_split(struct folio *folio, unsigned int new_order,
> > }
> >
> > if (is_anon)
> > - ret = __folio_split_unmap_and_freeze_anon(folio, new_order, split_at, true,
> > - true, list, split_type);
> > + ret = __folio_split_unmap_and_freeze(folio, new_order, split_at, true,
> > + true, list, split_type);
> > + else if (is_swapcache)
> > + ret = __folio_split_unmap_and_freeze(folio, new_order, split_at, true,
> > + false, list, split_type);
>
> These two boolean parameters are really a pain. There must be a better way.
>
> Also, I don't like that __folio_split_unmap_and_freeze() sounds generic again.
>
> There must be a better way for that as well. We had a clean split and now we
> mangle it again.
>
>
> ... but I am just before my PTO and out of puff, so others can brainstorm on how
> to do this cleaner :)
What if we just keep the __folio_split_unmap_and_freeze_anon name? And
have that "bool remap" mentioned in previous reply? Clean swap cache
could be considered "anon compatible" as they might become anon
anytime, and even for shmem, shmem shares the same IO and LRU like
anon, so considering clean swap cache "psudo anon" seems not too bad?