All of lore.kernel.org
 help / color / mirror / Atom feed
From: SJ Park <sj@kernel.org>
To: Andrew Morton <akpm@linux-foundation.org>
Cc: Mattathias Pinchover <mattathias.pinchover@uber.com>,
	SJ Park <sj@kernel.org>,
	damon@lists.linux.dev, linux-mm@kvack.org
Subject: [PATCH v3 1/6] mm/damon/core: introduce sz_ops_filter_passed_last stat
Date: Mon, 23 Nov 2026 07:13:02 -0800	[thread overview]
Message-ID: <20261123151309.82675-2-sj@kernel.org> (raw)
In-Reply-To: <20261123151309.82675-1-sj@kernel.org>

From: Mattathias Pinchover <mattathias.pinchover@uber.com>

DAMOS stat sz_ops_filter_passed shows the total bytes that passed
operations layer-handled DAMOS filters, accumulated from the beginning of
the scheme's execution.  Users who want the amount for only the latest
apply interval, e.g., the size of a workload's anonymous memory that is
cold as of now, need to keep the previous values in user space and
compute the difference with the help of nr_snapshots.  Because
nr_snapshots is increased once per target per apply interval, the
computation is complicated and error-prone, especially for contexts
having multiple targets.

Introduce a new DAMOS stat, sz_ops_filter_passed_last.  It is
updated at the end of each apply interval of the scheme with the amount
of sz_ops_filter_passed increase in the interval.

Assisted-by: Claude:claude-opus-5-5
Signed-off-by: Mattathias Pinchover <mattathias.pinchover@uber.com>
Reviewed-by: SJ Park <sj@kernel.org>
Signed-off-by: SJ Park <sj@kernel.org>
---
 include/linux/damon.h | 6 ++++++
 mm/damon/core.c       | 5 +++++
 2 files changed, 11 insertions(+)

diff --git a/include/linux/damon.h b/include/linux/damon.h
index 06bd92981af21..3aff5c525132b 100644
--- a/include/linux/damon.h
+++ b/include/linux/damon.h
@@ -351,6 +351,9 @@ struct damos_watermarks {
  * @sz_applied:	Total size of regions that the scheme is applied.
  * @sz_ops_filter_passed:
  *		Total bytes that passed ops layer-handled DAMOS filters.
+ * @sz_ops_filter_passed_last:
+ *		Bytes that passed ops layer-handled DAMOS filters in the last
+ *		apply interval.
  * @qt_exceeds: Total number of times the quota of the scheme has exceeded.
  * @nr_snapshots:
  *		Total number of DAMON snapshots that the scheme is completely
@@ -379,6 +382,7 @@ struct damos_stat {
 	unsigned long nr_applied;
 	unsigned long sz_applied;
 	unsigned long sz_ops_filter_passed;
+	unsigned long sz_ops_filter_passed_last;
 	unsigned long qt_exceeds;
 	unsigned long nr_snapshots;
 };
@@ -578,6 +582,8 @@ struct damos {
 	 * @action
 	 */
 	unsigned long next_apply_sis;
+	/* @stat.sz_ops_filter_passed at the start of the current apply interval */
+	unsigned long sz_ops_filter_passed_at_start;
 	/* informs if ongoing DAMOS walk for this scheme is finished */
 	bool walk_completed;
 	/*
diff --git a/mm/damon/core.c b/mm/damon/core.c
index 986404b547ebd..a99663f1f7ef0 100644
--- a/mm/damon/core.c
+++ b/mm/damon/core.c
@@ -769,6 +769,7 @@ struct damos *damon_new_scheme(struct damos_access_pattern *pattern,
 	 * or damon_attrs are updated.
 	 */
 	scheme->next_apply_sis = 0;
+	scheme->sz_ops_filter_passed_at_start = 0;
 	scheme->walk_completed = false;
 	INIT_LIST_HEAD(&scheme->core_filters);
 	INIT_LIST_HEAD(&scheme->ops_filters);
@@ -3532,6 +3533,10 @@ static noinline_for_stack void kdamond_apply_schemes(struct damon_ctx *c)
 		if (time_before(c->passed_sample_intervals, s->next_apply_sis))
 			continue;
 		damos_walk_complete(c, s);
+		s->stat.sz_ops_filter_passed_last =
+			s->stat.sz_ops_filter_passed -
+			s->sz_ops_filter_passed_at_start;
+		s->sz_ops_filter_passed_at_start = s->stat.sz_ops_filter_passed;
 		damos_set_next_apply_sis(s, c);
 		s->last_applied = NULL;
 		damos_trace_stat(c, s);
-- 
2.47.3


  reply	other threads:[~2026-11-23 15:13 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-23 15:13 [PATCH v3 0/6] mm/damon: add sz_ops_filter_passed_last DAMOS stat SJ Park
2026-11-23 15:13 ` SJ Park [this message]
2026-11-23 17:28   ` + mm-damon-core-introduce-sz_ops_filter_passed_last-stat.patch added to mm-new branch Andrew Morton
2026-11-23 15:13 ` [PATCH v3 2/6] mm/damon/sysfs-schemes: add sz_ops_filter_passed_last file SJ Park
2026-11-23 17:28   ` + mm-damon-sysfs-schemes-add-sz_ops_filter_passed_last-file.patch added to mm-new branch Andrew Morton
2026-11-23 15:13 ` [PATCH v3 3/6] mm/damon/tests/core-kunit: test sz_ops_filter_passed_last SJ Park
2026-11-23 17:28   ` + mm-damon-tests-core-kunit-test-sz_ops_filter_passed_last.patch added to mm-new branch Andrew Morton
2026-11-23 15:13 ` [PATCH v3 4/6] Docs/mm/damon/design: update for sz_ops_filter_passed_last SJ Park
2026-11-23 17:28   ` + docs-mm-damon-design-update-for-sz_ops_filter_passed_last.patch added to mm-new branch Andrew Morton
2026-11-23 15:13 ` [PATCH v3 5/6] Docs/admin-guide/mm/damon/usage: update for sz_ops_filter_passed_last SJ Park
2026-11-23 17:28   ` + docs-admin-guide-mm-damon-usage-update-for-sz_ops_filter_passed_last.patch added to mm-new branch Andrew Morton
2026-11-23 15:13 ` [PATCH v3 6/6] Docs/ABI/damon: update for sz_ops_filter_passed_last SJ Park
2026-11-23 17:28   ` + docs-abi-damon-update-for-sz_ops_filter_passed_last.patch added to mm-new branch Andrew Morton
2026-11-23 15:19 ` [PATCH v3 0/6] mm/damon: add sz_ops_filter_passed_last DAMOS stat sashiko-bot

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20261123151309.82675-2-sj@kernel.org \
    --to=sj@kernel.org \
    --cc=akpm@linux-foundation.org \
    --cc=damon@lists.linux.dev \
    --cc=linux-mm@kvack.org \
    --cc=mattathias.pinchover@uber.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.