Commit 8193321a authored by SeongJae Park's avatar SeongJae Park Committed by Andrew Morton

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.orgSigned-off-by: default avatarSeongJae Park <sj@kernel.org>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
parent f82e70e2
...@@ -232,7 +232,8 @@ static unsigned long damon_pa_pageout(struct damon_region *r) ...@@ -232,7 +232,8 @@ static unsigned long damon_pa_pageout(struct damon_region *r)
return applied * PAGE_SIZE; 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; unsigned long addr, applied = 0;
...@@ -241,27 +242,24 @@ static unsigned long damon_pa_mark_accessed(struct damon_region *r) ...@@ -241,27 +242,24 @@ static unsigned long damon_pa_mark_accessed(struct damon_region *r)
if (!page) if (!page)
continue; continue;
if (mark_accessed)
mark_page_accessed(page); mark_page_accessed(page);
else
deactivate_page(page);
put_page(page); put_page(page);
applied++; applied++;
} }
return applied * PAGE_SIZE; return applied * PAGE_SIZE;
} }
static unsigned long damon_pa_deactivate_pages(struct damon_region *r) static unsigned long damon_pa_mark_accessed(struct damon_region *r)
{ {
unsigned long addr, applied = 0; return damon_pa_mark_accessed_or_deactivate(r, true);
}
for (addr = r->ar.start; addr < r->ar.end; addr += PAGE_SIZE) {
struct page *page = damon_get_page(PHYS_PFN(addr));
if (!page) static unsigned long damon_pa_deactivate_pages(struct damon_region *r)
continue; {
deactivate_page(page); return damon_pa_mark_accessed_or_deactivate(r, false);
put_page(page);
applied++;
}
return applied * PAGE_SIZE;
} }
static unsigned long damon_pa_apply_scheme(struct damon_ctx *ctx, static unsigned long damon_pa_apply_scheme(struct damon_ctx *ctx,
......
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