linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] mm: gup: fix infinite loop within __get_longterm_locked
@ 2025-01-20  9:26 zhaoyang.huang
  2025-01-20 19:34 ` John Hubbard
  2025-01-20 20:14 ` David Hildenbrand
  0 siblings, 2 replies; 6+ messages in thread
From: zhaoyang.huang @ 2025-01-20  9:26 UTC (permalink / raw)
  To: Andrew Morton, Alistair Popple, John Hubbard, linux-mm,
	linux-kernel, Zhaoyang Huang, steve.kang

From: Zhaoyang Huang <zhaoyang.huang@unisoc.com>

Infinite loop within __get_longterm_locked detected in an unique usage
of pin_user_pages where the VA's pages are all unpinnable(vm_ops->fault
function allocate pages via cma_alloc for hardware purpose and leave them
out of LRU). Fixing this by have 'collected' reflect the actual number
of pages in movable_folio_list.

Signed-off-by: Zhaoyang Huang <zhaoyang.huang@unisoc.com>
---
 mm/gup.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/mm/gup.c b/mm/gup.c
index 3b75e631f369..2231ce7221f9 100644
--- a/mm/gup.c
+++ b/mm/gup.c
@@ -2341,8 +2341,6 @@ static unsigned long collect_longterm_unpinnable_folios(
 		if (folio_is_longterm_pinnable(folio))
 			continue;
 
-		collected++;
-
 		if (folio_is_device_coherent(folio))
 			continue;
 
@@ -2359,6 +2357,8 @@ static unsigned long collect_longterm_unpinnable_folios(
 		if (!folio_isolate_lru(folio))
 			continue;
 
+		collected++;
+
 		list_add_tail(&folio->lru, movable_folio_list);
 		node_stat_mod_folio(folio,
 				    NR_ISOLATED_ANON + folio_is_file_lru(folio),
-- 
2.25.1



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

end of thread, other threads:[~2025-01-21  7:49 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-01-20  9:26 [PATCH] mm: gup: fix infinite loop within __get_longterm_locked zhaoyang.huang
2025-01-20 19:34 ` John Hubbard
2025-01-21  1:28   ` Zhaoyang Huang
2025-01-20 20:14 ` David Hildenbrand
2025-01-21  1:31   ` Zhaoyang Huang
2025-01-21  7:49     ` David Hildenbrand

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