Re: [PATCH 12/46] mm/huge_memory: fix livelock on device private folio
From: Lance Yang
Date: Wed Oct 28 2026 - 11:14:30 EST
On Tue, Oct 27, 2026 at 12:17:32AM +0100, David Hildenbrand (Arm) wrote:
>From: Josef Bacik <josef@xxxxxxxxxxxxxx>
>
>If do_huge_pmd_device_private() cannot lock the folio, it simply returns
>to try again on the next fault.
>
>Just like we did in commit b570f37a2ce4 ("mm: Fix a hmm_range_fault()
>livelock / starvation problem"), let's wait for the softleaf entry,
>which will drop the PTL and wait until the folio was unlocked. This is
>precisely what we do in do_swap_page() with device-private folios. This
>avoids possibly livelocking.
>
>Update softleaf_entry_wait_on_locked() documentation to clarify that
>device-private entries wait until the folio is unlocked.
>
>There seems to be no compelling reason to backport this to stable
>kernels unless we actually see problems there.
>
>Fix generated by an LLM and sent by Josef Bacik in private.
>
>Fixes: 4964099163d0 ("mm/memory/fault: add THP fault handling for zone device private pages")
>Signed-off-by: Josef Bacik <josef@xxxxxxxxxxxxxx>
>[ david: simplify patch description, fixup softleaf_entry_wait_on_locked description]
>Signed-off-by: David Hildenbrand (Arm) <david@xxxxxxxxxx>
>---
Nice work!
Reviewed-by: Lance Yang <lance.yang@xxxxxxxxx>