From nobody Tue Dec 2 00:46:09 2025 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 D54AF19E819; Sun, 23 Nov 2025 18:43:44 +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=1763923424; cv=none; b=H0WFvb27olRyjk8Op7eRaCZMTcIyJVAZ4z4Ri+vg5UJ6JzNettcRbr1prcY5YgmV/OJzgQAZsIh66yswRdIkP0avchFK2OPTbUooSOzFWPKyKBAkFDIfRw+N+AycQQ18osKDzkIbAc/V6zH4RasKciNautgy5MJ7NFSHkX+pAJM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763923424; c=relaxed/simple; bh=DsxYSEC5PojLKtzUcVWfJP4PrbIxS3wEgw82HduLlh0=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=A1evB/q0/f1hM4/ncAY19J9MYeg/5khAopRGxYchB0WrcTgkTQwDRirmajlX84cZ4UY8ywasL+LjVcrYsUdYQX06BdbkwqwfdRHX4guxd9YTWHwEmqfd5pDC4np54od0VD42Wix0I1ELUU0Ovmwe03JTsRjkrTlTBJ+9H8zhRSM= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=IU6+gD7Y; 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="IU6+gD7Y" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 5A3AAC116B1; Sun, 23 Nov 2025 18:43:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1763923424; bh=DsxYSEC5PojLKtzUcVWfJP4PrbIxS3wEgw82HduLlh0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=IU6+gD7YXQfcvijugVPLPyX91rd/tCz+0r9sjh8I9R0rZ+PIg3vvv5UW0t2YJuiS9 xX0l74rBA+UnNVi1rjLP70NC+TaHrLQUDTLEdglLywJTIHOwthI9hJSpCC5NrUTJKj QWFKDeo6HjSAiZ1QFcUaW1kaRnNfCQlZeP+30MABLps4JvO9+ULktFV2ytU8XHMYkA /dLQy5xWgP/68YR8t0ofedEixkTwUMRxMlkYJCOTF1hyezxgF7A7krZP/fhX9fDjv1 AsEK31T0s9bCKuiBKxqj3o8PzTWpc/xG0WXnYWSqensu/GPF7bLNm7YnUulzwFepuO ucx7eZmvYpf+A== From: SeongJae Park To: Cc: SeongJae Park , Andrew Morton , damon@lists.linux.dev, linux-kernel@vger.kernel.org, linux-mm@kvack.org Subject: [RFC PATCH 01/12] mm/damon/core: introduce nr_snapshots damos stat Date: Sun, 23 Nov 2025 10:43:15 -0800 Message-ID: <20251123184329.85287-2-sj@kernel.org> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20251123184329.85287-1-sj@kernel.org> References: <20251123184329.85287-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 generates monitoring results snapshots for every sampling interval. DAMOS applies given schemes on the regions of the snapshots, for every apply interval of the scheme. DAMOS stat informs a given scheme has tried to how many memory entities and applied, in the region and byte level. In some use cases including user-space oriented tuning and investigations, it is useful to know that in the DAMON-snapshot level. Introduce a new stat, namely nr_snapshots for DAMON core API callers. Signed-off-by: SeongJae Park --- include/linux/damon.h | 3 +++ mm/damon/core.c | 13 ++++++++++--- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/include/linux/damon.h b/include/linux/damon.h index 3813373a9200..1d8a1515e75a 100644 --- a/include/linux/damon.h +++ b/include/linux/damon.h @@ -330,6 +330,8 @@ struct damos_watermarks { * @sz_ops_filter_passed: * Total bytes that passed ops layer-handled DAMOS filters. * @qt_exceeds: Total number of times the quota of the scheme has exceeded. + * @nr_snapshots: + * Total number of DAMON snapshots that the scheme has tried. * * "Tried an action to a region" in this context means the DAMOS core logic * determined the region as eligible to apply the action. The access patt= ern @@ -355,6 +357,7 @@ struct damos_stat { unsigned long sz_applied; unsigned long sz_ops_filter_passed; unsigned long qt_exceeds; + unsigned long nr_snapshots; }; =20 /** diff --git a/mm/damon/core.c b/mm/damon/core.c index f9fc0375890a..af922d5e500c 100644 --- a/mm/damon/core.c +++ b/mm/damon/core.c @@ -157,6 +157,12 @@ void damon_destroy_region(struct damon_region *r, stru= ct damon_target *t) damon_free_region(r); } =20 +static bool damon_is_last_region(struct damon_region *r, + struct damon_target *t) +{ + return list_is_last(&t->regions_list, &r->list); +} + /* * Check whether a region is intersecting an address range * @@ -1949,10 +1955,11 @@ static void damon_do_apply_schemes(struct damon_ctx= *c, if (damos_skip_charged_region(t, &r, s, c->min_sz_region)) continue; =20 - if (!damos_valid_target(c, t, r, s)) - continue; + if (damos_valid_target(c, t, r, s)) + damos_apply_scheme(c, t, r, s); =20 - damos_apply_scheme(c, t, r, s); + if (damon_is_last_region(r, t)) + s->stat.nr_snapshots++; } } =20 --=20 2.47.3 From nobody Tue Dec 2 00:46:09 2025 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 D900E2D7804; Sun, 23 Nov 2025 18:43:44 +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=1763923424; cv=none; b=ShxeTs1AAD1T751GFpvMtajAUnRXkYWe72ClRlq2Gfzng9MrbjOOA1zVn3acU4VwDQsd5AAZ8fgpWmCm5o6NjPyZ26jEy8p/XXV7jBDRr2VJ18SUqG9A6a73gUr8H4FuGzhJ0cGzD3zEQ9g+e/8LeKwlvMru7Ag0l+d7QLILOuk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763923424; c=relaxed/simple; bh=flHCn1jzwJYbHp6Nyj2GAUs2tIfp0Jhpc5MXnsDhPc8=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=fHR2aGJVknlfyZlZtbQaDM7918meyEtItecg2h2wS1cTWNOACK1MI450Msk1DmPHEvWv/29kZes94/xV7i3xBG0qhxpRP+IfZNAom9YB7nGV4RijKlBZcAE2SY1pS/SqqZa8gTGeVd/xUwtHvpIe7iB7lCDmFjXgZ70REPgkGmI= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=EWcxawcm; 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="EWcxawcm" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 98571C19422; Sun, 23 Nov 2025 18:43:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1763923424; bh=flHCn1jzwJYbHp6Nyj2GAUs2tIfp0Jhpc5MXnsDhPc8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=EWcxawcm3Wldt4q2Fk+N/iVtuR2wUJd4gie6Gwzx0wakwV72c2gYTNBoOY9FUhvXQ 8Mu3ZswD/pPPtgFMiCsEH9649+sKKLO7GguUAVZVLV8828LgjhI91u5ySL9IgQyySv llMTWbih/na/Q/hlRpkYmE+dDbe4GVxyb+XSuqEcLWadebqsTtsheGIYeCGoeDXUrD 5hOpw9cBW7yESLVi2uxKTcCrE6zcpSYNDxkAsAU1JEvZyR1jVhy2NNLJd6dsD0Mqwt dTEzcxzfhflNWP0FX1+XDXN6OW86t9yIVdoO6naM+m5ZzIQOImWSxpVKopwt/ifhv9 fPynkYljdoN3g== From: SeongJae Park To: Cc: SeongJae Park , Andrew Morton , damon@lists.linux.dev, linux-kernel@vger.kernel.org, linux-mm@kvack.org Subject: [RFC PATCH 02/12] mm/damon/sysfs-schemes: introduce nr_snapshots damos stat file Date: Sun, 23 Nov 2025 10:43:16 -0800 Message-ID: <20251123184329.85287-3-sj@kernel.org> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20251123184329.85287-1-sj@kernel.org> References: <20251123184329.85287-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" Introduce a new DAMON sysfs interface file for exposing the newly added DAMOS stat, nr_snapshots. The file has the name same to the stat name (nr_snapshots) and placed under the damos stat sysfs directory. Signed-off-by: SeongJae Park --- mm/damon/sysfs-schemes.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/mm/damon/sysfs-schemes.c b/mm/damon/sysfs-schemes.c index 30d20f5b3192..4d25469f957f 100644 --- a/mm/damon/sysfs-schemes.c +++ b/mm/damon/sysfs-schemes.c @@ -204,6 +204,7 @@ struct damon_sysfs_stats { unsigned long sz_applied; unsigned long sz_ops_filter_passed; unsigned long qt_exceeds; + unsigned long nr_snapshots; }; =20 static struct damon_sysfs_stats *damon_sysfs_stats_alloc(void) @@ -265,6 +266,15 @@ static ssize_t qt_exceeds_show(struct kobject *kobj, return sysfs_emit(buf, "%lu\n", stats->qt_exceeds); } =20 +static ssize_t nr_snapshots_show(struct kobject *kobj, + struct kobj_attribute *attr, char *buf) +{ + struct damon_sysfs_stats *stats =3D container_of(kobj, + struct damon_sysfs_stats, kobj); + + return sysfs_emit(buf, "%lu\n", stats->nr_snapshots); +} + static void damon_sysfs_stats_release(struct kobject *kobj) { kfree(container_of(kobj, struct damon_sysfs_stats, kobj)); @@ -288,6 +298,9 @@ static struct kobj_attribute damon_sysfs_stats_sz_ops_f= ilter_passed_attr =3D static struct kobj_attribute damon_sysfs_stats_qt_exceeds_attr =3D __ATTR_RO_MODE(qt_exceeds, 0400); =20 +static struct kobj_attribute damon_sysfs_stats_nr_snapshots_attr =3D + __ATTR_RO_MODE(nr_snapshots, 0400); + static struct attribute *damon_sysfs_stats_attrs[] =3D { &damon_sysfs_stats_nr_tried_attr.attr, &damon_sysfs_stats_sz_tried_attr.attr, @@ -295,6 +308,7 @@ static struct attribute *damon_sysfs_stats_attrs[] =3D { &damon_sysfs_stats_sz_applied_attr.attr, &damon_sysfs_stats_sz_ops_filter_passed_attr.attr, &damon_sysfs_stats_qt_exceeds_attr.attr, + &damon_sysfs_stats_nr_snapshots_attr.attr, NULL, }; ATTRIBUTE_GROUPS(damon_sysfs_stats); @@ -2761,6 +2775,7 @@ void damon_sysfs_schemes_update_stats( sysfs_stats->sz_ops_filter_passed =3D scheme->stat.sz_ops_filter_passed; sysfs_stats->qt_exceeds =3D scheme->stat.qt_exceeds; + sysfs_stats->nr_snapshots =3D scheme->stat.nr_snapshots; } } =20 --=20 2.47.3 From nobody Tue Dec 2 00:46:09 2025 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 9BF4A2DC320; Sun, 23 Nov 2025 18:43:45 +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=1763923425; cv=none; b=KJmFdcqgLSNOpi7zobqJNlHl7tvQlTtztyB+omerU/R9ZekrBo6jKahxgPgVCyGwLgrZjPRkBi8fEVa902LCBr2spT0XQe85tTEks1DAYbVyLggi3Nn+h3mApuqbgKmHRuWlmwS+xM56Fgkq+E9CpabvhAFZZH29gfqMlgkq+ow= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763923425; c=relaxed/simple; bh=vPTC/eKfLkll500maYdRrQDlL8kK86gyaCZ9jL7BWDM=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=ifXs8W3+wyGB1c9rFt/8dK/knMAFO2zHTUlQvfWNRLLUy/VlauxlMF/9tOMrsvPMsQaZWOJkXz1zdIgAzWY0Sji8DggXJ4Iey2XvkY482CuhjSNoQnF+sZW+cYPoJ703DbATIWWeeTdNbASdBst9ZnjqTtqff0jt2uboNHdT6YU= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=HR3R4cUb; 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="HR3R4cUb" Received: by smtp.kernel.org (Postfix) with ESMTPSA id D6E96C19423; Sun, 23 Nov 2025 18:43:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1763923425; bh=vPTC/eKfLkll500maYdRrQDlL8kK86gyaCZ9jL7BWDM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=HR3R4cUbNLbqybOvOYXzWLHXNxghlfQSspgN2RSov7tFY3h3ydIypBfGfHpCLCDan BwObokJtrIAbpDkOYRJFcS3647LBAJo251CSuQlPJ4vGxyOWNSdqetvDp29u1W8n21 2kzWyb5F0DjMPOz7ARkx+zG5taQlFN7qpD0SmAVIzJ1ptNJJKLGKYlt6FAkX0O3aq2 0sZEC0PsOqPXe5nSdplFJF/D03+uh7F+3BrcVvF/F6Zq+QBa43YqoG8QZyGoBaXySu yifZRO9RXWvt9RlApJcwNya65xh6c85RyVnYEHI1XfSAyFnVLnN0rY8FWTjyNxVWCS 1UkyHpR/Z4vRg== From: SeongJae Park To: Cc: SeongJae Park , "Liam R. Howlett" , Andrew Morton , 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: [RFC PATCH 03/12] Docs/mm/damon/design: update for nr_snapshots damos stat Date: Sun, 23 Nov 2025 10:43:17 -0800 Message-ID: <20251123184329.85287-4-sj@kernel.org> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20251123184329.85287-1-sj@kernel.org> References: <20251123184329.85287-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 DAMON design document for the newly added damos stat, nr_snapshots. Signed-off-by: SeongJae Park --- Documentation/mm/damon/design.rst | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Documentation/mm/damon/design.rst b/Documentation/mm/damon/des= ign.rst index 2d8d8ca1e0a3..5cc7b7d662be 100644 --- a/Documentation/mm/damon/design.rst +++ b/Documentation/mm/damon/design.rst @@ -718,6 +718,8 @@ scheme's execution. - ``nr_applied``: Total number of regions that the scheme is applied. - ``sz_applied``: Total size of regions that the scheme is applied. - ``qt_exceeds``: Total number of times the quota of the scheme has exceed= ed. +- ``nr_snapshots``: Total number of DAMON snapshots that the scheme is tri= ed to + be applied. =20 "A scheme is tried to be applied to a region" means DAMOS core logic deter= mined the region is eligible to apply the scheme's :ref:`action --=20 2.47.3 From nobody Tue Dec 2 00:46:09 2025 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 5031B2DC79D; Sun, 23 Nov 2025 18:43:45 +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=1763923426; cv=none; b=LyZfEzbnha67yCNWwFxL7UuiZWrxCH9vNS+hdxQFDzUHHBWPwgSP8blSrVvEa71TKZcJvR3Mlx7fxDNKK5NN+fqx+IKadyK72sQopAgNXdeKaVSa3V5wm4L/+EkiFEiVUgTkuc7KJg8m2HZmlmIgGnk6lpM2VOvG80hpOUzb25M= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763923426; c=relaxed/simple; bh=MfosQBkwjx3KXwTbjhH363GcqS+Z5CKxnOYfPNTR2Lk=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=IHeIDdom5g3znqh/Ivj4dnzY3UjW6KpIiRtTWxIXDyvSwsmAJY870MLsi8nXk2UClrKb0ZtR5sdcgY6zELQBrpThj3v7AWh33dwQE+JrPR+WJ3mZkCERsQzwF4C9PrqkNHPv6Vmu0rBD7tetasarD6sG9WqupmfDCgKggi/sv94= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=Vzf43v1m; 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="Vzf43v1m" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 5C4F3C19421; Sun, 23 Nov 2025 18:43:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1763923425; bh=MfosQBkwjx3KXwTbjhH363GcqS+Z5CKxnOYfPNTR2Lk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Vzf43v1mBUX0UuIUB6lejQV22KhuCioTa+XZkyrKmUxCAN3RZshlIJT9eO2uUeQMA XqbsH7XvIM4FDKqiQb8EmZU4/45WF/aDNo50DOt39X1JwG0bVqy35aXDseaEjByKPT EjUhpd5bJl550PaXpzGmv1eEflrLI30GID4TjFRkYGYF18EfnJs+o1GjflLK9dTqM0 qHdu7ZRZK70H+XkAdAd1j/eT0nvTAWujdJsMb1vJjl1DzQ+hX+lVdN/+Q6XihPPlro n50GfeGpiSUyBZcm7oK65jo1DcyKxBxM/c2pLurqJg6uLeqseqavg04wNlOKBjy3O+ AU94l7kBCINvg== From: SeongJae Park To: Cc: SeongJae Park , "Liam R. Howlett" , Andrew Morton , 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: [RFC PATCH 04/12] Docs/admin-guide/mm/damon/usage: update for nr_snapshots damos stat Date: Sun, 23 Nov 2025 10:43:18 -0800 Message-ID: <20251123184329.85287-5-sj@kernel.org> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20251123184329.85287-1-sj@kernel.org> References: <20251123184329.85287-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-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Update DAMON usage document for the newly added damos stat, nr_snapshots. Signed-off-by: SeongJae Park --- Documentation/admin-guide/mm/damon/usage.rst | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Documentation/admin-guide/mm/damon/usage.rst b/Documentation/a= dmin-guide/mm/damon/usage.rst index 9991dad60fcf..d0944bd78964 100644 --- a/Documentation/admin-guide/mm/damon/usage.rst +++ b/Documentation/admin-guide/mm/damon/usage.rst @@ -87,7 +87,7 @@ comma (","). =E2=94=82 =E2=94=82 =E2=94=82 =E2=94=82 =E2=94=82 =E2=94=82 =E2=94=82 = =E2=94=82 0/type,matching,allow,memcg_path,addr_start,addr_end,target_idx,m= in,max =E2=94=82 =E2=94=82 =E2=94=82 =E2=94=82 =E2=94=82 =E2=94=82 =E2=94=82 = :ref:`dests `/nr_dests =E2=94=82 =E2=94=82 =E2=94=82 =E2=94=82 =E2=94=82 =E2=94=82 =E2=94=82 = =E2=94=82 0/id,weight - =E2=94=82 =E2=94=82 =E2=94=82 =E2=94=82 =E2=94=82 =E2=94=82 =E2=94=82 = :ref:`stats `/nr_tried,sz_tried,nr_applied,sz_applied,= sz_ops_filter_passed,qt_exceeds + =E2=94=82 =E2=94=82 =E2=94=82 =E2=94=82 =E2=94=82 =E2=94=82 =E2=94=82 = :ref:`stats `/nr_tried,sz_tried,nr_applied,sz_applied,= sz_ops_filter_passed,qt_exceeds,nr_snapshots =E2=94=82 =E2=94=82 =E2=94=82 =E2=94=82 =E2=94=82 =E2=94=82 =E2=94=82 = :ref:`tried_regions `/total_bytes =E2=94=82 =E2=94=82 =E2=94=82 =E2=94=82 =E2=94=82 =E2=94=82 =E2=94=82 = =E2=94=82 0/start,end,nr_accesses,age,sz_filter_passed =E2=94=82 =E2=94=82 =E2=94=82 =E2=94=82 =E2=94=82 =E2=94=82 =E2=94=82 = =E2=94=82 ... @@ -543,9 +543,9 @@ online analysis or tuning of the schemes. Refer to :re= f:`design doc =20 The statistics can be retrieved by reading the files under ``stats`` direc= tory (``nr_tried``, ``sz_tried``, ``nr_applied``, ``sz_applied``, -``sz_ops_filter_passed``, and ``qt_exceeds``), respectively. The files ar= e not -updated in real time, so you should ask DAMON sysfs interface to update the -content of the files for the stats by writing a special keyword, +``sz_ops_filter_passed``, ``qt_exceeds`` and ``nr_snapshots``), respective= ly. +The files are not updated in real time, so you should ask DAMON sysfs inte= rface +to update the content of the files for the stats by writing a special keyw= ord, ``update_schemes_stats`` to the relevant ``kdamonds//state`` file. =20 .. _sysfs_schemes_tried_regions: --=20 2.47.3 From nobody Tue Dec 2 00:46:09 2025 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 502A02DA765; Sun, 23 Nov 2025 18:43:46 +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=1763923426; cv=none; b=GwT26yUqwAPhajtaovtuFzwM5myxXAlrZPyJZOfZArezlS8HJEjrMojJhTXUyeHPiGbw+0yjNwp3vo0VhRPdkLi2ZN4PnyV9+nZBhUxGdOAIHU1E/PDhLPCu5kpAr3gPwvMgSOGXw5T04a+3ovS9WXvaTJAftROMS+a2Kk+x4Zs= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763923426; c=relaxed/simple; bh=kDwIvFb8VodbxVEv7dJbhD0yz/eOfjwBbqy33WSlBfo=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=H+OYa2wJUEXyjOWoF3KX6s/gN0gZZxC+0dTgY92gNUEnoLH/DtwSx2wyXLCS8fcSO7OT38bupZNd7PByuWTIsWcrzksvOm1ickocPewFzkcG5LyHiiDi62OHpPek8Pi6LS9F1ExawVStqqpGB9SskifrNR1J8oQHZHMZAymXBm4= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=BjvbOznx; 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="BjvbOznx" Received: by smtp.kernel.org (Postfix) with ESMTPSA id D23A2C19422; Sun, 23 Nov 2025 18:43:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1763923425; bh=kDwIvFb8VodbxVEv7dJbhD0yz/eOfjwBbqy33WSlBfo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=BjvbOznxo38hdVc7pIPFkgfrNu+WIMZYz0mAohaEy2nWJ54GQBMuSPhyqfb2lxsex lkg73PzpS8fc0nixCljxRLfc9hx3clm7eM6zTewVD9dQcDjqO0ACcoYZdcwwLJdlhI RCfMqWZ4BehSZ2m7P6kZPdSaSAp3n5NBu2HfqFwmTJDfOyzAZNH2FmZTWHHZixq4YW iNKkFu9BkypGWj5kYxFtkIFo1mp0yGF2Mng7CylilvjlpYnVM7FoW5yL1vvsOGKnu0 FjAoJPbFuA7fcCJPwT7OOpKlOxl7xfbFs3Cws77mIDVTRQ2d+nwlkKOmQegXW85Tk6 VMqGJd3WTjEVQ== From: SeongJae Park To: Cc: SeongJae Park , damon@lists.linux.dev, linux-kernel@vger.kernel.org, linux-mm@kvack.org Subject: [RFC PATCH 05/12] Docs/ABI/damon: update for nr_snapshots damos stat Date: Sun, 23 Nov 2025 10:43:19 -0800 Message-ID: <20251123184329.85287-6-sj@kernel.org> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20251123184329.85287-1-sj@kernel.org> References: <20251123184329.85287-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 DAMON ABI document for the newly added damos stat, nr_snapshots. Signed-off-by: SeongJae Park --- Documentation/ABI/testing/sysfs-kernel-mm-damon | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/Documentation/ABI/testing/sysfs-kernel-mm-damon b/Documentatio= n/ABI/testing/sysfs-kernel-mm-damon index 4fb8b7a6d625..8ec469eb4471 100644 --- a/Documentation/ABI/testing/sysfs-kernel-mm-damon +++ b/Documentation/ABI/testing/sysfs-kernel-mm-damon @@ -516,6 +516,12 @@ Contact: SeongJae Park Description: Reading this file returns the number of the exceed events of the scheme's quotas. =20 +What: /sys/kernel/mm/damon/admin/kdamonds//contexts//schemes//st= ats/nr_snapshots +Date: Nov 2025 +Contact: SeongJae Park +Description: Reading this file returns the total number of DAMON snapshots + that the scheme has tried to be applied. + What: /sys/kernel/mm/damon/admin/kdamonds//contexts//schemes//tr= ied_regions/total_bytes Date: Jul 2023 Contact: SeongJae Park --=20 2.47.3 From nobody Tue Dec 2 00:46:09 2025 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 F12972DEA80; Sun, 23 Nov 2025 18:43:46 +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=1763923427; cv=none; b=Bi/9NLcYYcJ/uNjBywN/klElv5Q8u139TfWI8Pe+0F6Fa6dgtjLgmcV/TnlzhfRhAN5ET94cFXGp1Oykn8OooV1O6ZeQZm44lRIAFqcBM3Qc6QH5sTvtuaS1Q6KuOzXtSnPj+77hXM3Q+wIfMJlo5pFIKq8bCxcllSR3aUPtzh8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763923427; c=relaxed/simple; bh=dyfJoVaMw2se3otvFoArpX9pnB7yY+god8b9Qd1MKC4=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=DtOj20pt8cKaSBhOiAAvVoK8hfYCFLyPIxOMgrSGtSDdr7zm8ouPAcafd6q2kZVgcUEzqsUms3TDqyh5Ina//gcCuE/dYFCApBVYZbD8jYxJJMcDOsq/vD6miqDMI7z0F3bvmRu+vJZrl6J4NO4zXFjZt+/dGtrg47OIFaRXKWo= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=CiKQJhBJ; 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="CiKQJhBJ" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 17735C19424; Sun, 23 Nov 2025 18:43:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1763923426; bh=dyfJoVaMw2se3otvFoArpX9pnB7yY+god8b9Qd1MKC4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=CiKQJhBJnI5WYFJRAhLILwwpHsC9nhrMXkusYL+OVgcRmrizUjeyJdmMOV37IwAon aCMGlTOGfdHzxBUSBbxFb3r0wSmZ5x1Zmt0tlKVzgvdnp+DaDOnVFhdMCFFL5isEXS fXm1K1xHzKBdq4Aqp4t1YqKrCxwwBlLA3YfHO7VmYgoztMUjTIylVBpo3BRrkQXMjM G7em5Y2hkq1DEKThsHpm+Dn/xjpUVhJtIe2AAFpeCl5+Unzojr76w80P11kbGtzYEZ wWgr/UxhM2nmamCpje4o5ECAj8yYufVlOmtAnCdeRkY/AaF/XjVN9/X4xiUNqeo72x +wPJIKCQY8YqQ== From: SeongJae Park To: Cc: SeongJae Park , damon@lists.linux.dev, linux-kernel@vger.kernel.org, linux-mm@kvack.org Subject: [RFC PATCH 06/12] mm/damon: update damos kerneldoc for stat field Date: Sun, 23 Nov 2025 10:43:20 -0800 Message-ID: <20251123184329.85287-7-sj@kernel.org> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20251123184329.85287-1-sj@kernel.org> References: <20251123184329.85287-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" Commit 0e92c2ee9f45 ("mm/damon/schemes: account scheme actions that successfully applied") has replaced ->stat_count and ->stat_sz of 'struct damos' with ->stat. The commit mistakenly did not update the related kernel doc comment, though. Update the comment. Signed-off-by: SeongJae Park --- include/linux/damon.h | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/include/linux/damon.h b/include/linux/damon.h index 1d8a1515e75a..43dfbfe2292f 100644 --- a/include/linux/damon.h +++ b/include/linux/damon.h @@ -532,9 +532,7 @@ struct damos_migrate_dests { * unsets @last_applied when each regions walking for applying the scheme = is * finished. * - * After applying the &action to each region, &stat_count and &stat_sz is - * updated to reflect the number of regions and total size of regions that= the - * &action is applied. + * After applying the &action to each region, &stat is updated. */ struct damos { struct damos_access_pattern pattern; --=20 2.47.3 From nobody Tue Dec 2 00:46:09 2025 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 9293C2DE6E3; Sun, 23 Nov 2025 18:43:46 +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=1763923426; cv=none; b=rkC/NzJ9+7WNSuLzubMOvWA0BPBeV7k8g/lR4aMg6oO3BbWcOGvVvLolgEwDAu6ia7t57R6MKrousbGtGDHVTaJu/kMTeFpmosMViA3NflQiVPSF4JCPZX8AfMZC6Xc/7v6XyyKSfjD/UveoC+a7KxMWKp+jW+i70RIh6X01BPo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763923426; c=relaxed/simple; bh=+PG482StoL/pY9Nmw7mtPv/d1GxHurtk722prWLmX44=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=doCiDwsZwBDZbN36f09n2JEwJHoKctrzk/ulGy4Ab2jamFS3YVKzjnmpXJng5wTfjTCHCm4kW3Q9CbG9ZnAzHwF9HsIWk2PUOyhMT07LFixC0+TQCHZSyKy/H+R0xxQ6EzKj0vNwJwRmdv5GYliauYqkkUHe/StLNG3Hq5sz6MI= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=nFbyDXWf; 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="nFbyDXWf" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 5155AC16AAE; Sun, 23 Nov 2025 18:43:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1763923426; bh=+PG482StoL/pY9Nmw7mtPv/d1GxHurtk722prWLmX44=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=nFbyDXWfQDCIBVZS6Wz1iiSWM8Bt7727WKNonqal+RCrAnXjIk6b9S+LnsPdqmXCc pQa8L1UxoNUY+2fgFLTPXswxycWOqPmQbJl+Atyd1HWi/ycJaB659b96vzV9R/bTeO kjBUJaXSDpE5F94qZWPxiVka8LJZUeBK1/y4rtVmKRsNw2NIxdgdU2hoZ3xqQypkJ6 LRDqKh75fYq2dZhIaIsK10Fhaos9L6Sz98Q1OS25PUU3D1qAAGR0nIAH8mRCwwEVXF 5EZmetyeh2Ix3Es4+cHqaEHCGWjaC44VHmxsstDIJtgBRpdlVxalq+WjTHgCTpYs2w T+1sF7hgMa42Q== From: SeongJae Park To: Cc: SeongJae Park , Andrew Morton , damon@lists.linux.dev, linux-kernel@vger.kernel.org, linux-mm@kvack.org Subject: [RFC PATCH 07/12] mm/damon/core: implement max_nr_snapshots Date: Sun, 23 Nov 2025 10:43:21 -0800 Message-ID: <20251123184329.85287-8-sj@kernel.org> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20251123184329.85287-1-sj@kernel.org> References: <20251123184329.85287-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" There are DAMOS use cases that require user-space centric control of its activation and deactivation. Having the control plane on the user-space, or using DAMOS as a way for monitoring results collection are such examples. DAMON parameters online commit, DAMOS quotas and watermarks can be useful for this purpose. However, those features work only at the sub-DAMON-snapshot level. In some use cases, the DAMON-snapshot level control is required. For example, in DAMOS-based monitoring results collection use case, the user online-installs a DAMOS scheme with DAMOS_STAT action, wait it be applied to whole regions of a single DAMON-snapshot, retrieves the stats and tried regions information, and online-uninstall the scheme. It is efficient to ensure the lifetime of the scheme as no more no less one snapshot consumption. To support such use cases, introduce a new DAMOS core API per-scheme parameter, namely max_nr_snapshots. As the name implies, it is the upper limit of nr_snapshots, which is a DAMOS stat that represents the number of DAMON-snapshots that the scheme has fully applied. If the limit is set with a non-zero value and nr_snapshots reaches or exceeds the limit, the scheme is deactivated. Signed-off-by: SeongJae Park --- include/linux/damon.h | 5 +++++ mm/damon/core.c | 11 ++++++++++- 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/include/linux/damon.h b/include/linux/damon.h index 43dfbfe2292f..a67292a2f09d 100644 --- a/include/linux/damon.h +++ b/include/linux/damon.h @@ -499,6 +499,7 @@ struct damos_migrate_dests { * @ops_filters: ops layer handling &struct damos_filter objects list. * @last_applied: Last @action applied ops-managing entity. * @stat: Statistics of this scheme. + * @max_nr_snapshots: Upper limit of nr_snapshots stat. * @list: List head for siblings. * * For each @apply_interval_us, DAMON finds regions which fit in the @@ -533,6 +534,9 @@ struct damos_migrate_dests { * finished. * * After applying the &action to each region, &stat is updated. + * + * If &max_nr_snapshots is set as non-zero and &stat.nr_snapshots be same = to or + * greater than it, the scheme is deactivated. */ struct damos { struct damos_access_pattern pattern; @@ -567,6 +571,7 @@ struct damos { struct list_head ops_filters; void *last_applied; struct damos_stat stat; + unsigned long max_nr_snapshots; struct list_head list; }; =20 diff --git a/mm/damon/core.c b/mm/damon/core.c index af922d5e500c..36313cd1ff1c 100644 --- a/mm/damon/core.c +++ b/mm/damon/core.c @@ -401,6 +401,7 @@ struct damos *damon_new_scheme(struct damos_access_patt= ern *pattern, INIT_LIST_HEAD(&scheme->core_filters); INIT_LIST_HEAD(&scheme->ops_filters); scheme->stat =3D (struct damos_stat){}; + scheme->max_nr_snapshots =3D 0; INIT_LIST_HEAD(&scheme->list); =20 scheme->quota =3D *(damos_quota_init(quota)); @@ -1078,7 +1079,11 @@ static int damos_commit(struct damos *dst, struct da= mos *src) return err; =20 err =3D damos_commit_filters(dst, src); - return err; + if (err) + return err; + + dst->max_nr_snapshots =3D src->max_nr_snapshots; + return 0; } =20 static int damon_commit_schemes(struct damon_ctx *dst, struct damon_ctx *s= rc) @@ -1955,6 +1960,10 @@ static void damon_do_apply_schemes(struct damon_ctx = *c, if (damos_skip_charged_region(t, &r, s, c->min_sz_region)) continue; =20 + if (s->max_nr_snapshots && + s->max_nr_snapshots <=3D s->stat.nr_snapshots) + continue; + if (damos_valid_target(c, t, r, s)) damos_apply_scheme(c, t, r, s); =20 --=20 2.47.3 From nobody Tue Dec 2 00:46:09 2025 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 D345C2DEA78; Sun, 23 Nov 2025 18:43:46 +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=1763923426; cv=none; b=m68hbQUss44Ca+kWVZtYDcU1tx9jOvfFQdnZqDWh/kYPN+rWnfulBS5YJ1q1p5M+I4C3eUCctRrKuZUR+5eAY3H4RGI8OA3sAAmF7Vl3vpLpvYnJeErF5gVv6pBM0g11LkvUK0v+TJJQEeEYodqJY03TjogG7rKS7ACxcyAiYEE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763923426; c=relaxed/simple; bh=awU53/r/mJ37dlq+2AaGq1embqTuZiSy+X46MMp0c/c=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=TJYGCvW4TtPeXhQ30BBFgDaQuLnSNN2WwpRcCtv53gXNYRxmG8voe4OQ0s06WWf6RPMS2i+LBUJc88OvSaJE6Hbcxv12lC4CNNkbRoA7OjgR4k6JuJqe6CeZmwFDpMV2MC88szbSbESw2ESZ7uWKd01ghG5j70OknbbUxCj33BU= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=m7HxFeCa; 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="m7HxFeCa" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 958BEC113D0; Sun, 23 Nov 2025 18:43:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1763923426; bh=awU53/r/mJ37dlq+2AaGq1embqTuZiSy+X46MMp0c/c=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=m7HxFeCaHrBTLlTWG8+buUOpiNnqvfr0i+qXOsXwg+vop3y7kwEJQ2OrS2h0If4kx LG/3OQGqYdfncWiqVsxIwLJ4NE2sse7JGbHCGI7ITXUuUA00gZa41WhGZXiicESW6N zwZumy7ARMNi9Qj3MCrGCtzb6Ol1vErJ61JfrW2cTiOVxeazUKkN91ulqhnWBFnB1R YHvVlbsP7Oy7//APJxss1XHJ6b/b3Wjr/uODztVxRbn1ZtT63Ikps0Naf8jK/UKgNM 6JStTtSwTRvU/oi+7ma4d4L6MgNHKctk13+N+z58m8EY0cu8iJbG0PubO+4aIIDUtC q+GOYSwrAPOhg== From: SeongJae Park To: Cc: SeongJae Park , Andrew Morton , damon@lists.linux.dev, linux-kernel@vger.kernel.org, linux-mm@kvack.org Subject: [RFC PATCH 08/12] mm/damon/sysfs-schemes: implement max_nr_snapshots file Date: Sun, 23 Nov 2025 10:43:22 -0800 Message-ID: <20251123184329.85287-9-sj@kernel.org> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20251123184329.85287-1-sj@kernel.org> References: <20251123184329.85287-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 a new DAMON sysfs file for setting and getting the newly introduced per-DAMON-snapshot level DAMOS deactivation control parameter, max_nr_snapshots. The file has a name same to the parameter and placed under the damos stat directory. Signed-off-by: SeongJae Park --- mm/damon/sysfs-schemes.c | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/mm/damon/sysfs-schemes.c b/mm/damon/sysfs-schemes.c index 4d25469f957f..bf1b637d4342 100644 --- a/mm/damon/sysfs-schemes.c +++ b/mm/damon/sysfs-schemes.c @@ -205,6 +205,7 @@ struct damon_sysfs_stats { unsigned long sz_ops_filter_passed; unsigned long qt_exceeds; unsigned long nr_snapshots; + unsigned long max_nr_snapshots; }; =20 static struct damon_sysfs_stats *damon_sysfs_stats_alloc(void) @@ -275,6 +276,28 @@ static ssize_t nr_snapshots_show(struct kobject *kobj, return sysfs_emit(buf, "%lu\n", stats->nr_snapshots); } =20 +static ssize_t max_nr_snapshots_show(struct kobject *kobj, + struct kobj_attribute *attr, char *buf) +{ + struct damon_sysfs_stats *stats =3D container_of(kobj, + struct damon_sysfs_stats, kobj); + + return sysfs_emit(buf, "%lu\n", stats->max_nr_snapshots); +} + +static ssize_t max_nr_snapshots_store(struct kobject *kobj, + struct kobj_attribute *attr, const char *buf, size_t count) +{ + struct damon_sysfs_stats *stats =3D container_of(kobj, + struct damon_sysfs_stats, kobj); + unsigned long max_nr_snapshots, err =3D kstrtoul(buf, 0, &max_nr_snapshot= s); + + if (err) + return err; + stats->max_nr_snapshots =3D max_nr_snapshots; + return count; +} + static void damon_sysfs_stats_release(struct kobject *kobj) { kfree(container_of(kobj, struct damon_sysfs_stats, kobj)); @@ -301,6 +324,9 @@ static struct kobj_attribute damon_sysfs_stats_qt_excee= ds_attr =3D static struct kobj_attribute damon_sysfs_stats_nr_snapshots_attr =3D __ATTR_RO_MODE(nr_snapshots, 0400); =20 +static struct kobj_attribute damon_sysfs_stats_max_nr_snapshots_attr =3D + __ATTR_RW_MODE(max_nr_snapshots, 0600); + static struct attribute *damon_sysfs_stats_attrs[] =3D { &damon_sysfs_stats_nr_tried_attr.attr, &damon_sysfs_stats_sz_tried_attr.attr, @@ -309,6 +335,7 @@ static struct attribute *damon_sysfs_stats_attrs[] =3D { &damon_sysfs_stats_sz_ops_filter_passed_attr.attr, &damon_sysfs_stats_qt_exceeds_attr.attr, &damon_sysfs_stats_nr_snapshots_attr.attr, + &damon_sysfs_stats_max_nr_snapshots_attr.attr, NULL, }; ATTRIBUTE_GROUPS(damon_sysfs_stats); @@ -2731,6 +2758,7 @@ static struct damos *damon_sysfs_mk_scheme( damon_destroy_scheme(scheme); return NULL; } + scheme->max_nr_snapshots =3D sysfs_scheme->stats->max_nr_snapshots; return scheme; } =20 --=20 2.47.3 From nobody Tue Dec 2 00:46:09 2025 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 720932DECC2; Sun, 23 Nov 2025 18:43:47 +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=1763923427; cv=none; b=dTni3FAEfG09Y+SLJWPE4XD8+hG0xmCePnbrJNFdl3rRahMaIwRSwsKHP6v79+0WIlf1SEWjQ8h5Vp5eQoDIjlrXx+C06ZwixvvEOZqOwkKHipf5qGuWEKFVGlpAEQOZLYtjOJl4gGnzygYJomxXHA3djvd/6dy4oAi7Ecyd+VE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763923427; c=relaxed/simple; bh=iXEcDN8E6cxYy3isQfAsdFaACSzfCgupWIVQKmv8ny4=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=fTWXQx0c1z+SfksDhtjV8vqWSyrgBBARQ8/H6GUdKCp6g7LJlMw5s5Y52l3Y6sbm+7/nwsBaVu6hTi8IBHeimbrGHeQNF1ZeFAvks7N+x+W1uSACD447Bood/SflvnRdyjGp8R275EpwLQMeUW9L/Zi847fCUOAoKO1a6Fo9Qok= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=GDRk/cn/; 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="GDRk/cn/" Received: by smtp.kernel.org (Postfix) with ESMTPSA id D61D8C19421; Sun, 23 Nov 2025 18:43:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1763923427; bh=iXEcDN8E6cxYy3isQfAsdFaACSzfCgupWIVQKmv8ny4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=GDRk/cn/AEJQHJM38Tao7V9q2kGxm1ykxzMdjMBo54eYpg72gExF2HFdDNUPwdHgN wI02Rr2O7iYuV8vOhM1K4McnURJ9R89ykquKUPEO1JWyiqqsqjt6YLiS6g/3J/pP9Y noY4ltkqc5TWabMoj9UQPRKkzjyBGw7E7qcioIccd0m+fEMymoonFze+t/Kn2HuCGK M6lVuwXRhmteHw8B1K+ueIjL5wgFBEQIXlcy9afA5pw+zefV+qYquw6bBovJ7ZN2LS 9NpJhnmd8SXc+mtaQEXW95AHxGqcrXYzQque2fZJXXbKrKEybK0rDGJ+pPKLHQUq3X VjFIbbEFgRUyg== From: SeongJae Park To: Cc: SeongJae Park , "Liam R. Howlett" , Andrew Morton , 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: [RFC PATCH 09/12] Docs/mm/damon/design: update for max_nr_snapshots Date: Sun, 23 Nov 2025 10:43:23 -0800 Message-ID: <20251123184329.85287-10-sj@kernel.org> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20251123184329.85287-1-sj@kernel.org> References: <20251123184329.85287-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 DAMON design document for the newly added snapshot level DAMOS deactivation feature, max_nr_snapshots. Signed-off-by: SeongJae Park --- Documentation/mm/damon/design.rst | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/Documentation/mm/damon/design.rst b/Documentation/mm/damon/des= ign.rst index 5cc7b7d662be..7fd819b8bbf7 100644 --- a/Documentation/mm/damon/design.rst +++ b/Documentation/mm/damon/design.rst @@ -720,6 +720,7 @@ scheme's execution. - ``qt_exceeds``: Total number of times the quota of the scheme has exceed= ed. - ``nr_snapshots``: Total number of DAMON snapshots that the scheme is tri= ed to be applied. +- ``max_nr_snapshots``: Upper limit of ``nr_snapshots``. =20 "A scheme is tried to be applied to a region" means DAMOS core logic deter= mined the region is eligible to apply the scheme's :ref:`action @@ -741,6 +742,10 @@ to exclude anonymous pages and the region has only ano= nymous pages, or if the action is ``pageout`` while all pages of the region are unreclaimable, app= lying the action to the region will fail. =20 +Unlike normal stats, ``max_nr_snapshots`` is set by users. If it is set as +non-zero and ``nr_snapshots`` be same to or greater than ``nr_snapshots``,= the +scheme is deactivated. + To know how user-space can read the stats via :ref:`DAMON sysfs interface `, refer to :ref:s`stats ` part of the documentation. --=20 2.47.3 From nobody Tue Dec 2 00:46:09 2025 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 4EB662DF134; Sun, 23 Nov 2025 18:43:48 +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=1763923428; cv=none; b=MGorp7mGHsvYav9EUTaA6IPh2GJrMeJd1wVMMBK6sPJnHbdd5sheSpOc+e3Hc76RTBGC0olGOiY9amp5R9fnSMwFyELAKX6uDAGobGA47xQkvNNQyf1CoatLTMwlVTS+QPhwrdHRfSVy0rdiUoaUSl5EZtwQyL3fUEF4xy5ss7o= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763923428; c=relaxed/simple; bh=ihzFy5TOJPnYv7zeqZ3FA4BsW8yTIpVlYGwomLZgsUk=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=HPqTjDPZ6Vd6XJx5whlUizTzy/f0IVMsjRq+rmZiVLCGFnBNLXZ6dmghieBIIIXaTRsqsMyQMvA/7sOowVxBjhlUrtYMhj0fwoYSz48zZyRjQAAuRDV734mJL6aHV/Z4UnAX5P3J69vjn/RsdB8l1WwZWBSv32oHH+YYKa90pcU= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=iiM7b3dV; 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="iiM7b3dV" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 571F6C113D0; Sun, 23 Nov 2025 18:43:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1763923427; bh=ihzFy5TOJPnYv7zeqZ3FA4BsW8yTIpVlYGwomLZgsUk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=iiM7b3dVNQ4X2OiyrZkf0LKuyuwDddtr10cyC02fxUSnJKk6aEKb0yrRfFh9PQHQ9 J165637B4tbSLIC4BlPYbwqLkm62A1Q2vuhmoKXxqi0favHEjmQyv5oiypoK1AsLC5 lq4hZZdFZUC9t6hTVHEC3fQPhak49Zylx2V05NvGw4Q28SGOTR/4wKjKshgWq5rLJR 6mx2lINXEmsh0AVIH/ulu6muPvzJRlSxS+N0PkvSNvXXxvkzAms0948oeBgls0AdSh unjZM2AGydYVFcS1GQCKFYDk1NDwOAm9B6IhSz/8dAWNWg0nOO8MjU7SQ7r7FhmoVJ g1LvJ8B+S016A== From: SeongJae Park To: Cc: SeongJae Park , "Liam R. Howlett" , Andrew Morton , 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: [RFC PATCH 10/12] Docs/admin-guide/mm/damon/usage: update for max_nr_snapshots Date: Sun, 23 Nov 2025 10:43:24 -0800 Message-ID: <20251123184329.85287-11-sj@kernel.org> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20251123184329.85287-1-sj@kernel.org> References: <20251123184329.85287-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-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Update DAMON usage document for the newly added DAMON sysfs interface file, max_nr_snapshots. Signed-off-by: SeongJae Park --- Documentation/admin-guide/mm/damon/usage.rst | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/Documentation/admin-guide/mm/damon/usage.rst b/Documentation/a= dmin-guide/mm/damon/usage.rst index d0944bd78964..7da4c002cb39 100644 --- a/Documentation/admin-guide/mm/damon/usage.rst +++ b/Documentation/admin-guide/mm/damon/usage.rst @@ -87,7 +87,7 @@ comma (","). =E2=94=82 =E2=94=82 =E2=94=82 =E2=94=82 =E2=94=82 =E2=94=82 =E2=94=82 = =E2=94=82 0/type,matching,allow,memcg_path,addr_start,addr_end,target_idx,m= in,max =E2=94=82 =E2=94=82 =E2=94=82 =E2=94=82 =E2=94=82 =E2=94=82 =E2=94=82 = :ref:`dests `/nr_dests =E2=94=82 =E2=94=82 =E2=94=82 =E2=94=82 =E2=94=82 =E2=94=82 =E2=94=82 = =E2=94=82 0/id,weight - =E2=94=82 =E2=94=82 =E2=94=82 =E2=94=82 =E2=94=82 =E2=94=82 =E2=94=82 = :ref:`stats `/nr_tried,sz_tried,nr_applied,sz_applied,= sz_ops_filter_passed,qt_exceeds,nr_snapshots + =E2=94=82 =E2=94=82 =E2=94=82 =E2=94=82 =E2=94=82 =E2=94=82 =E2=94=82 = :ref:`stats `/nr_tried,sz_tried,nr_applied,sz_applied,= sz_ops_filter_passed,qt_exceeds,nr_snapshots,max_nr_snapshots =E2=94=82 =E2=94=82 =E2=94=82 =E2=94=82 =E2=94=82 =E2=94=82 =E2=94=82 = :ref:`tried_regions `/total_bytes =E2=94=82 =E2=94=82 =E2=94=82 =E2=94=82 =E2=94=82 =E2=94=82 =E2=94=82 = =E2=94=82 0/start,end,nr_accesses,age,sz_filter_passed =E2=94=82 =E2=94=82 =E2=94=82 =E2=94=82 =E2=94=82 =E2=94=82 =E2=94=82 = =E2=94=82 ... @@ -543,10 +543,11 @@ online analysis or tuning of the schemes. Refer to := ref:`design doc =20 The statistics can be retrieved by reading the files under ``stats`` direc= tory (``nr_tried``, ``sz_tried``, ``nr_applied``, ``sz_applied``, -``sz_ops_filter_passed``, ``qt_exceeds`` and ``nr_snapshots``), respective= ly. -The files are not updated in real time, so you should ask DAMON sysfs inte= rface -to update the content of the files for the stats by writing a special keyw= ord, -``update_schemes_stats`` to the relevant ``kdamonds//state`` file. +``sz_ops_filter_passed``, ``qt_exceeds``, ``nr_snapshots`` and +``max_nr_snapshots``), respectively. The files are not updated in real ti= me, +so you should ask DAMON sysfs interface to update the content of the files= for +the stats by writing a special keyword, ``update_schemes_stats`` to the +relevant ``kdamonds//state`` file. =20 .. _sysfs_schemes_tried_regions: =20 --=20 2.47.3 From nobody Tue Dec 2 00:46:09 2025 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 B25F42DF6F5; Sun, 23 Nov 2025 18:43:48 +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=1763923428; cv=none; b=EXLsuzGfVR3tugsJezRtUxhxStsrwKYe0KQ9TEhaZXKNTcZXLyWRnR7a5iP1rhiIjJgKq5tAE/fK58bHjBB0JqsdRfzadrXE3bmO5YUrSsV2xDIUXV/qGTKE90OLH5hhvyOMqAyAF7Fddw44iabYTAITgIuNlkTwwExjvG27oG0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763923428; c=relaxed/simple; bh=Ybb1QxrTxcSMGL/dvuVAmRcZVW1T/bi0bFKyjCzx1os=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=dstQnUaLOdDonSMtFYzY0myP073tnurgM5b8iOu/w2OAwGJqsNwB3l28abjLUOhwhvs8wayoLHJ/xxIv3jBjMNFH8FD8OSOri91owlzafiHdBou+VY4gj+Hn/BOWBGMx5+F952nUMuKKYZ8AkWey1ITE77WmLj5zIhhjBdrZC/Q= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=BYi9f6Rx; 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="BYi9f6Rx" Received: by smtp.kernel.org (Postfix) with ESMTPSA id CC1A3C116B1; Sun, 23 Nov 2025 18:43:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1763923427; bh=Ybb1QxrTxcSMGL/dvuVAmRcZVW1T/bi0bFKyjCzx1os=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=BYi9f6Rxc+0CMnIHUHMDz+lfgFgknCKtvqjVXfYl+ve/HQa7T34ClRr6hEVo0/svZ tBbqdU/pAr3Wx4t6yoqbOGnxB7At1cegTkOf63a7/Z91Y42MYkE61i65+LgDRitFFR NpFSrSWW39sMVdAFNy1K6+pZ8qteehu2Ve4Wz8kS8AgkJ/ug9qmG072Xo7B9ikNjOV r8iHDaN/UmObSd4WTqCejsHaKE5Xa/7T2QWj4c3Piwqlv5xe3ALScwDzhPZDGyLrHO jEQpkBey3hUJIxrRLfH3ekhusmaCYgLuxArQAM1Mc2uepF0ypmKzzTj4gVLpM2V208 h1X+1I6NtwkIw== From: SeongJae Park To: Cc: SeongJae Park , damon@lists.linux.dev, linux-kernel@vger.kernel.org, linux-mm@kvack.org Subject: [RFC PATCH 11/12] Docs/ABI/damon: update for max_nr_snapshots Date: Sun, 23 Nov 2025 10:43:25 -0800 Message-ID: <20251123184329.85287-12-sj@kernel.org> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20251123184329.85287-1-sj@kernel.org> References: <20251123184329.85287-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 DAMON ABI document for the newly added DAMON sysfs interface file, max_nr_snapshots. Signed-off-by: SeongJae Park --- Documentation/ABI/testing/sysfs-kernel-mm-damon | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/Documentation/ABI/testing/sysfs-kernel-mm-damon b/Documentatio= n/ABI/testing/sysfs-kernel-mm-damon index 8ec469eb4471..4504a0f8b446 100644 --- a/Documentation/ABI/testing/sysfs-kernel-mm-damon +++ b/Documentation/ABI/testing/sysfs-kernel-mm-damon @@ -522,6 +522,13 @@ Contact: SeongJae Park Description: Reading this file returns the total number of DAMON snapshots that the scheme has tried to be applied. =20 +What: /sys/kernel/mm/damon/admin/kdamonds//contexts//schemes//st= ats/max_nr_snapshots +Date: Nov 2025 +Contact: SeongJae Park +Description: Writing a number to this file sets the upper limit of + nr_snapshots that deactivates the scheme when the limit is + reached or exceeded. + What: /sys/kernel/mm/damon/admin/kdamonds//contexts//schemes//tr= ied_regions/total_bytes Date: Jul 2023 Contact: SeongJae Park --=20 2.47.3 From nobody Tue Dec 2 00:46:09 2025 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 6F78E2DCC1B; Sun, 23 Nov 2025 18:43:48 +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=1763923428; cv=none; b=Zz6OOOnhGRBn3uCN2HQTpgkG1UPXEhgQH+7SBtSnzl2Sa/h4F4CippCEaMPKOJirTV/26Jstx0VipQupTMKvK5xfi4krpPIrJZHhG/HiQvVQT1BgBRGoXZBKhFM2AAF4uQDrx1Z/4MlN0Z3GdajLNgfyEpKjUnH1PdndX7PwzdU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763923428; c=relaxed/simple; bh=mH5BWCQEqqk49CCwYmvCMx+4mPSEeoKbb/+aR5lpkFw=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=QXSyeGUpl6uWvLGDBuTZeeNXqeoG3F+He9eNzkFd9O3IoGxLwGkzyCh431lPlD4G7Idys2wldRuxmXfRRZ+OntATKjc7/vTs3QBZ9SPO+n2FTkFmYiIaLGiv99E3D2Mf/xPGYZHD97rf1XErkcthgHMWnBeCfMAHUXcubjzdaGI= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=RCsc9Fbe; 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="RCsc9Fbe" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 121B1C16AAE; Sun, 23 Nov 2025 18:43:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1763923428; bh=mH5BWCQEqqk49CCwYmvCMx+4mPSEeoKbb/+aR5lpkFw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=RCsc9Fbe1dxQvC+VyC2YgBZqZFVqvkyNxSvEcCyUenkZyYkccaPZ7WjU6SagGMC+1 XAQajqhn2371cO9Ln+ersUfxExuUbX0dRhyVAOIGdLG/C6SLaA7bslob0Zagkl2Pwu +UcF7rMZ5atHuuvBPT3AUTwNw17iHfbMiPboUJ/R6Jg8o+LrOUJhzzZzc20IxzvVFB 0ptr86AsnPZ+Yhkuo4SiKXfev1eBSlyVTXquh6KPu8g6+wZbycgr/UgCdHlJT5RWFN t6kFESo9IRwFeJL/ZhxyNZ8fO3xIdjn/gQuQlz2eU3FTZBpUo0VNs5Hku4Qxx3uJk7 U2t8nm2EO9OQw== From: SeongJae Park To: Cc: SeongJae Park , Andrew Morton , Masami Hiramatsu , Mathieu Desnoyers , Steven Rostedt , damon@lists.linux.dev, linux-kernel@vger.kernel.org, linux-mm@kvack.org, linux-trace-kernel@vger.kernel.org Subject: [RFC PATCH 12/12] mm/damon/core: add trace point for damos stat per apply interval Date: Sun, 23 Nov 2025 10:43:26 -0800 Message-ID: <20251123184329.85287-13-sj@kernel.org> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20251123184329.85287-1-sj@kernel.org> References: <20251123184329.85287-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 users can read DAMOS stats via DAMON sysfs interface. It enables efficient, simple and flexible usages of the stats. Especially for systems not having advanced tools like perf or bpftrace, that can be useful. But if the advanced tools are available, exposing the stats via tracepoint can reduce unnecessary reimplementation of the wheels. Add a new tracepoint for DAMOS stats, namely damos_stat_after_apply_interval. The tracepoint is triggered for each scheme's apply interval and exposes the whole stat values. If the user needs sub-apply interval information for any chance, damos_before_apply tracepoint could be used. Signed-off-by: SeongJae Park --- include/trace/events/damon.h | 41 ++++++++++++++++++++++++++++++++++++ mm/damon/core.c | 15 +++++++++++++ 2 files changed, 56 insertions(+) diff --git a/include/trace/events/damon.h b/include/trace/events/damon.h index 852d725afea2..24fc402ab3c8 100644 --- a/include/trace/events/damon.h +++ b/include/trace/events/damon.h @@ -9,6 +9,47 @@ #include #include =20 +TRACE_EVENT(damos_stat_after_apply_interval, + + TP_PROTO(unsigned int context_idx, unsigned int scheme_idx, + struct damos_stat *stat), + + TP_ARGS(context_idx, scheme_idx, stat), + + TP_STRUCT__entry( + __field(unsigned int, context_idx) + __field(unsigned int, scheme_idx) + __field(unsigned long, nr_tried) + __field(unsigned long, sz_tried) + __field(unsigned long, nr_applied) + __field(unsigned long, sz_applied) + __field(unsigned long, sz_ops_filter_passed) + __field(unsigned long, qt_exceeds) + __field(unsigned long, nr_snapshots) + ), + + TP_fast_assign( + __entry->context_idx =3D context_idx; + __entry->scheme_idx =3D scheme_idx; + __entry->nr_tried =3D stat->nr_tried; + __entry->sz_tried =3D stat->sz_tried; + __entry->nr_applied =3D stat->nr_applied; + __entry->sz_applied =3D stat->sz_applied; + __entry->sz_ops_filter_passed =3D stat->sz_ops_filter_passed; + __entry->qt_exceeds =3D stat->qt_exceeds; + __entry->nr_snapshots =3D stat->nr_snapshots; + ), + + TP_printk("ctx_idx=3D%u scheme_idx=3D%u nr_tried=3D%lu sz_tried=3D%lu " + "nr_applied=3D%lu sz_tried=3D%lu sz_ops_filter_passed=3D%lu " + "qt_exceeds=3D%lu nr_snapshots=3D%lu", + __entry->context_idx, __entry->scheme_idx, + __entry->nr_tried, __entry->sz_tried, + __entry->nr_applied, __entry->sz_applied, + __entry->sz_ops_filter_passed, __entry->qt_exceeds, + __entry->nr_snapshots) +); + TRACE_EVENT(damos_esz, =20 TP_PROTO(unsigned int context_idx, unsigned int scheme_idx, diff --git a/mm/damon/core.c b/mm/damon/core.c index 36313cd1ff1c..2f212a18e4a0 100644 --- a/mm/damon/core.c +++ b/mm/damon/core.c @@ -2256,6 +2256,19 @@ static void damos_adjust_quota(struct damon_ctx *c, = struct damos *s) quota->min_score =3D score; } =20 +static void damos_trace_stat(struct damon_ctx *c, struct damos *s) +{ + unsigned int cidx =3D 0, sidx =3D 0; + struct damos *siter; + + damon_for_each_scheme(siter, c) { + if (siter =3D=3D s) + break; + sidx++; + } + trace_damos_stat_after_apply_interval(cidx, sidx, &s->stat); +} + static void kdamond_apply_schemes(struct damon_ctx *c) { struct damon_target *t; @@ -2294,6 +2307,8 @@ static void kdamond_apply_schemes(struct damon_ctx *c) (s->apply_interval_us ? s->apply_interval_us : c->attrs.aggr_interval) / sample_interval; s->last_applied =3D NULL; + if (trace_damos_stat_after_apply_interval_enabled()) + damos_trace_stat(c, s); } mutex_unlock(&c->walk_control_lock); } --=20 2.47.3