On 2 Sep 2025, at 12:25, David Hildenbrand wrote:
> When checking for actual tail or head pages of a folio, we must make
> sure that the KPF_COMPOUND_HEAD/KPF_COMPOUND_TAIL flag is paired with
> KPF_THP.
>
> For example, if we have another large folio after our large folio in
> physical memory, our "pfn_flags & (KPF_THP | KPF_COMPOUND_TAIL" would
> trigger even though it's actually a head page of the next folio.
>
> If is_backed_by_folio() returns a wrong result, split_pte_mapped_thp()
> can fail with "Some THPs are missing during mremap".
>
> Fix it by checking for head/tail pages of folios properly. Add
> folio_tail_flags/folio_head_flags to improve readability and use these
> masks also when just testing for any compound page.
>
> Fixes: 169b456b0162 ("selftests/mm: reimplement is_backed_by_thp() with more
> precise check")
> Signed-off-by: David Hildenbrand <[email protected]>
> ---
> tools/testing/selftests/mm/split_huge_page_test.c | 15 +++++++--------
> 1 file changed, 7 insertions(+), 8 deletions(-)
>
LGTM. Thanks for fixing it. Reviewed-by: Zi Yan <[email protected]>
Best Regards,
Yan, Zi