mm/damon/paddr: deduplicate damon_pa_{mark_accessed,deactivate_pages}()

The bodies of damon_pa_{mark_accessed,deactivate_pages}() contains
duplicates.  This commit factors out the common part to a separate
function and removes the duplicates.

Link: https://lkml.kernel.org/r/20220913174449.50645-3-sj@kernel.org
Signed-off-by: SeongJae Park <sj@kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
This commit is contained in:
SeongJae Park 2022-09-13 17:44:29 +00:00 committed by Andrew Morton
parent f82e70e26b
commit 8193321ac9
1 changed files with 12 additions and 14 deletions

View File

@ -232,7 +232,8 @@ static unsigned long damon_pa_pageout(struct damon_region *r)
return applied * PAGE_SIZE;
}
static unsigned long damon_pa_mark_accessed(struct damon_region *r)
static inline unsigned long damon_pa_mark_accessed_or_deactivate(
struct damon_region *r, bool mark_accessed)
{
unsigned long addr, applied = 0;
@ -241,27 +242,24 @@ static unsigned long damon_pa_mark_accessed(struct damon_region *r)
if (!page)
continue;
mark_page_accessed(page);
if (mark_accessed)
mark_page_accessed(page);
else
deactivate_page(page);
put_page(page);
applied++;
}
return applied * PAGE_SIZE;
}
static unsigned long damon_pa_mark_accessed(struct damon_region *r)
{
return damon_pa_mark_accessed_or_deactivate(r, true);
}
static unsigned long damon_pa_deactivate_pages(struct damon_region *r)
{
unsigned long addr, applied = 0;
for (addr = r->ar.start; addr < r->ar.end; addr += PAGE_SIZE) {
struct page *page = damon_get_page(PHYS_PFN(addr));
if (!page)
continue;
deactivate_page(page);
put_page(page);
applied++;
}
return applied * PAGE_SIZE;
return damon_pa_mark_accessed_or_deactivate(r, false);
}
static unsigned long damon_pa_apply_scheme(struct damon_ctx *ctx,