Re: [PATCH mm-new v2 2/3] mm/khugepaged: use VM_WARN_ON_FOLIO instead of VM_BUG_ON_FOLIO for non-anon folios

From: Wei Yang

Date: Mon Oct 06 2025 - 20:35:41 EST


On Mon, Oct 06, 2025 at 10:43:37PM +0800, Lance Yang wrote:
>From: Lance Yang <lance.yang@xxxxxxxxx>
>
>As Zi pointed out, we should avoid crashing the kernel for conditions
>that can be handled gracefully. Encountering a non-anonymous folio in an
>anonymous VMA is a bug, but a warning is sufficient.
>
>This patch changes the VM_BUG_ON_FOLIO(!folio_test_anon(folio)) to a
>VM_WARN_ON_FOLIO() in both __collapse_huge_page_isolate() and
>hpage_collapse_scan_pmd(), and then aborts the scan with SCAN_PAGE_ANON.
>
>Making more of the scanning logic common between hpage_collapse_scan_pmd()
>and __collapse_huge_page_isolate(), as suggested by Dev.
>
>Suggested-by: Dev Jain <dev.jain@xxxxxxx>
>Suggested-by: Zi Yan <ziy@xxxxxxxxxx>
>Signed-off-by: Lance Yang <lance.yang@xxxxxxxxx>

Reviewed-by: Wei Yang <richard.weiyang@xxxxxxxxx>

--
Wei Yang
Help you, Help me