Commit 652e0446 authored by Xin Hao's avatar Xin Hao Committed by Andrew Morton

mm/damon: move sz_damon_region to damon_sz_region

Rename sz_damon_region() to damon_sz_region(), and move it to
"include/linux/damon.h", because in many places, we can to use this func.

Link: https://lkml.kernel.org/r/20220927001946.85375-1-xhao@linux.alibaba.comSigned-off-by: default avatarXin Hao <xhao@linux.alibaba.com>
Suggested-by: default avatarSeongJae Park <sj@kernel.org>
Reviewed-by: default avatarSeongJae Park <sj@kernel.org>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
parent ea091fa5
...@@ -484,6 +484,12 @@ static inline struct damon_region *damon_first_region(struct damon_target *t) ...@@ -484,6 +484,12 @@ static inline struct damon_region *damon_first_region(struct damon_target *t)
return list_first_entry(&t->regions_list, struct damon_region, list); return list_first_entry(&t->regions_list, struct damon_region, list);
} }
static inline unsigned long damon_sz_region(struct damon_region *r)
{
return r->ar.end - r->ar.start;
}
#define damon_for_each_region(r, t) \ #define damon_for_each_region(r, t) \
list_for_each_entry(r, &t->regions_list, list) list_for_each_entry(r, &t->regions_list, list)
......
...@@ -864,18 +864,13 @@ static void kdamond_apply_schemes(struct damon_ctx *c) ...@@ -864,18 +864,13 @@ static void kdamond_apply_schemes(struct damon_ctx *c)
} }
} }
static inline unsigned long sz_damon_region(struct damon_region *r)
{
return r->ar.end - r->ar.start;
}
/* /*
* Merge two adjacent regions into one region * Merge two adjacent regions into one region
*/ */
static void damon_merge_two_regions(struct damon_target *t, static void damon_merge_two_regions(struct damon_target *t,
struct damon_region *l, struct damon_region *r) struct damon_region *l, struct damon_region *r)
{ {
unsigned long sz_l = sz_damon_region(l), sz_r = sz_damon_region(r); unsigned long sz_l = damon_sz_region(l), sz_r = damon_sz_region(r);
l->nr_accesses = (l->nr_accesses * sz_l + r->nr_accesses * sz_r) / l->nr_accesses = (l->nr_accesses * sz_l + r->nr_accesses * sz_r) /
(sz_l + sz_r); (sz_l + sz_r);
...@@ -904,7 +899,7 @@ static void damon_merge_regions_of(struct damon_target *t, unsigned int thres, ...@@ -904,7 +899,7 @@ static void damon_merge_regions_of(struct damon_target *t, unsigned int thres,
if (prev && prev->ar.end == r->ar.start && if (prev && prev->ar.end == r->ar.start &&
abs(prev->nr_accesses - r->nr_accesses) <= thres && abs(prev->nr_accesses - r->nr_accesses) <= thres &&
sz_damon_region(prev) + sz_damon_region(r) <= sz_limit) damon_sz_region(prev) + damon_sz_region(r) <= sz_limit)
damon_merge_two_regions(t, prev, r); damon_merge_two_regions(t, prev, r);
else else
prev = r; prev = r;
......
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