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=1795997739; b=rATOxkntSsUZSHf2OI4OK7d3zhW8JizPbmd5rXSwmPMzyKyJluLS3NOiSh56vHeO72PY Df+zhywLMeOu4wSRXSK+nyOW7vkOIg4Ox1ynBdXjsFgt8yWx/7W61dLh6TZindoBpmEKc PoETCxPVONeZpndfjYBirKdY3HC+/iwOBKma/m3SGOsR/mrzRRUBY+xQ5nhwOOdB8eR1K MlY2LwUnmQCNC4CLb7RsSP112pXcLN18WNWeGfXKQDO9jb+qr24Ti7iWbakhUt1mAEuFS F9uJ+l1r2mPGnfOYhTaM4HK0I5JABDXFZ1GcCkDJ0JEAuJleWhOfNc6ToXHQL/lpbQA== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795997739; h=Received:DKIM-Signature:From:To:Cc:Subject:Date:Message-ID:X-Mailer: In-Reply-To:References:MIME-Version:Content-Transfer-Encoding; bh=GycrmzdAflXX/LqLPke3TjBOHeS+/6MUeeaorLMX9xs=; b=uR4e1zKaSbsnJhEmfPp9OdYxZcLl6du8Seu3YFTaSrFrtvSsIzI4eaU5CX9N93KTa3d8 Kz8rOe8ynqTcH54zYbn0+4HjVsJiQno50cadHqmlkO9QOaFMw2VJaqOoLvsh4O/gT37/N nMQIorjtShPVgRZO4adBUw3s7l16YDYDc/A2Y31Ox9XaoFq/r/AJjHuaef3MkhkedCSlM ndtTQ764whXjlwX51/uIRaBHUopMo6Elo5GgSr8Pnnqvie2fPAoXFRyIueP8+xFMhYvO6 vfqaunASCeMLKaT4d9diYat2b02jsFiKiB8l5C7tPuV3EdjnbjXsVkykJzasnj9SBXA== 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=NWJw1SGo; 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 85149606A327 for ; Mon, 30 Nov 2026 00:15:39 +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=NWJw1SGo Received: by smtp.kernel.org (Postfix) with ESMTPSA id 3DD4B1F000C1; Mon, 30 Nov 2026 00:15:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1795997739; bh=GycrmzdAflXX/LqLPke3TjBOHeS+/6MUeeaorLMX9xs=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=NWJw1SGo0FMdf/Zx5oTUaIv8JsTcMs2I6RxlbxzIrELJXwYoK2wMGXuSYPhEAtx7X WSPhzd/fafBeWrMNxqYekgCFM3543dJADucdC7339EDp7GF1+YzuA9gDt74wHMZzAO kLs36y96/VFD1bZEb+IiikDLYEdHZDm0bM2JZtzMb11S1ViarojXcEYJCfJJZD7j5W Nkvgd9uqnbSodO/O+mGs7+VZ6nTk2zAG9pP/XnMfxBEZE6i86hUUCX9VxOfCUxD4mv BjKTPaZ5v1Ic1UBwT3ydjb6sf20wOJi/0tzD+uItSAptIJonMuC32/ktCM0MkZrJ5v CawgL3wRftORA== From: SJ Park To: Cc: SJ Park , Andrew Morton , damon@lists.linux.dev, linux-mm@kvack.org Subject: [RFC PATCH 2/2] mm/damon/ops-common: use probe hits weighted sum for hotness Date: Sun, 29 Nov 2026 16:15:29 -0800 Message-ID: <20261130001530.173703-3-sj@kernel.org> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20261130001530.173703-1-sj@kernel.org> References: <20261130001530.173703-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 | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/mm/damon/ops-common.c b/mm/damon/ops-common.c index 2216a0023154..9197ead1c96b 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)); age_in_sec = div_u64((u64)r->age * c->attrs.aggr_interval, -- 2.47.3