All of lore.kernel.org
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "SJ Park" <sj@kernel.org>
Cc: "Andrew Morton" <akpm@linux-foundation.org>,
	damon@lists.linux.dev, linux-mm@kvack.org
Subject: Re: [RFC PATCH 2/2] mm/damon/ops-common: use probe hits weighted sum for hotness
Date: Mon, 30 Nov 2026 00:27:31 +0000	[thread overview]
Message-ID: <sashiko-outbox-240158@kernel.org> (raw)
In-Reply-To: <20261130001530.173703-3-sj@kernel.org>

Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [Medium] mm/damon: unnormalized probe weight sum in damon_hot_score()
--

commit a023b890f9f2134b02ad0d5476f73b5146e1e76b
Author: SJ Park <sj@kernel.org>

mm/damon/ops-common: use probe hits weighted sum for hotness

This commit uses the moving weighted sum of probe hits instead of the
access frequency counter in damon_hot_score() when DAMON runs with probe
weights configured.

> diff --git a/mm/damon/ops-common.c b/mm/damon/ops-common.c
> index 2216a0023154f..9197ead1c96b0 100644
> --- a/mm/damon/ops-common.c
> +++ b/mm/damon/ops-common.c
> @@ -168,6 +168,7 @@ void damon_hugetlb_mkold(pte_t *pte, struct mm_struct *mm,
>  int damon_hot_score(struct damon_ctx *c, struct damon_region *r,
>  			struct damos *s)
>  {
> +	unsigned int nr_events;
>  	int freq_subscore;
>  	u64 age_in_sec;
>  	int age_in_log, age_subscore;
> @@ -175,8 +176,12 @@ int damon_hot_score(struct damon_ctx *c, struct damon_region *r,
>  	unsigned int age_weight = s->quota.weight_age;
>  	int hotness;
>  
> -	freq_subscore = mult_frac(damon_nr_accesses_mvsum(r, c),
> -			DAMON_MAX_SUBSCORE,
> +	if (damon_has_probe_weights(c))
> +		nr_events = damon_probe_hits_wsum(r, false, true, c);
> +	else
> +		nr_events = damon_nr_accesses_mvsum(r, c);
> +
> +	freq_subscore = mult_frac(nr_events, DAMON_MAX_SUBSCORE,
>  			damon_nr_samples_per_aggr(&c->attrs));

[Severity: Medium]
Does freq_subscore also need to be divided by the sum of probe->weight
when damon_has_probe_weights(c) is true?

damon_probe_hits_wsum() multiplies each probe's hit count by
probe->weight, so its maximum value per aggregation interval is
damon_nr_samples_per_aggr(&c->attrs) * sum(probe->weight) rather than
damon_nr_samples_per_aggr(&c->attrs).  Dividing only by
damon_nr_samples_per_aggr(&c->attrs) scales freq_subscore up to
DAMON_MAX_SUBSCORE * sum(probe->weight), which overpowers age_subscore
(in [0, DAMON_MAX_SUBSCORE]) and saturates hotness at DAMOS_MAX_SCORE
even at low hit rates whenever the total probe weight exceeds 1.  For
large probe weights allowed by damon_valid_probe_params(), the subsequent
32-bit signed arithmetic on freq_subscore and hotness can also overflow
and clamp hotness to 0.

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261130001530.173703-1-sj@kernel.org?part=2

  reply	other threads:[~2026-11-30  0:27 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-30  0:15 [RFC PATCH 0/2] mm/damon: improve DAMOS quota region prioritization in attr-only mode SJ Park
2026-11-30  0:15 ` [RFC PATCH 1/2] mm/damon/core: expose damon_has_probe_weights() SJ Park
2026-11-30  0:15 ` [RFC PATCH 2/2] mm/damon/ops-common: use probe hits weighted sum for hotness SJ Park
2026-11-30  0:27   ` sashiko-bot [this message]
2026-11-30  0:47     ` SJ Park
2026-11-30  0:27 ` [RFC PATCH 0/2] mm/damon: improve DAMOS quota region prioritization in attr-only mode sashiko-bot

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=sashiko-outbox-240158@kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=akpm@linux-foundation.org \
    --cc=damon@lists.linux.dev \
    --cc=linux-mm@kvack.org \
    --cc=sashiko-reviews@lists.linux.dev \
    --cc=sj@kernel.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.