Re: [PATCH v2 2/2] mm/hugetlb: clear the hugetlb flag before leaking a hwpoisoned folio
From: Miaohe Lin
Date: Thu Nov 19 2026 - 01:41:19 EST
On 2026/11/4 5:00, Mani Tofigh via B4 Relay wrote:
> From: Mani Tofigh <mt4022@xxxxxxxxxxxx>
>
> If hugetlb_update_hwpoison() fails to allocate a raw_hwp_page, the folio
> is marked raw_hwp_unreliable and __update_and_free_hugetlb_folio() leaks
> it intentionally. With hugetlb_free_vmemmap=on, it's leaked before the
> hugetlb flag is cleared, since commit 32c877191e02 ("hugetlb: do not
> clear hugetlb dtor until allocating vmemmap") doesn't remove the flag
> until the vmemmap is restored. The leaked folio is then a hugetlb folio
> with refcount 0 and on no list (the same state as a hugetlb folio that
> is being freed), but nothing is freeing it, and
> dissolve_free_hugetlb_folio() keeps retrying on it. Offlining its
> memory block then never completes, even on SIGKILL, and other tasks
> block on the memory hotplug lock:
>
> [ 3.271255] Memory failure: 0x20007: recovery action for free huge page: Failed
> [ 41.729695] INFO: task hugeoffline:77 blocked for more than 20 seconds.
> ...
> [ 41.733014] get_online_mems+0xc1/0xd0
> [ 41.733026] soft_offline_page+0xfd/0x9b0
>
> alloc_and_dissolve_hugetlb_folio() loops on it the same way. The
> refcount is 0 since commit bd225530a4c7 ("mm/hugetlb_vmemmap: fix race
> with speculative PFN walkers"). Before that these paths failed with
> -EBUSY.
>
> Check raw_hwp_unreliable after the hugetlb flag is cleared so that the
> folio is leaked as a non-hugetlb folio, as without vmemmap
> optimization. unpoison_memory() keeps refusing to unpoison it. With
> the fix, offlining retries as it does for any page it can't isolate,
> and stops on a signal.
>
> Fixes: 32c877191e02 ("hugetlb: do not clear hugetlb dtor until allocating vmemmap")
> Fixes: bd225530a4c7 ("mm/hugetlb_vmemmap: fix race with speculative PFN walkers")
> Cc: stable@xxxxxxxxxxxxxxx
> Signed-off-by: Mani Tofigh <mt4022@xxxxxxxxxxxx>
Reviewed-by: Miaohe Lin <linmiaohe@xxxxxxxxxx>
Thanks.
.