Commit d720bbbd authored by Xin Hao's avatar Xin Hao Committed by Linus Torvalds

mm/damon/core: use abs() instead of diff_of()

In kernel, we can use abs(a - b) to get the absolute value, So there is no
need to redefine a new one.

Link: https://lkml.kernel.org/r/b24e7b82d9efa90daf150d62dea171e19390ad0b.1636989871.git.xhao@linux.alibaba.comSigned-off-by: default avatarXin Hao <xhao@linux.alibaba.com>
Reviewed-by: default avatarMuchun Song <songmuchun@bytedance.com>
Reviewed-by: default avatarSeongJae Park <sj@kernel.org>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
parent c46b0bb6
...@@ -750,8 +750,6 @@ static void damon_merge_two_regions(struct damon_target *t, ...@@ -750,8 +750,6 @@ static void damon_merge_two_regions(struct damon_target *t,
damon_destroy_region(r, t); damon_destroy_region(r, t);
} }
#define diff_of(a, b) (a > b ? a - b : b - a)
/* /*
* Merge adjacent regions having similar access frequencies * Merge adjacent regions having similar access frequencies
* *
...@@ -765,13 +763,13 @@ static void damon_merge_regions_of(struct damon_target *t, unsigned int thres, ...@@ -765,13 +763,13 @@ static void damon_merge_regions_of(struct damon_target *t, unsigned int thres,
struct damon_region *r, *prev = NULL, *next; struct damon_region *r, *prev = NULL, *next;
damon_for_each_region_safe(r, next, t) { damon_for_each_region_safe(r, next, t) {
if (diff_of(r->nr_accesses, r->last_nr_accesses) > thres) if (abs(r->nr_accesses - r->last_nr_accesses) > thres)
r->age = 0; r->age = 0;
else else
r->age++; r->age++;
if (prev && prev->ar.end == r->ar.start && if (prev && prev->ar.end == r->ar.start &&
diff_of(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) sz_damon_region(prev) + sz_damon_region(r) <= sz_limit)
damon_merge_two_regions(t, prev, r); damon_merge_two_regions(t, prev, r);
else else
......
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