Re: [PATCH v2 1/4] mm/damon/ops-common: optimize damon_hot_score() using ilog2()

SeongJae Park
2026-04-27T15:10:01Z

On Sun, 26 Apr 2026 16:16:14 -0700 SeongJae Park <sj@kernel.org> wrote:

> From: Liew Rui Yan <aethernet65535@gmail.com>
[...]
> --- a/mm/damon/ops-common.c
> +++ b/mm/damon/ops-common.c
> @@ -117,9 +117,12 @@ int damon_hot_score(struct damon_ctx *c, struct damon_region *r,
> damon_max_nr_accesses(&c->attrs);
>
> age_in_sec = (unsigned long)r->age * c->attrs.aggr_interval / 1000000;
> - for (age_in_log = 0; age_in_log < DAMON_MAX_AGE_IN_LOG && age_in_sec;
> - age_in_log++, age_in_sec >>= 1)
> - ;
> + if (age_in_sec)
> + age_in_log = min_t(int, ilog2(age_in_sec) + 1,
> + DAMON_MAX_AGE_IN_LOG);
> + else
> + age_in_log = 0;
> +
>
> /* If frequency is 0, higher age means it's colder */
> if (freq_subscore == 0)

Sashiko found this patch is introducing two blank lines. Andrew, I saw you
already added this to mm-new. Could you please add below attaching fixup? If
you prefer reposting this patch, please let me know.

Thanks,
SJ

[...]
=== >8 ===
From 1d97945a7c35463d3757df985cf3545bf9d5ed9c Mon Sep 17 00:00:00 2001
From: SeongJae Park <sj@kernel.org>
Date: Mon, 27 Apr 2026 08:05:09 -0700
Subject: [PATCH] mm/damon/ops-common: (fixup) remove unnecessary blank line

Two blank lines are unnecessary.

The issue was discovered [1] by Sashiko.

[1] https://lore.kernel.org/20260426232811.618BFC2BCAF@smtp.kernel.org

Signed-off-by: SeongJae Park <sj@kernel.org>
---
mm/damon/ops-common.c | 1 -
1 file changed, 1 deletion(-)

diff --git a/mm/damon/ops-common.c b/mm/damon/ops-common.c
index 3a0ddc3ac7196..b2ce817f33c53 100644
--- a/mm/damon/ops-common.c
+++ b/mm/damon/ops-common.c
@@ -123,7 +123,6 @@ int damon_hot_score(struct damon_ctx *c, struct damon_region *r,
else
age_in_log = 0;

-
/* If frequency is 0, higher age means it's colder */
if (freq_subscore == 0)
age_in_log *= -1;
--
2.47.3