From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1795998452; b=xPqw2Rt+t1H8V9WlFHxloa914+4xaAcdjDRJ/o1L99OBOkBNzvUmY1g4gA07WfuqsVU2 rSPsE1saF1PpVG4VFthifeN8KbJGmmLFQPAGS2zS7Tlz465wuPwcIX27R4cE4meYcK1B7 yhNfT4q8Yge4Z17gLtR5aLBHliVmMCf+0XHPx6Ij4E6K4G5MmyhaQxucasxWspgSu36jD b4MjCLf8jTRc3fY0M4DQs4QdF+G353zHtXq56CC174UXEosoqhWz2bgWxz+J8MKuIbHyg syHtdi+tXrCbbN8L4vF3SuD9ijoB/4r+mOw7DNuBGV7DhBXOm0nTimbVz+548ajXPxQ== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795998452; h=Received:DKIM-Signature:Message-ID:From:Subject:Reply-To:To:Cc: In-Reply-To:References:Content-Type:Content-Transfer-Encoding:Date; bh=XE3tWb/7v5GE0bef0JLVKjRBjEzTEfyf2u7HkcM37sg=; b=zSwYazsa8ll9R5b3HcCAgWAuBhQLwNkA6lEBGGUkKECSZ5ab7FUWVboWoetLqzlXFN3v qvfj7/muLi3TNIYm/EW6dpr43viWmVnckb53aj40EvaR3AvJM8ansXqia0A0DwcgdzBGX VI2F17WjgFQ0H4pjkO8sgOqRnYsN3aRzNagnOgDSKHzdJojtsIzng9dzI9ERx58quvn78 zGrhU88s0Zthvom9Sa6QVkS/ig8sPSh2K/1w9lrfyS7pKgZdBO8pByH/8f3LTXsVn4PiN dJp2YxzcYo0/mGxcw9pM+Gh+5E61Q20pmnuOxx2BDhsD7T92lJQhutGHSZdcjHdLoXg== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=OLE9kGE1; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B1FFA606A31C for ; Mon, 30 Nov 2026 00:27:32 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=OLE9kGE1 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 633BC1F000C1; Mon, 30 Nov 2026 00:27:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1795998452; bh=XE3tWb/7v5GE0bef0JLVKjRBjEzTEfyf2u7HkcM37sg=; h=From:Subject:Reply-To:To:Cc:In-Reply-To:References:Date; b=OLE9kGE1RM0HmXPGFBPUC74qio5Fpt+oPy4zSkB62e/p1wpxFfLNvP+fRWve3vXtt poU5rZfOCQCN1jAYKd6idYOijsakusD1Xvt5fT8ijnVIkj6D7Tjljzwlt8TjSQYtZz uKwAGR62A2ani2BC3vjOudJuyP7e+hYaeM2W5F6VX9/nFhTGMyJ6C2EAirrxjgDp4K qI6zQ/Jf5FgRe6xX9ktnl9FtWrCJyWxMFqSQ+VkcUzbIurcNHMCVTU0O3ZohmSDDnL GYkq+MZHRJDepGC2icbZ7KYq8c6SOcDYpEiWU5GQIxJjHhkQGbcPzQoBLqeWXeOo8S WVpFkjzaWB3NQ== Message-ID: From: sashiko-bot@kernel.org Subject: Re: [RFC PATCH 2/2] mm/damon/ops-common: use probe hits weighted sum for hotness Reply-To: sashiko-reviews@lists.linux.dev To: "SJ Park" Cc: "Andrew Morton" , damon@lists.linux.dev, linux-mm@kvack.org In-Reply-To: <20261130001530.173703-3-sj@kernel.org> References: <20261130001530.173703-1-sj@kernel.org> <20261130001530.173703-3-sj@kernel.org> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Date: Mon, 30 Nov 2026 00:27:31 +0000 X-Mailing-List: damon@lists.linux.dev List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list 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 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 damo= n_region *r, > unsigned int age_weight =3D s->quota.weight_age; > int hotness; > =20 > - freq_subscore =3D mult_frac(damon_nr_accesses_mvsum(r, c), > - DAMON_MAX_SUBSCORE, > + if (damon_has_probe_weights(c)) > + nr_events =3D damon_probe_hits_wsum(r, false, true, c); > + else > + nr_events =3D damon_nr_accesses_mvsum(r, c); > + > + freq_subscore =3D 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. --=20 Sashiko AI review =C2=B7 https://sashiko.dev/#/patchset/20261130001530.1737= 03-1-sj@kernel.org?part=3D2