Skip to contentSkip to conversation

mm/damon/paddr: fix missing folio_put()

PATCH Applied Andrew Yang 2 participants 2 messages Feb 22, 2023

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

PATCH v3 1/1 mm/damon/paddr: fix missing folio_put()

From: "andrew.yang" <[email protected]>

damon_get_folio() would always increase folio _refcount and folio_isolate_lru() would increase folio _refcount if the folio's lru flag is set.

If an unevictable folio isolated successfully, there will be two more _refcount. The one from folio_isolate_lru() will be decreased in folio_puback_lru(), but the other one from damon_get_folio() will be left behind. This causes a pin page.

Whatever the case, the _refcount from damon_get_folio() should be decreased.

Fixes 57223ac29584 ("mm/damon/paddr: support the pageout scheme")
Cc <[email protected]> # 5.16.x

---
v3:
add fixes tag and cc stable
v2:
according to David's suggestion
1. revise subject
according to SeongJae's suggestions
1. rebase to mm-unstable tree
2. remove braces for th single statements

---
 mm/damon/paddr.c | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)
mm/damon/paddr.c +3 -4
index 607bb69e526c..6c655d9b5639 100644
@@ -250,12 +250,11 @@ static unsigned long damon_pa_pageout(struct damon_region *r, struct damos *s)
 			folio_put(folio);
 			continue;
 		}
-		if (folio_test_unevictable(folio)) {
+		if (folio_test_unevictable(folio))
 			folio_putback_lru(folio);
-		} else {
+		else
 			list_add(&folio->lru, &folio_list);
-			folio_put(folio);
-		}
+		folio_put(folio);
 	}
 	applied = reclaim_pages(&folio_list);
 	cond_resched();
Signature · 1 line
2.18.0
maintainer Reviewed-by on v3 1/1
#1 lore raw

Hi Andrew,

Thank you for revising this patch!

Quoted 11 lines

From: "andrew.yang" <[email protected]>

damon_get_folio() would always increase folio _refcount and folio_isolate_lru() would increase folio _refcount if the folio's lru flag is set.

If an unevictable folio isolated successfully, there will be two more _refcount. The one from folio_isolate_lru() will be decreased in folio_puback_lru(), but the other one from damon_get_folio() will be left behind. This causes a pin page.

Quoted 6 lines

Whatever the case, the _refcount from damon_get_folio() should be decreased.

Fixes 57223ac29584 ("mm/damon/paddr: support the pageout scheme")
Cc <[email protected]> # 5.16.x

This may not cleanly applicable on 6.1.y and 6.2.y. I would post backports once this is merged in the mainline, unless others do earlier than me.

Thanks,
SJ

Quoted 37 lines

---
v3:
add fixes tag and cc stable
v2:
according to David's suggestion
1. revise subject
according to SeongJae's suggestions
1. rebase to mm-unstable tree
2. remove braces for th single statements

---
 mm/damon/paddr.c | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)
mm/damon/paddr.c +3 -4
index 607bb69e526c..6c655d9b5639 100644
@@ -250,12 +250,11 @@ static unsigned long damon_pa_pageout(struct damon_region *r, struct damos *s)
 			folio_put(folio);
 			continue;
 		}
-		if (folio_test_unevictable(folio)) {
+		if (folio_test_unevictable(folio))
 			folio_putback_lru(folio);
-		} else {
+		else
 			list_add(&folio->lru, &folio_list);
-			folio_put(folio);
-		}
+		folio_put(folio);
 	}
 	applied = reclaim_pages(&folio_list);
 	cond_resched();
Signature · 1 line
2.18.0