DAMON development mailing list
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "DaeMyung Kang" <charsyam@gmail.com>
Cc: damon@lists.linux.dev
Subject: Re: [RFC PATCH 1/3] mm/damon/ops-common: avoid overflow in weighted hotness score
Date: Tue, 27 Oct 2026 14:05:13 +0000	[thread overview]
Message-ID: <sashiko-outbox-186693@kernel.org> (raw)
In-Reply-To: <20261027135932.2301646-2-charsyam@gmail.com>

> damon_hot_score() combines the frequency and age subscores using the
> user supplied DAMOS quota weights.  The weights are unsigned int, and
> both the weighted sum and the total weight are calculated in unsigned
> int.  This is independent of the architecture word size.
> 
> A frequency weight of 50,000,000 makes the weighted sum wrap, so a
> region that is accessed in every sample gets a score of 13 instead of
> 99.  If the two weights add up to exactly 2^32, the total wraps to zero
> and the averaging division is skipped.
> 
> Accumulate both values in u64 and divide the weighted sum by the full
> total weight.  Add a KUnit case covering a large weight, weights summing
> above UINT_MAX, and zero weights.
> 
> The issue was discovered [1] by Sashiko.
> 
> [1] https://lore.kernel.org/20260623141527.044D11F000E9@smtp.kernel.org
> 
> Fixes: 198f0f4c58b9 ("mm/damon/vaddr,paddr: support pageout prioritization")
> Signed-off-by: DaeMyung Kang <charsyam@gmail.com>

Sashiko has reviewed this patch and found no issues.

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261027135932.2301646-1-charsyam@gmail.com?part=1


  reply	other threads:[~2026-10-27 14:05 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-27 13:59 [RFC PATCH 0/3] mm/damon: fix overflows in score and ratio calculations DaeMyung Kang
2026-10-27 13:59 ` [RFC PATCH 1/3] mm/damon/ops-common: avoid overflow in weighted hotness score DaeMyung Kang
2026-10-27 14:05   ` sashiko-bot [this message]
2026-10-27 13:59 ` [RFC PATCH 2/3] mm/damon/core: avoid overflows in monitoring results calculations DaeMyung Kang
2026-10-27 14:10   ` sashiko-bot
2026-10-27 14:18   ` Gutierrez Asier
2026-10-27 13:59 ` [RFC PATCH 3/3] mm/damon/core: avoid overflows in quota goal metrics and scores DaeMyung Kang
2026-10-27 14:12   ` sashiko-bot
2026-10-27 14:23 ` [RFC PATCH 0/3] mm/damon: fix overflows in score and ratio calculations SJ Park

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-186693@kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=charsyam@gmail.com \
    --cc=damon@lists.linux.dev \
    --cc=sashiko-reviews@lists.linux.dev \
    /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