Re: [PATCH v3 1/4] mm/huge_memory: change folio_split_supported() to folio_check_splittable()

From: Barry Song

Date: Thu Nov 27 2025 - 00:23:12 EST


On Wed, Nov 26, 2025 at 11:50 AM Zi Yan <ziy@xxxxxxxxxx> wrote:
>
> folio_split_supported() used in try_folio_split_to_order() requires
> folio->mapping to be non NULL, but current try_folio_split_to_order() does
> not check it. There is no issue in the current code, since
> try_folio_split_to_order() is only used in truncate_inode_partial_folio(),
> where folio->mapping is not NULL.
>
> To prevent future misuse, move folio->mapping NULL check (i.e., folio is
> truncated) into folio_split_supported(). Since folio->mapping NULL check
> returns -EBUSY and folio_split_supported() == false means -EINVAL, change
> folio_split_supported() return type from bool to int and return error
> numbers accordingly. Rename folio_split_supported() to
> folio_check_splittable() to match the return type change.
>
> While at it, move is_huge_zero_folio() check and folio_test_writeback()
> check into folio_check_splittable() and add kernel-doc.
>
> Remove all warnings inside folio_check_splittable() and give warnings
> in __folio_split() instead, so that bool warns parameter can be removed.
>
> Signed-off-by: Zi Yan <ziy@xxxxxxxxxx>
> Reviewed-by: Wei Yang <richard.weiyang@xxxxxxxxx>

Much cleaner than having a "warns" argument before.

Reviewed-by: Barry Song <baohua@xxxxxxxxxx>

Thanks
Barry