All of lore.kernel.org
 help / color / mirror / Atom feed
From: SJ Park <sj@kernel.org>
Cc: SJ Park <sj@kernel.org>,
	Andrew Morton <akpm@linux-foundation.org>,
	damon@lists.linux.dev, linux-kernel@vger.kernel.org,
	linux-mm@kvack.org
Subject: [RFC PATCH v2.1 06/17] mm/damon/core: commit preps
Date: Mon, 27 Jul 2026 07:38:15 -0700	[thread overview]
Message-ID: <20260727143829.86236-7-sj@kernel.org> (raw)
In-Reply-To: <20260727143829.86236-1-sj@kernel.org>

damon_commit_probes() is ignoring damon_prep.  Commit the prep actions,
too.

Signed-off-by: SJ Park <sj@kernel.org>
---
 mm/damon/core.c | 59 +++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 59 insertions(+)

diff --git a/mm/damon/core.c b/mm/damon/core.c
index bda61f9ec0266..c74dee56efee8 100644
--- a/mm/damon/core.c
+++ b/mm/damon/core.c
@@ -128,11 +128,34 @@ void damon_add_prep(struct damon_probe *p, struct damon_prep *prep)
 	list_add_tail(&prep->list, &p->preps);
 }
 
+static void damon_del_prep(struct damon_prep *p)
+{
+	list_del(&p->list);
+}
+
 static void damon_free_prep(struct damon_prep *p)
 {
 	kfree(p);
 }
 
+static void damon_destroy_prep(struct damon_prep *p)
+{
+	damon_del_prep(p);
+	damon_free_prep(p);
+}
+
+static struct damon_prep *damon_nth_prep(int n, struct damon_probe *p)
+{
+	struct damon_prep *prep;
+	int i = 0;
+
+	damon_for_each_prep(prep, p) {
+		if (i++ == n)
+			return prep;
+	}
+	return NULL;
+}
+
 struct damon_filter *damon_new_filter(enum damon_filter_type type,
 		bool matching, bool allow)
 {
@@ -1694,6 +1717,36 @@ static int damon_commit_targets(
 	return err;
 }
 
+static void damon_commit_prep(struct damon_prep *dst, struct damon_prep *src)
+{
+	dst->action = src->action;
+}
+
+static int damon_commit_preps(struct damon_probe *dst, struct damon_probe *src)
+{
+	struct damon_prep *dst_prep, *next, *src_prep, *new_prep;
+	int i = 0, j = 0;
+
+	damon_for_each_prep_safe(dst_prep, next, dst) {
+		src_prep = damon_nth_prep(i++, src);
+		if (src_prep)
+			damon_commit_prep(dst_prep, src_prep);
+		else
+			damon_destroy_prep(dst_prep);
+	}
+
+	damon_for_each_prep_safe(src_prep, next, src) {
+		if (j++ < i)
+			continue;
+
+		new_prep = damon_new_prep(src_prep->action);
+		if (!new_prep)
+			return -ENOMEM;
+		damon_add_prep(dst, new_prep);
+	}
+	return 0;
+}
+
 static void damon_commit_filter(struct damon_filter *dst,
 		struct damon_filter *src)
 {
@@ -1752,6 +1805,9 @@ static int damon_commit_probes(struct damon_ctx *dst, struct damon_ctx *src)
 		src_probe = damon_nth_probe(i++, src);
 		if (src_probe) {
 			dst_probe->weight = src_probe->weight;
+			err = damon_commit_preps(dst_probe, src_probe);
+			if (err)
+				return err;
 			err = damon_commit_filters(dst_probe, src_probe);
 			if (err)
 				return err;
@@ -1769,6 +1825,9 @@ static int damon_commit_probes(struct damon_ctx *dst, struct damon_ctx *src)
 			return -ENOMEM;
 		damon_add_probe(dst, new_probe);
 		new_probe->weight = src_probe->weight;
+		err = damon_commit_preps(new_probe, src_probe);
+		if (err)
+			return err;
 		err = damon_commit_filters(new_probe, src_probe);
 		if (err)
 			return err;
-- 
2.47.3


  parent reply	other threads:[~2026-07-27 14:38 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-07-27 14:38 [RFC PATCH v2.1 00/17] mm/damon: introduce data access-as-a-data attribute SJ Park
2026-07-27 14:38 ` [RFC PATCH v2.1 01/17] mm/damon/core: introduce DAMON_FILTER_TYPE_PGIDLE_UNSET SJ Park
2026-07-27 14:47   ` sashiko-bot
2026-07-27 14:58     ` SJ Park
2026-07-27 14:38 ` [RFC PATCH v2.1 02/17] mm/damon/paddr: support PGIDLE_UNSET probe filter type SJ Park
2026-07-27 14:52   ` sashiko-bot
2026-07-27 14:59     ` SJ Park
2026-07-27 14:38 ` [RFC PATCH v2.1 03/17] mm/damon/sysfs: support pgidle_unset " SJ Park
2026-07-27 14:38 ` [RFC PATCH v2.1 04/17] Docs/mm/damon/design: document " SJ Park
2026-07-27 14:38 ` [RFC PATCH v2.1 05/17] mm/damon/core: introduce damon_prep struct SJ Park
2026-07-27 14:48   ` sashiko-bot
2026-07-27 15:00     ` SJ Park
2026-07-27 14:38 ` SJ Park [this message]
2026-07-27 14:38 ` [RFC PATCH v2.1 07/17] mm/damon/core: introduce damon_operations->prep_probes() SJ Park
2026-07-27 14:44   ` sashiko-bot
2026-07-27 15:02     ` SJ Park
2026-07-27 14:38 ` [RFC PATCH v2.1 08/17] mm/damon/paddr: support damon_prep SJ Park
2026-07-27 14:38 ` [RFC PATCH v2.1 09/17] mm/damon/sysfs: implement preps directory SJ Park
2026-07-27 14:38 ` [RFC PATCH v2.1 10/17] mm/damon/sysfs: implement preps/nr_preps file SJ Park
2026-07-27 14:38 ` [RFC PATCH v2.1 11/17] mm/damon/sysfs: create directories for nr_preps writes SJ Park
2026-07-27 14:38 ` [RFC PATCH v2.1 12/17] mm/damon/sysfs: implement prep_action file SJ Park
2026-07-27 14:38 ` [RFC PATCH v2.1 13/17] mm/damon/sysfs: pass preps to DAMON core SJ Park
2026-07-27 14:38 ` [RFC PATCH v2.1 14/17] selftests/damon/sysfs.sh: test probe prep sysfs files SJ Park
2026-07-27 14:38 ` [RFC PATCH v2.1 15/17] Docs/mm/damon/design: document probe preps SJ Park
2026-07-27 14:38 ` [RFC PATCH v2.1 16/17] Docs/admin-guide/mm/damon/usage: document probe preps sysfs files SJ Park
2026-07-27 14:38 ` [RFC PATCH v2.1 17/17] Docs/ABI/damon: document probe prep " SJ Park

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=20260727143829.86236-7-sj@kernel.org \
    --to=sj@kernel.org \
    --cc=akpm@linux-foundation.org \
    --cc=damon@lists.linux.dev \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    /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.