From: SeongJae Park <sj@kernel.org>
To: Liew Rui Yan <aethernet65535@gmail.com>
Cc: SeongJae Park <sj@kernel.org>,
damon@lists.linux.dev, linux-mm@kvack.org,
Andrew Morton <akpm@linux-foundation.org>
Subject: Re: [PATCH v2] mm/damon/ops-common: optimize damon_hot_score() using ilog2()
Date: Fri, 20 Mar 2026 17:23:10 -0700 [thread overview]
Message-ID: <20260321002311.69009-1-sj@kernel.org> (raw)
In-Reply-To: <20260320192020.33004-1-aethernet65535@gmail.com>
Hello Liew,
When you send a new version of patches, please send those as new thread, rather
than as a reply to the previous version.
On Sat, 21 Mar 2026 03:20:20 +0800 Liew Rui Yan <aethernet65535@gmail.com> wrote:
> The current implementation of damon_hot_score() uses a manual for-loop
> to calculate the value of 'age_in_log'. This can be efficiently replaced
> by ilog2(), which is semantically more appropriate for calculating the
> logarithmic value of age.
>
> In a simulated-kernel-module performance test with 10,000,000 iterations,
> this optimization showed a significant reduction in latency (average
> latency reduced from ~12ns to ~1ns).
>
> Test results from the simulated-kernel-module:
> - ilog2:
> DAMON Perf Test: Starting 10000000 iterations
> =============================================
> Total Iterations : 10000000
> Average Latency : 1 ns
> P95 Latency : 41 ns
> P99 Latency : 41 ns
> ---------------------------------------------
> Range (ns) | Count | Percent
> ---------------------------------------------
> 0-19 | 0 | 0%
> 20-39 | 2625000 | 26%
> 40-59 | 7374000 | 73%
> 60-79 | 0 | 0%
> 80-99 | 0 | 0%
> 100+ | 1000 | 0%
> =============================================
>
> - for-loop:
> DAMON Perf Test: Starting 10000000 iterations
> =============================================
> Total Iterations : 10000000
> Average Latency : 12 ns
> P95 Latency : 51 ns
> P99 Latency : 60 ns
> ---------------------------------------------
> Range (ns) | Count | Percent
> ---------------------------------------------
> 0-19 | 0 | 0%
> 20-39 | 0 | 0%
> 40-59 | 9862000 | 98%
> 60-79 | 135000 | 1%
> 80-99 | 1000 | 0%
> 100+ | 2000 | 0%
> =============================================
Nice!
>
> Full raw benchmark results can be found at [1].
>
> [1] https://github.com/aethernet65535/damon-hot-score-fls-optimize/tree/master/result-raw
>
> Signed-off-by: Liew Rui Yan <aethernet65535@gmail.com>
Reviewed-by: SeongJae Park <sj@kernel.org>
> ---
> Changes from v1:
> - Replace fls() with ilog2() per SeongJae Park's suggestion for better
> semantic clarity.
> - Move performance benchmark results into the commit message and add
> comparison between for-loop and ilog2.
As I mentioned at the beginning, please send new versions as new thread from
the next time. And, in the case, consider adding a link to the previous
versions.
[1] https://docs.kernel.org/process/submitting-patches.html#commentary
Thanks,
SJ
[...]
prev parent reply other threads:[~2026-03-21 0:23 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-03-20 7:24 [RFC PATCH] mm/damon/ops-common: optimize damon_hot_score() using fls() Liew Rui Yan
2026-03-20 15:05 ` SeongJae Park
2026-03-20 19:20 ` [PATCH v2] mm/damon/ops-common: optimize damon_hot_score() using ilog2() Liew Rui Yan
2026-03-21 0:23 ` SeongJae Park [this message]
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=20260321002311.69009-1-sj@kernel.org \
--to=sj@kernel.org \
--cc=aethernet65535@gmail.com \
--cc=akpm@linux-foundation.org \
--cc=damon@lists.linux.dev \
--cc=linux-mm@kvack.org \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.