Re: [PATCH v2 1/4] mm/huge_memory: change folio_split_supported() to folio_check_splittable()
From: Andrew Morton
Date: Tue Nov 25 2025 - 12:45:09 EST
On Tue, 25 Nov 2025 09:58:03 +0100 "David Hildenbrand (Red Hat)" <david@xxxxxxxxxx> wrote:
> > + * Return: 0 - @folio can be split to @new_order, otherwise an error number is
> > + * returned.
> > + */
> > +int folio_check_splittable(struct folio *folio, unsigned int new_order,
> > + enum split_type split_type, bool warns)
> > {
> > + 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 shmem folios that are in the
> > + * swapcache.
> > + */
>
> Per the other discussion, should this even be:
>
> "this will also currently refuse folios without a mapping in the
> swapcache (shmem or to-be-anon folios)"
>
> IOW, to spell out that anon folios that were read into the swapcache but
> not mapped yet into page tables (where we set folio->mapping).
This?
--- a/mm/huge_memory.c~mm-huge_memory-change-folio_split_supported-to-folio_check_splittable-fix
+++ a/mm/huge_memory.c
@@ -3714,7 +3714,8 @@ int folio_check_splittable(struct folio
* caller that there was a race.
*
* TODO: this will also currently refuse shmem folios that are in the
- * swapcache.
+ * swapcache. Currently it will also refuse folios without a mapping
+ * in the swapcache (shmem or to-be-anon folios).
*/
if (!folio_test_anon(folio) && !folio->mapping)
return -EBUSY;
_