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 07/17] mm/damon/core: introduce damon_operations->prep_probes()
Date: Sat, 25 Jul 2026 14:02:11 -0700	[thread overview]
Message-ID: <20260725210225.129944-8-sj@kernel.org> (raw)
In-Reply-To: <20260725210225.129944-1-sj@kernel.org>

damon_prep needs to be executed by the underlying DAMON operation set.
Extend the operation set callback list for the execution of damon_prep
actions.  If the underlying operation set implements the callback, DAMON
core executes it in the monitoring preparation time.

Signed-off-by: SJ Park <sj@kernel.org>
---
 include/linux/damon.h |  4 ++++
 mm/damon/core.c       | 18 +++++++++++++++++-
 2 files changed, 21 insertions(+), 1 deletion(-)

diff --git a/include/linux/damon.h b/include/linux/damon.h
index 255b20e44287f..f5b0f16305b30 100644
--- a/include/linux/damon.h
+++ b/include/linux/damon.h
@@ -629,6 +629,7 @@ enum damon_ops_id {
  * @update:			Update operations-related data structures.
  * @prepare_access_checks:	Prepare next access check of target regions.
  * @check_accesses:		Check the accesses to target regions.
+ * @prep_probes:		Prepare applying probes for each region.
  * @apply_probes:		Apply probes for each region.
  * @get_scheme_score:		Get the score of a region for a scheme.
  * @apply_scheme:		Apply a DAMON-based operation scheme.
@@ -656,6 +657,8 @@ enum damon_ops_id {
  * last preparation and update the number of observed accesses of each region.
  * It should also return max number of observed accesses that made as a result
  * of its update.  The value will be used for regions adjustment threshold.
+ * @prep_probes should execute required &struct damon_prep for next &struct
+ * damon_probe applications to each region.
  * @apply_probes should apply the data attribute probes to each region and
  * accordingly update the probe hits counter of the region.  It should also
  * set &damon_region->sampling_addr of each region if ``set_samples`` is true.
@@ -678,6 +681,7 @@ struct damon_operations {
 	void (*update)(struct damon_ctx *context);
 	void (*prepare_access_checks)(struct damon_ctx *context);
 	unsigned int (*check_accesses)(struct damon_ctx *context);
+	void (*prep_probes)(struct damon_ctx *context, bool set_samples);
 	unsigned int (*apply_probes)(struct damon_ctx *context,
 			bool set_samples, bool return_max_wsum);
 	int (*get_scheme_score)(struct damon_ctx *context,
diff --git a/mm/damon/core.c b/mm/damon/core.c
index c74dee56efee8..11d16b7104a7e 100644
--- a/mm/damon/core.c
+++ b/mm/damon/core.c
@@ -156,6 +156,18 @@ static struct damon_prep *damon_nth_prep(int n, struct damon_probe *p)
 	return NULL;
 }
 
+static bool damon_has_prep(struct damon_ctx *c)
+{
+	struct damon_prep *prep;
+	struct damon_probe *probe;
+
+	damon_for_each_probe(probe, c) {
+		damon_for_each_prep(prep, probe)
+			return true;
+	}
+	return false;
+}
+
 struct damon_filter *damon_new_filter(enum damon_filter_type type,
 		bool matching, bool allow)
 {
@@ -3868,6 +3880,7 @@ static int kdamond_fn(void *data)
 		unsigned long next_ops_update_sis = ctx->next_ops_update_sis;
 		unsigned long sample_interval = ctx->attrs.sample_interval;
 		bool access_check_disabled = damon_has_probe_weights(ctx);
+		bool has_prep = damon_has_prep(ctx);
 		unsigned int max_merge_score = 0, max_wsum;
 		bool get_max_wsum;
 
@@ -3876,6 +3889,8 @@ static int kdamond_fn(void *data)
 
 		if (!access_check_disabled && ctx->ops.prepare_access_checks)
 			ctx->ops.prepare_access_checks(ctx);
+		if (ctx->ops.prep_probes)
+			ctx->ops.prep_probes(ctx, has_prep);
 
 		kdamond_usleep(sample_interval);
 		ctx->passed_sample_intervals++;
@@ -3890,7 +3905,8 @@ static int kdamond_fn(void *data)
 			else
 				get_max_wsum = false;
 			max_wsum = ctx->ops.apply_probes(ctx,
-					access_check_disabled, get_max_wsum);
+					access_check_disabled && !has_prep,
+					get_max_wsum);
 			if (get_max_wsum)
 				max_merge_score = max_wsum;
 		}
-- 
2.47.3

  parent reply	other threads:[~2026-07-25 21:02 UTC|newest]

Thread overview: 38+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-07-25 21:02 [RFC PATCH 00/17] mm/damon: introduce data access-as-a-data attribute SJ Park
2026-07-25 21:02 ` [RFC PATCH 01/17] mm/damon/core: introduce DAMON_FILTER_TYPE_PGIDLE_UNSET SJ Park
2026-07-25 21:11   ` sashiko-bot
2026-07-25 21:28     ` SJ Park
2026-07-25 21:02 ` [RFC PATCH 02/17] mm/damon/paddr: support PGIDLE_UNSET probe filter type SJ Park
2026-07-25 21:17   ` sashiko-bot
2026-07-25 21:30     ` SJ Park
2026-07-25 21:02 ` [RFC PATCH 03/17] mm/damon/sysfs: support pgidle_unset " SJ Park
2026-07-25 21:02 ` [RFC PATCH 04/17] Docs/mm/damon/design: document " SJ Park
2026-07-25 21:05   ` sashiko-bot
2026-07-25 21:39     ` SJ Park
2026-07-25 21:02 ` [RFC PATCH 05/17] mm/damon/core: introduce damon_prep struct SJ Park
2026-07-25 21:02 ` [RFC PATCH 06/17] mm/damon/core: commit preps SJ Park
2026-07-25 21:02 ` SJ Park [this message]
2026-07-25 21:14   ` [RFC PATCH 07/17] mm/damon/core: introduce damon_operations->prep_probes() sashiko-bot
2026-07-25 21:52     ` SJ Park
2026-07-25 21:02 ` [RFC PATCH 08/17] mm/damon/paddr: support damon_prep SJ Park
2026-07-25 21:15   ` sashiko-bot
2026-07-25 21:54     ` SJ Park
2026-07-25 21:02 ` [RFC PATCH 09/17] mm/damon/sysfs: implement preps directory SJ Park
2026-07-25 21:13   ` sashiko-bot
2026-07-25 21:57     ` SJ Park
2026-07-25 21:02 ` [RFC PATCH 10/17] mm/damon/sysfs: create probe " SJ Park
2026-07-25 21:02 ` [RFC PATCH 11/17] mm/damon/sysfs: implement probe prep directory SJ Park
2026-07-25 21:10   ` sashiko-bot
2026-07-25 21:59     ` SJ Park
2026-07-25 21:02 ` [RFC PATCH 12/17] mm/damon/sysfs: create probe prep files for preps/nr file write SJ Park
2026-07-25 21:02 ` [RFC PATCH 13/17] mm/damon/sysfs: pass preps to DAMON core SJ Park
2026-07-25 21:02 ` [RFC PATCH 14/17] selftests/damon/sysfs.sh: test probe prep sysfs files SJ Park
2026-07-25 21:02 ` [RFC PATCH 15/17] Docs/mm/damon/design: document probe preps SJ Park
2026-07-25 21:06   ` sashiko-bot
2026-07-25 22:00     ` SJ Park
2026-07-25 21:02 ` [RFC PATCH 16/17] Docs/admin-guide/mm/damon/usage: document probe preps sysfs files SJ Park
2026-07-25 21:08   ` sashiko-bot
2026-07-25 22:06     ` SJ Park
2026-07-25 21:02 ` [RFC PATCH 17/17] Docs/ABI/damon: document probe prep " SJ Park
2026-07-25 21:12   ` sashiko-bot
2026-07-25 22:09     ` 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=20260725210225.129944-8-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.