From nobody Sat Feb 7 11:31:12 2026 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id EE69F392B94; Tue, 13 Jan 2026 15:27:30 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1768318051; cv=none; b=QOPIS9YuobUwTtzp3He/jQ1piI9nKsmmXw45Fwo6VITz8jwhZlsFXJvnhVAyWzz1rS/k1eNVDkJCjECT55tzwoKZ3S8HQkN4jOY1R/5QHc1Y5qx/goR0ZL+XB7vSsPJK/Qhw5vDpFn8zHRHesh+KE/63tQdQFNNrBmz0gNCyBdI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1768318051; c=relaxed/simple; bh=7NAyhkfQbcxTPtt6Wuep4buJLBzXp37MO61JEyiUHsU=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=My74nN90Dlxn34aMBmllbj5oO2Nzn8wXKtNqmGn3R04u3DDKqBBnq9QZdcltrgmvp4Wj+OGmZ72+Z8ayhu/GTeXkE5qHU05kZwXhfPQIr9aZI+msdJrrnjz/vQZpY5NWGfLUa4hoXoaauw2D66ckFVyVVtgpTTanGbYYdoGopAc= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=jVbA/nvA; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="jVbA/nvA" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 689D4C19421; Tue, 13 Jan 2026 15:27:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1768318050; bh=7NAyhkfQbcxTPtt6Wuep4buJLBzXp37MO61JEyiUHsU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=jVbA/nvADP0cj5hfiuCwC6TlLON6/t/yO31DIlKvYC1iFdH9LbvsxLk0sjAUDvqDG voTJWWNodHb86PVFPoavd1lCpIB0J7IMmdcHEsfShFogBolKJ1i8AbX8MAvxsJsgmI 3n6qC6Uhn5NllSe4LEWSJwdnlIsUiFGpyiTFOUsGnSDF/GpJUYMt5ZfyCW5p6ACa4s jBz7BYffQ4d7O4qC5bKvKEV8fey4j/onYserdl1kxQNlzAWwrfRH5h0HW6Ru6CEWhd hDLhNkwwuqd0e2rRonjmvZ4ACNbFK9rM+2nVRxadDRz5s55s3dAyMIrsaYYthhtK3L nePNsyWQz9rww== From: SeongJae Park To: Andrew Morton Cc: SeongJae Park , damon@lists.linux.dev, linux-kernel@vger.kernel.org, linux-mm@kvack.org Subject: [PATCH 01/11] mm/damon/core: introduce [in]active memory ratio damos quota goal metric Date: Tue, 13 Jan 2026 07:27:06 -0800 Message-ID: <20260113152717.70459-2-sj@kernel.org> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20260113152717.70459-1-sj@kernel.org> References: <20260113152717.70459-1-sj@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" DAMOS_LRU_[DE]PRIO are DAMOS actions for making balance of active and inactive memory size. There is no appropriate DAMOS quota auto-tuning target metric for the use case. Add two new DAMOS quota goal metrics for the purpose, namely DAMOS_QUOTA_[IN]ACTIVE_MEM_BP. Those will represent the ratio of [in]active memory to total (inactive + active) memory. Hence, users will be able to ask DAMON to, for example, "find hot and cold memory, and move pages of those to active and inactive LRU lists, adjusting the hot/cold thresholds aiming 50:50 active:inactive memory ratio." Signed-off-by: SeongJae Park --- include/linux/damon.h | 4 ++++ mm/damon/core.c | 22 ++++++++++++++++++++++ 2 files changed, 26 insertions(+) diff --git a/include/linux/damon.h b/include/linux/damon.h index 650e7ecfa32b..26fb8e90dff6 100644 --- a/include/linux/damon.h +++ b/include/linux/damon.h @@ -155,6 +155,8 @@ enum damos_action { * @DAMOS_QUOTA_NODE_MEM_FREE_BP: MemFree ratio of a node. * @DAMOS_QUOTA_NODE_MEMCG_USED_BP: MemUsed ratio of a node for a cgroup. * @DAMOS_QUOTA_NODE_MEMCG_FREE_BP: MemFree ratio of a node for a cgroup. + * @DAMOS_QUOTA_ACTIVE_MEM_BP: Active to total LRU memory ratio. + * @DAMOS_QUOTA_INACTIVE_MEM_BP: Inactive to total LRU memory ratio. * @NR_DAMOS_QUOTA_GOAL_METRICS: Number of DAMOS quota goal metrics. * * Metrics equal to larger than @NR_DAMOS_QUOTA_GOAL_METRICS are unsupport= ed. @@ -166,6 +168,8 @@ enum damos_quota_goal_metric { DAMOS_QUOTA_NODE_MEM_FREE_BP, DAMOS_QUOTA_NODE_MEMCG_USED_BP, DAMOS_QUOTA_NODE_MEMCG_FREE_BP, + DAMOS_QUOTA_ACTIVE_MEM_BP, + DAMOS_QUOTA_INACTIVE_MEM_BP, NR_DAMOS_QUOTA_GOAL_METRICS, }; =20 diff --git a/mm/damon/core.c b/mm/damon/core.c index abda850c28c0..d2ed75e521bd 100644 --- a/mm/damon/core.c +++ b/mm/damon/core.c @@ -2132,6 +2132,23 @@ static unsigned long damos_get_node_memcg_used_bp( } #endif =20 +/* + * Returns LRU-active or inactive memory to total LRU memory size ratio. + */ +static unsigned int damos_get_in_active_mem_bp(bool active_ratio) +{ + unsigned long active, inactive, total; + + /* This should align with /proc/meminfo output */ + active =3D global_node_page_state(NR_LRU_BASE + LRU_ACTIVE_ANON) + + global_node_page_state(NR_LRU_BASE + LRU_ACTIVE_FILE); + inactive =3D global_node_page_state(NR_LRU_BASE + LRU_INACTIVE_ANON) + + global_node_page_state(NR_LRU_BASE + LRU_INACTIVE_FILE); + total =3D active + inactive; + if (active_ratio) + return active * 10000 / total; + return inactive * 10000 / total; +} =20 static void damos_set_quota_goal_current_value(struct damos_quota_goal *go= al) { @@ -2154,6 +2171,11 @@ static void damos_set_quota_goal_current_value(struc= t damos_quota_goal *goal) case DAMOS_QUOTA_NODE_MEMCG_FREE_BP: goal->current_value =3D damos_get_node_memcg_used_bp(goal); break; + case DAMOS_QUOTA_ACTIVE_MEM_BP: + case DAMOS_QUOTA_INACTIVE_MEM_BP: + goal->current_value =3D damos_get_in_active_mem_bp( + goal->metric =3D=3D DAMOS_QUOTA_ACTIVE_MEM_BP); + break; default: break; } --=20 2.47.3 From nobody Sat Feb 7 11:31:12 2026 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E7043392B90; Tue, 13 Jan 2026 15:27:30 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1768318051; cv=none; b=t8YJroV8RFlS3hB9H72FIMQVzX0XhocAt9umcujDMFCLiL8DZrm3oYKCT1EN+04VmhUlNBupstjCzAosFxb55cW8OGEBXasJJhTMi8sgQTiCv6i+/9pmRyXvTM/sl2bc94GcZ9j/dQ00nS8EErMbHxeUqxXhiKE8AkTyZ6Jjy3w= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1768318051; c=relaxed/simple; bh=1yLzbYEUiETjkqkRJcB6Pqye8DL4YZB4qDv/HnOmOps=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=EJ6vK1e5mnpQQjNM/ggzs38IB8p0GC3exqe6+iKZWiJB8KYAsDm6cBkOKnRDu2Q1gvaL9ibfP6KSi8fq6unh6OCWFhKd4r7HThaLRNmT+lwI7pRIjBuDGIuJSz4yW8u1Payx/73bmzBZryXb+Bk0GLekq8uruT88n6zQA8WYcFY= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=RwOWgdQb; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="RwOWgdQb" Received: by smtp.kernel.org (Postfix) with ESMTPSA id A4D71C19422; Tue, 13 Jan 2026 15:27:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1768318050; bh=1yLzbYEUiETjkqkRJcB6Pqye8DL4YZB4qDv/HnOmOps=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=RwOWgdQbKo9fy3X4sYy5porDOpEkj5B8IZSuP7I1voJXWf0bUifkU7luWi7BAelAG EBp/NJl+5Neo2tfWcVA/cxrjFOsXWAZ2XMX8JbaOw+aolPfDPm3+eVoo+5FLjarI5S N3tnJOfb76yBcvBxTTZU4gpvsqsInowHNEsr/rPR5mXP2OFoODacz2H4r8Ps6qcsxS SfOrlcZ/rKvRNo5NVdcY5hWqkwz0s14IIoBg9Wm1EDUetYIucnzEJyqZqMWWSOHSL3 nngr2TF2IdrVx1b14UpB8ea1TUgkcUYzAqpnHXnhfxCt8m5ES4xFx7N2AUcUCFBoCM 88J7IWrf+VTnQ== From: SeongJae Park To: Andrew Morton Cc: SeongJae Park , damon@lists.linux.dev, linux-kernel@vger.kernel.org, linux-mm@kvack.org Subject: [PATCH 02/11] mm/damon/sysfs-schemes: support DAMOS_QUOTA_[IN]ACTIVE_MEM_BP Date: Tue, 13 Jan 2026 07:27:07 -0800 Message-ID: <20260113152717.70459-3-sj@kernel.org> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20260113152717.70459-1-sj@kernel.org> References: <20260113152717.70459-1-sj@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Add support of DAMOS_QUOTA_[IN]ACTIVE_MEM_BP on DAMON sysfs interface. Users can use [in]active_mem_bp keyword input to the target_metric sysfs file to use the new DAMOS quota auto-tune target metrics. Signed-off-by: SeongJae Park Acked-by: wang lian --- mm/damon/sysfs-schemes.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/mm/damon/sysfs-schemes.c b/mm/damon/sysfs-schemes.c index 419d6e7ee945..2b05a6477188 100644 --- a/mm/damon/sysfs-schemes.c +++ b/mm/damon/sysfs-schemes.c @@ -1079,6 +1079,14 @@ struct damos_sysfs_qgoal_metric_name damos_sysfs_qgo= al_metric_names[] =3D { .metric =3D DAMOS_QUOTA_NODE_MEMCG_FREE_BP, .name =3D "node_memcg_free_bp", }, + { + .metric =3D DAMOS_QUOTA_ACTIVE_MEM_BP, + .name =3D "active_mem_bp", + }, + { + .metric =3D DAMOS_QUOTA_INACTIVE_MEM_BP, + .name =3D "inactive_mem_bp", + }, }; =20 static ssize_t target_metric_show(struct kobject *kobj, --=20 2.47.3 From nobody Sat Feb 7 11:31:12 2026 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id AE068392C43; Tue, 13 Jan 2026 15:27:31 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1768318051; cv=none; b=Ja7EbLYrpkr9ij6nzZ8JK4YUQi08dOdI6T8F2QYfWrXzbnmTzBLNwcHp2km5ZfUCldKhOd445GqP90WVhEKLoj2+dXEFmmqlHH9cMSRIo1DG5xwuSlHcnduA/7L0kyCG9tlmRBuEwDicf+4VbIAKKP5rH75wXr6m6ByPCCwIVjI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1768318051; c=relaxed/simple; bh=PXBZmxIShUHTOj68WkS5j6Xr3CS96XOQ/oFi936N2Rk=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=e/QsTPeb5MVcjrD3OTth8Co63CGVOrkO6Q+cOioJ1+j/FgjAwWHy1JHf/W6mSOYIWEMSAqNgHN7fvkAsrOJGTkYSGoyl8IAqVYTq/CCuooQZO/ODZXw25HxJDfSkofzw454idieIwEWthYJqzYaIAbb9yvUm8l5vBaKsPI8wqZU= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=VXmaPVkG; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="VXmaPVkG" Received: by smtp.kernel.org (Postfix) with ESMTPSA id E992CC19424; Tue, 13 Jan 2026 15:27:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1768318051; bh=PXBZmxIShUHTOj68WkS5j6Xr3CS96XOQ/oFi936N2Rk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=VXmaPVkGiyyRuTCvCnLqVaThvQ3h+a38mIaYB+PZFZhn4IN/Cn60g6ooaw7JH5I2V cGzQEFzxre6EdaYJ5uLKTVM3rhM2cPexg1CduyuSQERI0g7VL5auvOcPErCcgx92Hk ySNH3Xod/O0xh4WWbzvdc+uwm9XXsX7hpeH3PJ8QnXZ38JL+hLr/k1qd1tnJ9AAXrS uT/E2mPhJMOKx33qEG2A3G8wmNGQKkEBWFhNbJI4xy4ybABdAORyBFTuAb2yNLUzBO YQdRuKS6YytGN+NiRpCmOwQSdNvZLgHJX8NnfrIlUfPEdogwGz8pg3N6MUeJI1T0Xb 6YTEI9pUCLKvg== From: SeongJae Park To: Andrew Morton Cc: SeongJae Park , "Liam R. Howlett" , David Hildenbrand , Jonathan Corbet , Lorenzo Stoakes , Michal Hocko , Mike Rapoport , Suren Baghdasaryan , Vlastimil Babka , damon@lists.linux.dev, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org Subject: [PATCH 03/11] Docs/mm/damon/design: document DAMOS_QUOTA_[IN]ACTIVE_MEM_BP Date: Tue, 13 Jan 2026 07:27:08 -0800 Message-ID: <20260113152717.70459-4-sj@kernel.org> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20260113152717.70459-1-sj@kernel.org> References: <20260113152717.70459-1-sj@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Update design document for newly added DAMOS_QUOTA_[IN]ACTIVE_MEM_BP metrics. Note that API document is automatically updated by kernel-doc comment, and the usage document points to the design document which uses keywords same to that for sysfs inputs. Hence updating only design document is sufficient. Signed-off-by: SeongJae Park Acked-by: wang lian --- Documentation/mm/damon/design.rst | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Documentation/mm/damon/design.rst b/Documentation/mm/damon/des= ign.rst index 7fd819b8bbf7..0cfd4c25e92d 100644 --- a/Documentation/mm/damon/design.rst +++ b/Documentation/mm/damon/design.rst @@ -585,6 +585,10 @@ mechanism tries to make ``current_value`` of ``target_= metric`` be same to specific NUMA node, in bp (1/10,000). - ``node_memcg_free_bp``: Specific cgroup's node unused memory ratio for a specific NUMA node, in bp (1/10,000). +- ``active_mem_bp``: Active to active + inactive (LRU) memory size ratio i= n bp + (1/10,000). +- ``inactive_mem_bp``: Inactive to active + inactive (LRU) memory size rat= io in + bp (1/10,000). =20 ``nid`` is optionally required for only ``node_mem_used_bp``, ``node_mem_free_bp``, ``node_memcg_used_bp`` and ``node_memcg_free_bp`` to --=20 2.47.3 From nobody Sat Feb 7 11:31:12 2026 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C48E2392C47; Tue, 13 Jan 2026 15:27:31 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1768318051; cv=none; b=uTfQjJWTVeBvDuB3E9yuCahb3XmPA3nwAzOWbk6tVLfaniHDR+5D6K6wyGIUyK6HAYsMei6gIDArEzupZ8qnF87Er5Y2RqmbemUNKIjQ3M/Rk84U4vxup48lLZPaojNlmu0DMKps+KX3PwzJZgnJtNiJ6LWqxXFIAVAVeRAFxMM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1768318051; c=relaxed/simple; bh=F7+1XG5LjId9vgDKAd+pvaqjxO2poIILsvjkJM5g+64=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=W8gXF/XVyvhl1tUz9Xkv5L/eyFdfAFJep/4Y7r712gaOo2mifxhtc3eo7s8zBRzWc2z1iK4QTNGkX1I7kMyoGIzeP4/SCjF6JcG1eBUnNg/S2MoYhp7xydNPlL3S/6tyDmwaY5XqngVwn9BdZR1hFc+tDnDAd44aQ24sxSjT+Zg= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=LYeyIAc0; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="LYeyIAc0" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 812C2C116C6; Tue, 13 Jan 2026 15:27:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1768318051; bh=F7+1XG5LjId9vgDKAd+pvaqjxO2poIILsvjkJM5g+64=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=LYeyIAc0DPPpy3z1Rl+8ig1Nyu0ySouQKyf6phjuEuB3RGheVTYUKbsvTHuTPDbmz 8aXf2v1J9bYSbGQyX3xR/g3cZIr4+ecuI3pAVK9JB2E19hYEVwytMRHmT7jadC4lZh le0SJ31b3yfaNdvUhND+LOseKXPoiSYG29BonPklsL78TldIy1YGleHzemv41TvCmq I/7Z1bcyf+tggipDawjvytAsszupZBKu6jrTedzFAub5n97J8xrc1h8M6ZM5ex7GT5 jI0Y8b709XpJCHtIalPaY18mdwJV1D4wSjkN77ZSd7DXKwYePkiYAO14j9X2d0LiT4 BXWifBme6kvGg== From: SeongJae Park To: Andrew Morton Cc: SeongJae Park , damon@lists.linux.dev, linux-kernel@vger.kernel.org, linux-mm@kvack.org Subject: [PATCH 04/11] mm/damon/paddr: activate DAMOS_LRU_PRIO targets instead of marking accessed Date: Tue, 13 Jan 2026 07:27:09 -0800 Message-ID: <20260113152717.70459-5-sj@kernel.org> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20260113152717.70459-1-sj@kernel.org> References: <20260113152717.70459-1-sj@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" DAMOS_LRU_DEPRIOD directly deactivates the pages, while DAMOS_LRU_PRIO calls folio_mark_accessed(), which does incremental activation. The incremental activation was assumed to be useful for making sure the pages of the hot memory region are really hot. After the introduction of DAMOS_LRU_PRIO, the young page filter has added. Users can use the young page filter to make sure the page is eligible to be activated. Meanwhile, the asymmetric behavior of DAMOS_LRU_[DE]PRIO can confuse users. Directly activate given pages for DAMOS_LRU_PRIO, to eliminate the unnecessary incremental activation steps, and be symmetric with DAMOS_LRU_DEPRIO for easier usages. Signed-off-by: SeongJae Park --- mm/damon/paddr.c | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/mm/damon/paddr.c b/mm/damon/paddr.c index 7d887a3c0866..4c2c935d82d6 100644 --- a/mm/damon/paddr.c +++ b/mm/damon/paddr.c @@ -206,9 +206,9 @@ static unsigned long damon_pa_pageout(struct damon_regi= on *r, return damon_pa_core_addr(applied * PAGE_SIZE, addr_unit); } =20 -static inline unsigned long damon_pa_mark_accessed_or_deactivate( +static inline unsigned long damon_pa_de_activate( struct damon_region *r, unsigned long addr_unit, - struct damos *s, bool mark_accessed, + struct damos *s, bool activate, unsigned long *sz_filter_passed) { phys_addr_t addr, applied =3D 0; @@ -227,8 +227,8 @@ static inline unsigned long damon_pa_mark_accessed_or_d= eactivate( else *sz_filter_passed +=3D folio_size(folio) / addr_unit; =20 - if (mark_accessed) - folio_mark_accessed(folio); + if (activate) + folio_activate(folio); else folio_deactivate(folio); applied +=3D folio_nr_pages(folio); @@ -240,20 +240,18 @@ static inline unsigned long damon_pa_mark_accessed_or= _deactivate( return damon_pa_core_addr(applied * PAGE_SIZE, addr_unit); } =20 -static unsigned long damon_pa_mark_accessed(struct damon_region *r, +static unsigned long damon_pa_activate_pages(struct damon_region *r, unsigned long addr_unit, struct damos *s, unsigned long *sz_filter_passed) { - return damon_pa_mark_accessed_or_deactivate(r, addr_unit, s, true, - sz_filter_passed); + return damon_pa_de_activate(r, addr_unit, s, true, sz_filter_passed); } =20 static unsigned long damon_pa_deactivate_pages(struct damon_region *r, unsigned long addr_unit, struct damos *s, unsigned long *sz_filter_passed) { - return damon_pa_mark_accessed_or_deactivate(r, addr_unit, s, false, - sz_filter_passed); + return damon_pa_de_activate(r, addr_unit, s, false, sz_filter_passed); } =20 static unsigned long damon_pa_migrate(struct damon_region *r, @@ -327,7 +325,7 @@ static unsigned long damon_pa_apply_scheme(struct damon= _ctx *ctx, case DAMOS_PAGEOUT: return damon_pa_pageout(r, aunit, scheme, sz_filter_passed); case DAMOS_LRU_PRIO: - return damon_pa_mark_accessed(r, aunit, scheme, + return damon_pa_activate_pages(r, aunit, scheme, sz_filter_passed); case DAMOS_LRU_DEPRIO: return damon_pa_deactivate_pages(r, aunit, scheme, --=20 2.47.3 From nobody Sat Feb 7 11:31:12 2026 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 073FB392C54; Tue, 13 Jan 2026 15:27:31 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1768318052; cv=none; b=susgRxgW00og74hjVkYmUHA4QDMua9Yu/eGNSG38YaphEUTgLX5LRna/HKJ+M+36Jsjy/5LkqPS4Hgu7eF6+lpLf/0scy7C1DpzyJPg933IuPGEeGdedFtg5cE6FHHtapRO043k04kp7Rt4xDRmYl0T3QYQEqC0x8vL4CkVjN1o= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1768318052; c=relaxed/simple; bh=u9BpClkZFdNL3P8/T2nVybp/XhQM1COhsP+bLP+TFE4=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=txziZMoNfLBU2KMOEeVMtUsxnsbqamQTT1FHVSEJ62L4PUqWcyqKJdta820MCcXEGHMxJGlLxH054ZZhB+nwuuS9mI7nzG54p10kSpM2qDPYZ5nL9hYm0z/2Pd1w9kNPo/82EZqmBIPq0ryZvYSlfWpnhKfU4zOe2i9oFWiA0Y4= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=TQwLD6Yq; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="TQwLD6Yq" Received: by smtp.kernel.org (Postfix) with ESMTPSA id C3778C2BC87; Tue, 13 Jan 2026 15:27:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1768318051; bh=u9BpClkZFdNL3P8/T2nVybp/XhQM1COhsP+bLP+TFE4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=TQwLD6YquT6NgnNQ84Kx8u7TWgMhbpMmt3X9fEodCwRYUsC9TaiBlzVw/KmPmmtNw 1uII382sK4yne5J+fP75WQWpKjrs847Il9tU6TVwhj3ZkqWDU6trZ9l3kTyh6RFVZq vbbSqe4dEk1gvxU4hzdxMa+eAzna3Z1H6u97Y4GII2PQoTkUBtfPxzGq485BQxg5v6 Ega6oOwSY7lWyVFPh42UnaMj5FH8ZKnGua+4N/yiHbsxP8nVfQoHX5COyAAUeQOpr7 +F6Wa14h2HHNqnQ6QnbYITbui3f1pqJa3v/SGtfPe8MpJL6zoDbGhlWgv9IwAqNkFZ SGvlIBXdiA08Q== From: SeongJae Park To: Andrew Morton Cc: SeongJae Park , damon@lists.linux.dev, linux-kernel@vger.kernel.org, linux-mm@kvack.org Subject: [PATCH 05/11] mm/damon/lru_sort: consider age for quota prioritization Date: Tue, 13 Jan 2026 07:27:10 -0800 Message-ID: <20260113152717.70459-6-sj@kernel.org> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20260113152717.70459-1-sj@kernel.org> References: <20260113152717.70459-1-sj@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" DAMON_LRU_SORT is doing under-quota access pattern based regions prioritization using only access frequency. Age of regions is another useful information for distinguishing hot and cold regions. Use it for prioritization, too. Signed-off-by: SeongJae Park --- mm/damon/lru_sort.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mm/damon/lru_sort.c b/mm/damon/lru_sort.c index 9388b091deb7..a74c4ec170a9 100644 --- a/mm/damon/lru_sort.c +++ b/mm/damon/lru_sort.c @@ -71,7 +71,7 @@ static struct damos_quota damon_lru_sort_quota =3D { /* Within the quota, mark hotter regions accessed first. */ .weight_sz =3D 0, .weight_nr_accesses =3D 1, - .weight_age =3D 0, + .weight_age =3D 1, }; DEFINE_DAMON_MODULES_DAMOS_TIME_QUOTA(damon_lru_sort_quota); =20 --=20 2.47.3 From nobody Sat Feb 7 11:31:12 2026 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 6A7E83933E8; Tue, 13 Jan 2026 15:27:32 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1768318052; cv=none; b=M9UDKSYLUnj8+bHNd1ktXXmhKqiEvYox0SohSMtR+z8QfukzmGb2+EH5KOhKiM/PLbQKepEmKHhSRc0I0B7ETnn6wbi8dHK0Lo0UCVd8wg6PhM0djuZO2dsHfCEC1nNrZ2/KOVUESEPoQvp0OTvCsfHYqqRZ30wv4FPFQQoQgfU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1768318052; c=relaxed/simple; bh=Ps1Llk1zn7k8iBguPu+c50Hh6cMt1or4lC99Uh+5urc=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=fsfkawldBJHWcBfMKqhDWFuA7R8qKse7VxjE/3xIFjh7ax46/LN4OXUndJ+PJ0Y3bKdVA/huHsxDmqpFwhAUopdmEvMf2I61s99J6d47NfQFfHsAx1X4B0d1A4If+wASFI90rPk9M2tLwboEm3curVNhRiiIbnKoyOWk5/3wNn0= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=Zk2ebu7+; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="Zk2ebu7+" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 01167C19422; Tue, 13 Jan 2026 15:27:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1768318052; bh=Ps1Llk1zn7k8iBguPu+c50Hh6cMt1or4lC99Uh+5urc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Zk2ebu7+GAxnV8yJ3e1uSgG0okFBS2+bpqblZ/XsSuXKo3ZOACswlTS/P2AgCE88i Tf8A1g6E1f6j0068Nqhxmr/AJhZSGngoDXYG5DI4eO92dx/edIzFSnx1UzF2uE9HCb oEyIqtftImRHgSNsTgu8n8aOFkNCiBz4oKrSDTROyi05aPZJanwziQTd/8JkjyVdTf 45gWlqMgZCyL3BCLM0Z1VIqHHh+UFyhONN+y5f5hQK/iGQAk+ImdvyL7ab0QcCAHUo WkRbzVUVrQYxD5Eea8XTJA0Ax+faZMBn5uVkBI1uUiLHCbAy2JfGE3axG5voYRLye9 YxnOY/FivKOHQ== From: SeongJae Park To: Andrew Morton Cc: SeongJae Park , damon@lists.linux.dev, linux-kernel@vger.kernel.org, linux-mm@kvack.org Subject: [PATCH 06/11] mm/damon/lru_sort: support young page filters Date: Tue, 13 Jan 2026 07:27:11 -0800 Message-ID: <20260113152717.70459-7-sj@kernel.org> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20260113152717.70459-1-sj@kernel.org> References: <20260113152717.70459-1-sj@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" DAMON monitors access patterns at the region level, and hence there could be some page level mismatches. A few hot pages could be located in cold regions, and vice versa. Young page filters can be useful for doing additional page level access checks before applying some DAMOS action. DAMON_LRU_SORT is not using young page filters, though. Add a parameter for using it. Signed-off-by: SeongJae Park --- mm/damon/lru_sort.c | 41 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) diff --git a/mm/damon/lru_sort.c b/mm/damon/lru_sort.c index a74c4ec170a9..f1fdb37b9b47 100644 --- a/mm/damon/lru_sort.c +++ b/mm/damon/lru_sort.c @@ -41,6 +41,21 @@ static bool enabled __read_mostly; static bool commit_inputs __read_mostly; module_param(commit_inputs, bool, 0600); =20 +/* + * Filter [non-]young pages accordingly for LRU [de]prioritizations. + * + * If this is set, check page level access (youngness) once again before e= ach + * LRU [de]prioritization operation. LRU prioritization operation is skip= ped + * if the page has not accessed since the last check (not young). LRU + * deprioritization operation is skipped if the page has accessed since the + * last check (young). The feature is enabled or disabled if this paramet= er is + * set as ``Y`` or ``N``, respectively. + * + * Disabled by default. + */ +static bool filter_young_pages __read_mostly; +module_param(filter_young_pages, bool, 0600); + /* * Access frequency threshold for hot memory regions identification in per= mil. * @@ -193,6 +208,28 @@ static struct damos *damon_lru_sort_new_cold_scheme(un= signed int cold_thres) return damon_lru_sort_new_scheme(&pattern, DAMOS_LRU_DEPRIO); } =20 +static int damon_lru_sort_add_filters(struct damos *hot_scheme, + struct damos *cold_scheme) +{ + struct damos_filter *filter; + + if (!filter_young_pages) + return 0; + + /* disallow prioritizing not-young pages */ + filter =3D damos_new_filter(DAMOS_FILTER_TYPE_YOUNG, false, false); + if (!filter) + return -ENOMEM; + damos_add_filter(hot_scheme, filter); + + /* disabllow de-prioritizing young pages */ + filter =3D damos_new_filter(DAMOS_FILTER_TYPE_YOUNG, true, false); + if (!filter) + return -ENOMEM; + damos_add_filter(cold_scheme, filter); + return 0; +} + static int damon_lru_sort_apply_parameters(void) { struct damon_ctx *param_ctx; @@ -240,6 +277,10 @@ static int damon_lru_sort_apply_parameters(void) damon_set_schemes(param_ctx, &hot_scheme, 1); damon_add_scheme(param_ctx, cold_scheme); =20 + err =3D damon_lru_sort_add_filters(hot_scheme, cold_scheme); + if (err) + goto out; + err =3D damon_set_region_biggest_system_ram_default(param_target, &monitor_region_start, &monitor_region_end, --=20 2.47.3 From nobody Sat Feb 7 11:31:12 2026 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E5524393405; Tue, 13 Jan 2026 15:27:32 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1768318053; cv=none; b=Q1CgOCNwNgQ3I5IXAXb2a//oSx4SQzAeHJzpmIpD0PJ5bte2wZoU2wJxVFuvp8Kwhs9KSmPnbfAfHgWqX7n/llJ6k19ssSlPjtskuV78ufYbkiIc8FvVxVXNJLU/1AFCykZM7wH66yP1R31Lqpuqq3ttonN10lloNTzc1X4IxLQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1768318053; c=relaxed/simple; bh=Wj0dAUEbE3nyWuMQ+51OFmWg9i5unPK4WiDRQNYOALc=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=VZuZ5AQ/tYgjf7CWrMU3EpN3+de0ZJdbBkihgYFz9XOgNCwXlHJSgoNa5dvCJhlHUuV605Tsbx2SYBKIighppjUhMqbw7Cwd5X9JJVPK4A6XsdgVY/f1nl84X+vpEo5hX0htoIRUxhm8IFJa+Kg4l+PE+DzFiC6B56WNj/1KXos= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=YdqTQfw5; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="YdqTQfw5" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 6E7F4C19424; Tue, 13 Jan 2026 15:27:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1768318052; bh=Wj0dAUEbE3nyWuMQ+51OFmWg9i5unPK4WiDRQNYOALc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=YdqTQfw59TQTrYZHgAP3pNMp/sMoVB6t0t/t+feeT8iON9eWWmQIdgg9tB4lzdMrt 0EFRTszgUKharMpOUI3taS5WRcGSpXt1bY2zvJRXQ/rF2Inbs0fmu7eS7d6mw0qkR3 oe6TR5PrLMjWmPf/jdlQtN8JHPe3lg0zvHTmjJcanyYXRvMtdAVZQFBSqgNY0S2YQ7 3tVZNFOvrpHLBt6jqs13jRVygx0mAe+PUQ4NfIDoPXrOvZXuMJ8y5iXDxBx5fneGZE bMmlhbq4KVYlz3z0t67O8NmMOC3dWaubERxRXMRav6j2BTIkG7Fwdu7dMdxeyKBsrt Q3NXYeY3Vj1zQ== From: SeongJae Park To: Andrew Morton Cc: SeongJae Park , "Liam R. Howlett" , David Hildenbrand , Jonathan Corbet , Lorenzo Stoakes , Michal Hocko , Mike Rapoport , Suren Baghdasaryan , Vlastimil Babka , damon@lists.linux.dev, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org Subject: [PATCH 07/11] Docs/admin-guide/mm/damon/lru_sort: document filter_young_pages Date: Tue, 13 Jan 2026 07:27:12 -0800 Message-ID: <20260113152717.70459-8-sj@kernel.org> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20260113152717.70459-1-sj@kernel.org> References: <20260113152717.70459-1-sj@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Document the new DAMON_LRU_SORT parameter, filter_young_pages. It can be used to use page level access re-check for the LRU sorting. Signed-off-by: SeongJae Park Acked-by: wang lian --- Documentation/admin-guide/mm/damon/lru_sort.rst | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/Documentation/admin-guide/mm/damon/lru_sort.rst b/Documentatio= n/admin-guide/mm/damon/lru_sort.rst index 72a943202676..bb222a32aefd 100644 --- a/Documentation/admin-guide/mm/damon/lru_sort.rst +++ b/Documentation/admin-guide/mm/damon/lru_sort.rst @@ -79,6 +79,20 @@ of parametrs except ``enabled`` again. Once the re-read= ing is done, this parameter is set as ``N``. If invalid parameters are found while the re-reading, DAMON_LRU_SORT will be disabled. =20 +filter_young_pages +------------------ + +Filter [non-]young pages accordingly for LRU [de]prioritizations. + +If this is set, check page level access (youngness) once again before each +LRU [de]prioritization operation. LRU prioritization operation is skipped +if the page has not accessed since the last check (not young). LRU +deprioritization operation is skipped if the page has accessed since the +last check (young). The feature is enabled or disabled if this parameter = is +set as ``Y`` or ``N``, respectively. + +Disabled by default. + hot_thres_access_freq --------------------- =20 --=20 2.47.3 From nobody Sat Feb 7 11:31:12 2026 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 2ECEF393412; Tue, 13 Jan 2026 15:27:33 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1768318053; cv=none; b=lc1HoJ9y7molrsMsUFdZFnGwANnqniYk0K8YWiHjJlKf53lsZiWVkVqV5DFCKDDlnxVRAZRiE/GfZ0hLUc2b/iTONMpuHq3GJBn8LP1mpvpeoZpfnFoNn0cpLAQEtsBmFNHkHWSz9XaJ8URydeT4UFHGiOfmd9/ChK/Eru4YV8M= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1768318053; c=relaxed/simple; bh=pLryvh98ed6XxIPENni66cywNufL7GDRDX92gXVXv0M=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=OxNlqFfAoHOfXFVHFYn7THB4MrqZxCicdHsf/rbIP0dYtzefamKdJkDe75FqyyNUHy/wpzhWqCAZKTgSJNDsskaAp5ual1FHE5C3ekP04hfDkD/Ul5aoTnLzIuGyUX+mr438A54ylLPBGTjcPKmQuE+Qeh3h9avxbVXqHQmbw9I= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=MbPlCZKp; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="MbPlCZKp" Received: by smtp.kernel.org (Postfix) with ESMTPSA id E5994C2BC86; Tue, 13 Jan 2026 15:27:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1768318053; bh=pLryvh98ed6XxIPENni66cywNufL7GDRDX92gXVXv0M=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=MbPlCZKpIa9lOj8AUJONXGdiS2aKBOANl+x8LvCD7wN/3tBH/k1xZ21qPaPOTgd1/ JQ6KtXiAKUbQtF/268czWsrcAIKAMqWUEOd5YMI2HaveSZkVKBOQEKI+R1GrfEDrOz L9n/QK7uEmuy03W2+7Yc3lG1HjtzKD4RXxfhSMaZjkbSkEpyWBPz1fvlvNNGboeBOi KRemgqA15qfU3IjPJtr2AHIP1eAYyb6+R0Nh7yCUD+2ZKh7wqUawGcv3Oyj4LlEVx8 joZHlZo2O1H5B+yqoalAjodSq8qbWo/UHo06cHVY0PCsirMjc3k6J3nb/xY/Htz9Cz Tx/bOa4/5q2ZA== From: SeongJae Park To: Andrew Morton Cc: SeongJae Park , damon@lists.linux.dev, linux-kernel@vger.kernel.org, linux-mm@kvack.org Subject: [PATCH 08/11] mm/damon/lru_sort: support active:inactive memory ratio based auto-tuning Date: Tue, 13 Jan 2026 07:27:13 -0800 Message-ID: <20260113152717.70459-9-sj@kernel.org> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20260113152717.70459-1-sj@kernel.org> References: <20260113152717.70459-1-sj@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Doing DAMOS_LRU_[DE]PRIO with DAMOS_QUOTA_[IN]ACTIVE_MEM_BP based quota auto-tuning can be easy and intuitive, compared to the manual [de]prioritization target access pattern thresholds tuning. For example, users can ask DAMON to "find hot/cold pages and activate/deactivate those aiming 50:50 active:inactive memory size." But DAMON_LRU_SORT has no interface to do that. Add a module parameter for setting the target ratio. Signed-off-by: SeongJae Park --- mm/damon/lru_sort.c | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/mm/damon/lru_sort.c b/mm/damon/lru_sort.c index f1fdb37b9b47..f3a9dfc246b6 100644 --- a/mm/damon/lru_sort.c +++ b/mm/damon/lru_sort.c @@ -41,6 +41,20 @@ static bool enabled __read_mostly; static bool commit_inputs __read_mostly; module_param(commit_inputs, bool, 0600); =20 +/* + * Desired active to [in]active memory ratio in bp (1/10,000). + * + * While keeping the caps that set by other quotas, DAMON_LRU_SORT + * automatically increases and decreases the effective level of the quota + * aiming the LRU [de]prioritizations of the hot and cold memory resulting= in + * this active to [in]active memory ratio. Value zero means disabling this + * auto-tuning feature. + * + * Disabled by default. + */ +static unsigned long active_mem_bp __read_mostly; +module_param(active_mem_bp, ulong, 0600); + /* * Filter [non-]young pages accordingly for LRU [de]prioritizations. * @@ -208,6 +222,26 @@ static struct damos *damon_lru_sort_new_cold_scheme(un= signed int cold_thres) return damon_lru_sort_new_scheme(&pattern, DAMOS_LRU_DEPRIO); } =20 +static int damon_lru_sort_add_quota_goals(struct damos *hot_scheme, + struct damos *cold_scheme) +{ + struct damos_quota_goal *goal; + + if (!active_mem_bp) + return 0; + goal =3D damos_new_quota_goal(DAMOS_QUOTA_ACTIVE_MEM_BP, active_mem_bp); + if (!goal) + return -ENOMEM; + damos_add_quota_goal(&hot_scheme->quota, goal); + /* aim 0.2 % goal conflict, to keep little ping pong */ + goal =3D damos_new_quota_goal(DAMOS_QUOTA_INACTIVE_MEM_BP, + 10000 - active_mem_bp + 2); + if (!goal) + return -ENOMEM; + damos_add_quota_goal(&hot_scheme->quota, goal); + return 0; +} + static int damon_lru_sort_add_filters(struct damos *hot_scheme, struct damos *cold_scheme) { @@ -277,6 +311,9 @@ static int damon_lru_sort_apply_parameters(void) damon_set_schemes(param_ctx, &hot_scheme, 1); damon_add_scheme(param_ctx, cold_scheme); =20 + err =3D damon_lru_sort_add_quota_goals(hot_scheme, cold_scheme); + if (err) + goto out; err =3D damon_lru_sort_add_filters(hot_scheme, cold_scheme); if (err) goto out; --=20 2.47.3 From nobody Sat Feb 7 11:31:12 2026 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 938D6392B89; Tue, 13 Jan 2026 15:27:33 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1768318053; cv=none; b=JQH7mK5uyWBguYrrL08SuMZbllW2/Cxbo5x4hvS7qH4q8lVoWKCKWAWU164xNmLsJDeJVNBSxuAMAeszzyLnI/bN0/j+w5+kbQO8W+KFIKbEnwFCBiVJb0J0sXQMtoq8MO49YniUjBRK+3DKQvgLiErVvJAc7qdC307sguNHqTc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1768318053; c=relaxed/simple; bh=pT8rCC+C0SK1J6+L6zG1LeeNo37asvsmk7EOOOw2HLA=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=jTd+1R+taUVyoX/aB03XTR8aevpO5+LaAnol6+/ic6I2L3yag0hYijYkifnt6xhJboCbU+U/PNLgUu+G1beailEOfa+mqGeg7dRoJrp3s4i+oXJxj4RkwtxjZSX+9+yjMPC25YHK9T0IuJsVLSF0weDOIAxo9s4tDqTwVwnngDo= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=BgsY/EKw; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="BgsY/EKw" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 2FC40C2BCB0; Tue, 13 Jan 2026 15:27:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1768318053; bh=pT8rCC+C0SK1J6+L6zG1LeeNo37asvsmk7EOOOw2HLA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=BgsY/EKwjt7qmaf3qUOIY0hmGSbVVt9OdvhnNXzeZBijHgaHf+WDh02E8rNvP8rIP V3HOJo0D8Hs9EEIn7xVw0Y3TRmn4+kGO7tHhaAjSRb74C3aeTu4usHqNeJCwdOuF0z Ky7/AWiVPrn39Y0jFkiavTeqCs5g4Np4bo+q4zonH1+f59pPCT6u1W9mzHleoMW6Pm kPqKlx5hmYPopCVxstoGHsTxXOFg3eSSxWiodmJddCzbxBrtwsMcfphrBK8x/wRbCS QeA6GmB6r7CYyRyfARgcqihrh6ZyprF7pZiN9g8l00FIjjlXgtRC/SY0WC/3yvQAU3 7VigYfNXpZqVg== From: SeongJae Park To: Andrew Morton Cc: SeongJae Park , "Liam R. Howlett" , David Hildenbrand , Jonathan Corbet , Lorenzo Stoakes , Michal Hocko , Mike Rapoport , Suren Baghdasaryan , Vlastimil Babka , damon@lists.linux.dev, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org Subject: [PATCH 09/11] Docs/admin-guide/mm/damon/lru_sort: document active_mem_bp parameter Date: Tue, 13 Jan 2026 07:27:14 -0800 Message-ID: <20260113152717.70459-10-sj@kernel.org> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20260113152717.70459-1-sj@kernel.org> References: <20260113152717.70459-1-sj@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Document a newly added DAMON_LRU_SORT parameter for doing auto-tuning aiming an active to inactive memory size ratio. Signed-off-by: SeongJae Park Acked-by: wang lian --- Documentation/admin-guide/mm/damon/lru_sort.rst | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/Documentation/admin-guide/mm/damon/lru_sort.rst b/Documentatio= n/admin-guide/mm/damon/lru_sort.rst index bb222a32aefd..6af3ab5579a3 100644 --- a/Documentation/admin-guide/mm/damon/lru_sort.rst +++ b/Documentation/admin-guide/mm/damon/lru_sort.rst @@ -79,6 +79,18 @@ of parametrs except ``enabled`` again. Once the re-read= ing is done, this parameter is set as ``N``. If invalid parameters are found while the re-reading, DAMON_LRU_SORT will be disabled. =20 +active_mem_bp +------------- + +Desired active to [in]active memory ratio in bp (1/10,000). + +While keeping the caps that set by other quotas, DAMON_LRU_SORT automatica= lly +increases and decreases the effective level of the quota aiming the LRU +[de]prioritizations of the hot and cold memory resulting in this active to +[in]active memory ratio. Value zero means disabling this auto-tuning feat= ure. + +Disabled by default. + filter_young_pages ------------------ =20 --=20 2.47.3 From nobody Sat Feb 7 11:31:12 2026 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id F24D43939AF; Tue, 13 Jan 2026 15:27:33 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1768318054; cv=none; b=NBftNOoIFwkwPxDcuFbP4XyPVdp+U+LQD7HeyGkE+xVtS1Aj2+baoO+DChdzOrtwKSBSDcvbg5Dc+wefXy0WR6wQJjmrSx6GP6dce28cLYUBLWEM4jL5UKADmBqoLZj6up/qCtejPniHztzgBrlB+WuSTSWylPmzo/YNl5UdNc0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1768318054; c=relaxed/simple; bh=f3S6xDzMYwBAJsmHW3zullLbXTgyY6fprlw1+nJamAA=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=DMpcxzjW+C/UvXL2KlftxTClNp9H5ZnEGXnMMVd6t9vTgGawKHvA6s8OvmYuB4hxastimcgwbXjXn/l3Gy7vCJqN17v0YdFqzP0IqBmqoNY4L11kYr/YvP65xOD8Bdm3h6MaQOIl9HXk2M7W6BTKATGurN5CA2GayVl3qDvUHdQ= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=BU7j9M+T; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="BU7j9M+T" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 963CBC19424; Tue, 13 Jan 2026 15:27:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1768318053; bh=f3S6xDzMYwBAJsmHW3zullLbXTgyY6fprlw1+nJamAA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=BU7j9M+T12Pl2/6y/ThZgQsOBqc2tov7ik5qihZ+zekXx4nv/okg1SjeyuMJKE8ct UrrJK6PnCIRHTrzVLUx8eLaLQqYzPFlZRzqi0VP+0oPaXA6dcPAmoxzpwVvDUxRPc3 ZYkXjvDj37yDuO31Wj5O2XtCX47hiyIIh1/NIfE3vQz5BlKMHaafY/I/y3p6NdQFaZ nwnwNdhHh5cJ4WyEhhHDDu8V0GHAqm0sj4jzdyThuvafKvoZpu214Q3E+edJaqqcGL uqbxEceh/bVlsT6G7KOQYkYBBJQUXcIRGQ2nwvCDZqV64YiKPprYbLvO+nN6mdeN9B PU1b4lvH3tbVQ== From: SeongJae Park To: Andrew Morton Cc: SeongJae Park , damon@lists.linux.dev, linux-kernel@vger.kernel.org, linux-mm@kvack.org Subject: [PATCH 10/11] mm/damon/lru_sort: add monitoring intervals auto-tuning parameter Date: Tue, 13 Jan 2026 07:27:15 -0800 Message-ID: <20260113152717.70459-11-sj@kernel.org> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20260113152717.70459-1-sj@kernel.org> References: <20260113152717.70459-1-sj@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" DAMON monitoring intervals tuning was crucial for every DAMON use case. Now there are a tuning guideline and an automated intervals tuning feature. DAMON_LRU_SORT is still using manual control of intervals. Add a module parameter for utilizing the auto-tuning feature with a suggested auto-tuning parameters. Signed-off-by: SeongJae Park Acked-by: wang lian --- mm/damon/lru_sort.c | 30 +++++++++++++++++++++++++++--- 1 file changed, 27 insertions(+), 3 deletions(-) diff --git a/mm/damon/lru_sort.c b/mm/damon/lru_sort.c index f3a9dfc246b6..717cc585d207 100644 --- a/mm/damon/lru_sort.c +++ b/mm/damon/lru_sort.c @@ -55,6 +55,20 @@ module_param(commit_inputs, bool, 0600); static unsigned long active_mem_bp __read_mostly; module_param(active_mem_bp, ulong, 0600); =20 +/* + * Auto-tune monitoring intervals. + * + * If this parameter is set as ``Y``, DAMON_LRU_SORT automatically tunes + * DAMON's sampling and aggregation intervals. The auto-tuning aims to ca= pture + * meaningful amount of access events in each DAMON-snapshot, while keepin= g the + * sampling interval 5 milliseconds in minimum, and 10 seconds in maximum. + * Setting this as ``N`` disables the auto-tuning. + * + * Disabled by default. + */ +static bool autotune_monitoring_intervals __read_mostly; +module_param(autotune_monitoring_intervals, bool, 0600); + /* * Filter [non-]young pages accordingly for LRU [de]prioritizations. * @@ -268,6 +282,7 @@ static int damon_lru_sort_apply_parameters(void) { struct damon_ctx *param_ctx; struct damon_target *param_target; + struct damon_attrs attrs; struct damos *hot_scheme, *cold_scheme; unsigned int hot_thres, cold_thres; int err; @@ -290,18 +305,27 @@ static int damon_lru_sort_apply_parameters(void) goto out; } =20 - err =3D damon_set_attrs(param_ctx, &damon_lru_sort_mon_attrs); + attrs =3D damon_lru_sort_mon_attrs; + if (autotune_monitoring_intervals) { + attrs.sample_interval =3D 5000; + attrs.aggr_interval =3D 100000; + attrs.intervals_goal.access_bp =3D 40; + attrs.intervals_goal.aggrs =3D 3; + attrs.intervals_goal.min_sample_us =3D 5000; + attrs.intervals_goal.max_sample_us =3D 10 * 1000 * 1000; + } + err =3D damon_set_attrs(param_ctx, &attrs); if (err) goto out; =20 err =3D -ENOMEM; - hot_thres =3D damon_max_nr_accesses(&damon_lru_sort_mon_attrs) * + hot_thres =3D damon_max_nr_accesses(&attrs) * hot_thres_access_freq / 1000; hot_scheme =3D damon_lru_sort_new_hot_scheme(hot_thres); if (!hot_scheme) goto out; =20 - cold_thres =3D cold_min_age / damon_lru_sort_mon_attrs.aggr_interval; + cold_thres =3D cold_min_age / attrs.aggr_interval; cold_scheme =3D damon_lru_sort_new_cold_scheme(cold_thres); if (!cold_scheme) { damon_destroy_scheme(hot_scheme); --=20 2.47.3 From nobody Sat Feb 7 11:31:12 2026 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 2B401392C46; Tue, 13 Jan 2026 15:27:34 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1768318056; cv=none; b=FtlywKKzb8aPGWj3lxsBsNHZdSAEHrKT23Mxl1aXAtQajlM1fDafgs89JESwsdBUHf04mXY0TcXuq0Mbxww6Zg/y8qWCESTkjuMXxjbtQ21uArpVPolfKTM+DgcONo5DfpV6Tve90x28fYiz1Rr18RtHwg95ZjbHqa0GT1xhCiM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1768318056; c=relaxed/simple; bh=ZmJrAkMA9Irtz6OhLBZFE9S6wzn9oxN2fIfGy091mqs=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=IntY2JYnrj7DA/uguqwns/SCZdcKn7LXO1pVjt/rHycmGchLwwqFaJoJK4V3eTrz/bdbqTcTbpxHYALaUg030w6D7Bz2JpYcvUoZhu1ytjhRB0WBdiUS6UTStGFjmiZ5Rkn//dI8XZoKxJCKcUNAqCgM6IQw65JXvl/jJ+Fwlo0= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=QbKz/WvZ; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="QbKz/WvZ" Received: by smtp.kernel.org (Postfix) with ESMTPSA id C97C6C19421; Tue, 13 Jan 2026 15:27:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1768318054; bh=ZmJrAkMA9Irtz6OhLBZFE9S6wzn9oxN2fIfGy091mqs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=QbKz/WvZSBUAf7ErFfDMyIrvtRdGi7BE8mJZkAoVw+9dngIBXggRh0/SXNXLO0k5j 0y05XEwmUbLtA0ZMkjsp1RJ3840rkwwpZmnzxnCv9PnMkWzdR2LyQIrxGuhgdbQV5e hdOyvmKV/84XqF0TwTVJflLYzgJp5feHdBlmkqoGxfGCTvbd6S5BjYgh1cPWBQRnWC pscrF2vTCU/q+j2+xq3tib+MHqM3uygZTYqB8lsiM0Xx1b9o7VEgDjp1dxyhEPO6cP gIJtE7TZb31/2wsfsA1rp4zOwLOabR45EF4qSEtFqorzu38cLfJ5De1HPsDYpLp6jq TLPrD4cR7us2A== From: SeongJae Park To: Andrew Morton Cc: SeongJae Park , "Liam R. Howlett" , David Hildenbrand , Jonathan Corbet , Lorenzo Stoakes , Michal Hocko , Mike Rapoport , Suren Baghdasaryan , Vlastimil Babka , damon@lists.linux.dev, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org Subject: [PATCH 11/11] Docs/admin-guide/mm/damon/lru_sort: document intervals autotuning Date: Tue, 13 Jan 2026 07:27:16 -0800 Message-ID: <20260113152717.70459-12-sj@kernel.org> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20260113152717.70459-1-sj@kernel.org> References: <20260113152717.70459-1-sj@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Document a newly added DAMON_LRU_SORT module parameter for using monitoring intervals auto-tuning feature of DAMON. Signed-off-by: SeongJae Park Acked-by: wang lian --- Documentation/admin-guide/mm/damon/lru_sort.rst | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/Documentation/admin-guide/mm/damon/lru_sort.rst b/Documentatio= n/admin-guide/mm/damon/lru_sort.rst index 6af3ab5579a3..20a8378d5a94 100644 --- a/Documentation/admin-guide/mm/damon/lru_sort.rst +++ b/Documentation/admin-guide/mm/damon/lru_sort.rst @@ -91,6 +91,17 @@ increases and decreases the effective level of the quota= aiming the LRU =20 Disabled by default. =20 +Auto-tune monitoring intervals +------------------------------ + +If this parameter is set as ``Y``, DAMON_LRU_SORT automatically tunes DAMO= N's +sampling and aggregation intervals. The auto-tuning aims to capture meani= ngful +amount of access events in each DAMON-snapshot, while keeping the sampling +interval 5 milliseconds in minimum, and 10 seconds in maximum. Setting th= is as +``N`` disables the auto-tuning. + +Disabled by default. + filter_young_pages ------------------ =20 --=20 2.47.3