linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Xin Hao <xhao@linux.alibaba.com>
To: sjpark@amazon.de
Cc: xhao@linux.alibaba.com, akpm@linux-foundation.org,
	linux-mm@kvack.org, linux-kernel@vger.kernel.org
Subject: [PATCH V3 3/4] mm/damon/core: Using function abs() instead of diff_of()
Date: Sat, 13 Nov 2021 00:02:41 +0800	[thread overview]
Message-ID: <f178322529c7498d85a545b9a07ac7c8dec7d58e.1636732449.git.xhao@linux.alibaba.com> (raw)
In-Reply-To: <cover.1636732449.git.xhao@linux.alibaba.com>

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

Signed-off-by: Xin Hao <xhao@linux.alibaba.com>
Reviewed-by: SeongJae Park <sj@kernel.org>
---
 mm/damon/core.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/mm/damon/core.c b/mm/damon/core.c
index f37c17b53814..4d2c3a0c7c8a 100644
--- a/mm/damon/core.c
+++ b/mm/damon/core.c
@@ -757,8 +757,6 @@ static void damon_merge_two_regions(struct damon_target *t,
 	damon_destroy_region(r, t);
 }
 
-#define diff_of(a, b) (a > b ? a - b : b - a)
-
 /*
  * Merge adjacent regions having similar access frequencies
  *
@@ -772,13 +770,13 @@ static void damon_merge_regions_of(struct damon_target *t, unsigned int thres,
 	struct damon_region *r, *prev = NULL, *next;
 
 	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;
 		else
 			r->age++;
 
 		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)
 			damon_merge_two_regions(t, prev, r);
 		else
-- 
2.31.0



  parent reply	other threads:[~2021-11-12 16:08 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-11-12 16:02 [PATCH V3 0/4] mm/damon: Do some small changes Xin Hao
2021-11-12 16:02 ` [PATCH V3 1/4] mm/damon: Unified access_check function naming rules Xin Hao
2021-11-12 16:02 ` [PATCH V3 2/4] mm/damon: Add 'age' of region tracepoint support Xin Hao
2021-11-12 16:02 ` Xin Hao [this message]
2021-11-13  2:46   ` [PATCH V3 3/4] mm/damon/core: Using function abs() instead of diff_of() Muchun Song
2021-11-12 16:02 ` [PATCH V3 4/4] mm/damon: Remove some no need func definitions in damon.h file Xin Hao
2021-11-15 10:23   ` kernel test robot
2021-11-15 14:52   ` kernel test robot

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=f178322529c7498d85a545b9a07ac7c8dec7d58e.1636732449.git.xhao@linux.alibaba.com \
    --to=xhao@linux.alibaba.com \
    --cc=akpm@linux-foundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=sjpark@amazon.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox