Re: [PATCH v3 11/18] mm/huge_memory: allow splitting mappingless swap cache folios
From: David Hildenbrand (Arm)
Date: Thu Aug 27 2026 - 15:16:46 EST
On 8/27/26 19:41, Kairui Song wrote:
> 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
I think you can just rely on folio_mapped() internally. swapcache-only is never
mapped. And anon folios you can just detect internally as well, right?
> could be considered "anon compatible" as they might become anon
Dirty but better than what you have right now. As you say, there really is no
difference.
But for example the mapping/remapping is superfluous. So you could also consider
a _swapcache that reuses some common bits from the _anon helper.
--
Cheers,
David