Commit 3f98c9a6 authored by andrew.yang's avatar andrew.yang Committed by Andrew Morton

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: 57223ac2 ("mm/damon/paddr: support the pageout scheme")
Signed-off-by: default avatarandrew.yang <andrew.yang@mediatek.com>
Reviewed-by: default avatarSeongJae Park <sj@kernel.org>
Cc: <stable@vger.kernel.org>	[5.16.x]
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
parent 4c675996
...@@ -250,13 +250,12 @@ static unsigned long damon_pa_pageout(struct damon_region *r, struct damos *s) ...@@ -250,13 +250,12 @@ static unsigned long damon_pa_pageout(struct damon_region *r, struct damos *s)
folio_put(folio); folio_put(folio);
continue; continue;
} }
if (folio_test_unevictable(folio)) { if (folio_test_unevictable(folio))
folio_putback_lru(folio); folio_putback_lru(folio);
} else { else
list_add(&folio->lru, &folio_list); list_add(&folio->lru, &folio_list);
folio_put(folio); folio_put(folio);
} }
}
applied = reclaim_pages(&folio_list); applied = reclaim_pages(&folio_list);
cond_resched(); cond_resched();
return applied * PAGE_SIZE; return applied * PAGE_SIZE;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment