DAMON development mailing list
 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 v2 2/2] mm/damon/ops-common: use probe hits weighted sum for hotness
Date: Tue, 01 Dec 2026 03:34:02 +0000	[thread overview]
Message-ID: <sashiko-outbox-242446@kernel.org> (raw)
In-Reply-To: <20261201032655.123822-3-sj@kernel.org>

Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [High] mm/damon: inverted damon_has_probe_weights() check in
  damon_freq_subscore()
--

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

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

This commit introduces damon_freq_subscore() to compute the frequency
subscore in damon_hot_score() from the probe hits weighted sum when
DAMON runs in attributes-only monitoring mode.

> diff --git a/mm/damon/ops-common.c b/mm/damon/ops-common.c
> index 38720794c9fcf..f7fd35867505c 100644
> --- a/mm/damon/ops-common.c
> +++ b/mm/damon/ops-common.c
> @@ -165,6 +165,25 @@ void damon_hugetlb_mkold(pte_t *pte, struct mm_struct *mm,
>  #define DAMON_MAX_SUBSCORE	(100)
>  #define DAMON_MAX_AGE_IN_LOG	(32)
>  
> +static int damon_freq_subscore(struct damon_ctx *c,
> +		struct damon_region *r)
> +{
> +	unsigned int num, denom, samples_per_aggr;
> +	struct damon_probe *p;
> +
> +	samples_per_aggr = damon_nr_samples_per_aggr(&c->attrs);
> +	if (!damon_has_probe_weights(c)) {
> +		num = damon_probe_hits_wsum(r, false, true, c);
> +		denom = 0;
> +		damon_for_each_probe(p, c)
> +			denom += samples_per_aggr * p->weight;
> +	} else {
> +		num = damon_nr_accesses_mvsum(r, c);
> +		denom = samples_per_aggr;
> +	}
> +	return mult_frac(num, DAMON_MAX_SUBSCORE, denom);
> +}

[Severity: High]
Is the damon_has_probe_weights(c) check inverted here?  When no probe has
a non-zero weight, damon_has_probe_weights(c) returns false, so denom
stays 0 and mult_frac() divides by zero; when probe weights are configured,
this takes the else branch and uses damon_nr_accesses_mvsum() instead of
damon_probe_hits_wsum().

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

  reply	other threads:[~2026-12-01  3:34 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-12-01  3:26 [RFC PATCH v2 0/2] mm/damon: improve DAMOS quota region prioritization in attr-only mode SJ Park
2026-12-01  3:26 ` [RFC PATCH v2 1/2] mm/damon/core: expose damon_has_probe_weights() SJ Park
2026-12-01  3:26 ` [RFC PATCH v2 2/2] mm/damon/ops-common: use probe hits weighted sum for hotness SJ Park
2026-12-01  3:34   ` sashiko-bot [this message]
2026-12-01  3:35     ` SJ Park
2026-12-01  3:34 ` [RFC PATCH v2 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-242446@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox