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=1796095629; b=uSsW60tW3rMFC2O/AY85gDactlz/B7jlbVFar8Tth/WUiWqfAS0iq4lizt/u242gjZbp bJIWVdAPZCqknAmV2P61P0DlWOxGrAip+2X2QiDHmuEUwoLChQrmLWRLK2VREeub5k7fk JaB5io907P+fohaGqhWV01Cu2e4Wa4OvG+hNCvMtTJf00um4zJzcEdBVXmRZc8hsz4+BE xbbdoSilxqnhWbuYkLJxyILIc4Eidrq5Fpm7oBDhPFBkhQH/zH+BgmMccLX6/KZ4Qn6U9 qB/XH5a76dDy68076ZjAlgv1iOUniAiufew144TULJoLVTAoiVmTocF8Za8KVWPJRdQ== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796095629; h=Received:DKIM-Signature:From:To:Cc:Subject:Date:Message-ID:X-Mailer: In-Reply-To:References:MIME-Version:Content-Transfer-Encoding; bh=i0U2z5pCn8NU7/vqAee1AzMfeaRWp36fPifUjtAaYM4=; b=FJjcIiY1dLmFjWw41lS3Aea01RLIuEcmxVWbBMB7oFfPY3y25t2I+4+03di03bKjdNOS lgiXxT48jI5TrC1B88ouoYxU1iAOsZaEeL/W+5Tg832d3pFqOcy8McFe8coQWE5MPhZd3 ca4vwHEO5t6BEeU5Z7OzI7Q1leEzm4j/E2dwh+iPgesU7pBa3Fxn6ZCko9ZSnjGXyYCgj JJXP5kZdKBOsxEB3yYgnEcmEKD3zAwolar6DAEsHp+QaKw64bO3SC2itNMKlm+H/rcGE2 fLw9e361DM2Xb6gW9pju6xtFyE5RERw2fgqVM395geYzB7zvgy9UR5XrAEtSvigoAOQ== 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=oPKqJGN2; 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 7D319606A327 for ; Tue, 1 Dec 2026 03:27:09 +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=oPKqJGN2 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 30FCC1F00897; Tue, 1 Dec 2026 03:27:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796095629; bh=i0U2z5pCn8NU7/vqAee1AzMfeaRWp36fPifUjtAaYM4=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=oPKqJGN2OfK7Z99vbHwoq35QDCqv14IjouNtbcylL4YFDcMKa/Hsnsfp3E7ml4Bqy rEd9zHIbwXqjDPWFnh+WTMARsLKkjL5mCBC+D1o75j1aXvtQjykkt4sjML0F3NsvXn Wlp4i3BSBZEFgmL0ptRAk8YVa0+UGm35ChgL35hkJPQ4Di79G3XWlgkxXg95Hy25T9 N77Jgbau6boOrfvaimo6kjiCl2Yby00qAl5YQjznHFIsMbU+mD06W+thnUM7bXT6CQ ZAa3NhAW3PxAls1OcPA9TewkWrhbG9qcpACCELkd7IBGney3nj0rHXJWNnuXJx0Rfk D6OLzVkyr8u8Q== From: SJ Park To: Cc: SJ Park , Andrew Morton , damon@lists.linux.dev, linux-mm@kvack.org Subject: [RFC PATCH v2 2/2] mm/damon/ops-common: use probe hits weighted sum for hotness Date: Mon, 30 Nov 2026 19:26:53 -0800 Message-ID: <20261201032655.123822-3-sj@kernel.org> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20261201032655.123822-1-sj@kernel.org> References: <20261201032655.123822-1-sj@kernel.org> X-Mailing-List: damon@lists.linux.dev List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: 8bit DAMOS finds memory that is eligible to apply the action, using DAMOS core filters and target access pattern. If the total amount of the eligible memory is larger than DAMOS quota, DAMOS selects memory to apply the action based on their hotness and the action type. For migrate_hot action, warmer regions are selected. For migrate_cold action, colder regions are selected. The hotness is calculated using the age and the access frequency. The frequency is counted in damon_region->nr_accesses. When DAMON is configured with data attribute probes and probe weights, it runs in attributes-only monitoring mode. In the mode, the traditional access frequency monitoring is skipped and therefore the access frequency counter is not updated. The prioritization logic will show all regions as having zero access frequency. For actions that prefer hot regions such as migrate_hot, regions of shorter age will be prioritized. For actions that prefer cold regions such as migrate_cold and pageout, regions of longer age will be prioritized. No real access frequency or the attributes monitoring results are considered. It is only chaotic and useless. In the attribute-only mode, probe hits weighted sum plays the role that is similar to that of the traditional access frequency. The adaptive region adjustment logic uses it in the attributes only mode. Do the same for the DAMOS quota region prioritization purpose hotness calculation. Replace the access frequency with the probe hits weighted sum for the hotness calculation in the mode. Signed-off-by: SJ Park --- mm/damon/ops-common.c | 23 ++++++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) diff --git a/mm/damon/ops-common.c b/mm/damon/ops-common.c index 38720794c9fc..f7fd35867505 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); +} + int damon_hot_score(struct damon_ctx *c, struct damon_region *r, struct damos *s) { @@ -175,9 +194,7 @@ 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, - damon_nr_samples_per_aggr(&c->attrs)); + freq_subscore = damon_freq_subscore(c, r); age_in_sec = div_u64((u64)r->age * c->attrs.aggr_interval, USEC_PER_SEC); -- 2.47.3