linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] mm/hmm: Prevent infinite loop in hmm_range_fault during EBUSY retries
@ 2025-01-28  6:34 sooraj
  2025-01-28  1:00 ` Andrew Morton
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: sooraj @ 2025-01-28  6:34 UTC (permalink / raw)
  To: linux-mm; +Cc: sooraj

When hmm_vma_walk_test() skips a VMA (e.g., unsupported VM_IO/PFNMAP range),
it must update hmm_vma_walk->last to the end of the skipped VMA. Failing to
do so causes hmm_range_fault() to restart from the same address during
-EBUSY retries, reprocessing the skipped VMA indefinitely. This results in
an infinite loop if the VMA remains non-processable.

Update hmm_vma_walk->last to the VMA's end address in hmm_vma_walk_test()
when skipping the range. This ensures subsequent iterations resume correctly
after the skipped VMA, preventing infinite retry loops.

Signed-off-by: sooraj <sooraj20636@gmail.com>
---
 mm/hmm.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/mm/hmm.c b/mm/hmm.c
index 7e0229ae4a5a..29e3678fede5 100644
--- a/mm/hmm.c
+++ b/mm/hmm.c
@@ -547,6 +547,8 @@ static int hmm_vma_walk_test(unsigned long start, unsigned long end,
 
 	hmm_pfns_fill(start, end, range, HMM_PFN_ERROR);
 
+	/* Update last to the end of the skipped VMA to prevent reprocessing */
+	hmm_vma_walk->last = end;
 	/* Skip this vma and continue processing the next vma. */
 	return 1;
 }
-- 
2.45.2



^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2025-01-28 18:04 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-01-28  6:34 [PATCH] mm/hmm: Prevent infinite loop in hmm_range_fault during EBUSY retries sooraj
2025-01-28  1:00 ` Andrew Morton
2025-01-28  1:16 ` Alistair Popple
2025-01-28 18:04 ` Jason Gunthorpe

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox