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

From: SeongJae Park

Date: Mon Apr 27 2026 - 11:10:21 EST


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

> From: Liew Rui Yan <aethernet65535@xxxxxxxxx>
[...]
> --- 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 ===