Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

mm/damon/paddr: fix missing folio_put()

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.

Link: https://lkml.kernel.org/r/20230222064223.6735-1-andrew.yang@mediatek.com
Fixes: 57223ac29584 ("mm/damon/paddr: support the pageout scheme")
Signed-off-by: andrew.yang <andrew.yang@mediatek.com>
Reviewed-by: SeongJae Park <sj@kernel.org>
Cc: <stable@vger.kernel.org> [5.16.x]
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>

authored by

andrew.yang and committed by
Andrew Morton
3f98c9a6 4c675996

+3 -4
+3 -4
mm/damon/paddr.c
··· 250 250 folio_put(folio); 251 251 continue; 252 252 } 253 - if (folio_test_unevictable(folio)) { 253 + if (folio_test_unevictable(folio)) 254 254 folio_putback_lru(folio); 255 - } else { 255 + else 256 256 list_add(&folio->lru, &folio_list); 257 - folio_put(folio); 258 - } 257 + folio_put(folio); 259 258 } 260 259 applied = reclaim_pages(&folio_list); 261 260 cond_resched();