From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (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 90431388E46; Tue, 28 Jul 2026 04:12:55 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1785211978; cv=none; b=uVArernNAxSsCNnPeW1b4sSekZSglfT3s7OHKGR/FQW/hmCL1OaC8L+9I7e2l1a36sYSOU3o55fv43Y49arPH7zBCbfqPm7OJjupe3scfcMh1fJDMmXOcKY8YAd8Vebes2yYxn3lTbqYMym+2algX4jjm7j/+3zG1Ehpf1k4zxM= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1785211978; c=relaxed/simple; bh=16yP5cV9OrB/WE3D2vcIatZsshn7bQBy6zYqQtCanic=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=DnTEIFvouGqvZEwdxpFZ7cNjlSOWbW5gq76F7xQPp5wwWfBeECIxsyMhwbXWeCCZqxst+ZGTpCh5m2ZDf05bs5DF3AvAluU+yQAFuoRK0DSK2NgDT9Z5q4+/0I85qMYSjUEjL8CT566gQChmBTbvZtsJP6b4Rz8ZiqFGiN7mp8U= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=bvAy/5wc; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="bvAy/5wc" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 546771F00A3A; Tue, 28 Jul 2026 04:12:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1785211974; bh=4iMGONrTxKF9K4rx67zBl5qGWanzFtUrmQIoQVAkWTA=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=bvAy/5wcxVr+voBw3danpLK2JmlUQsrvMqPswGDDfWY8kWEGsG7CV6cKD9AEnYSUc 4GrsWElHOvVtqhv8oxPU8PxpXUdTjMGPZNrUCfYPH2lFL01ygygaUbMx/p+vdPhpjx OMwXmQ2xDmLyX9Y8IjJss+1OoxjOLO2lkDk6y+GVlJjGsbYqThb9X6qfBWIpXCEnoe gnfzJ46PLD5sJ9fVhUKJhami9Ebxu5u79Ewijb/cz0nWvDFxv5MRbzSwl8mNhXJXQd qlaqjDZutdS2ErpplHNW11RSA9jA2n+tUoKXWWAibQKYfrSIr2RHmX+KdeEeugbbqU T9qqA5lrH4+SQ== From: SJ Park To: Cc: SJ Park , Andrew Morton , damon@lists.linux.dev, linux-kernel@vger.kernel.org, linux-mm@kvack.org Subject: [RFC PATCH v2.2 07/17] mm/damon/core: introduce damon_operations->prep_probes() Date: Mon, 27 Jul 2026 21:12:28 -0700 Message-ID: <20260728041242.187380-8-sj@kernel.org> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20260728041242.187380-1-sj@kernel.org> References: <20260728041242.187380-1-sj@kernel.org> Precedence: bulk X-Mailing-List: damon@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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 --- include/linux/damon.h | 5 +++++ mm/damon/core.c | 20 +++++++++++++++++++- 2 files changed, 24 insertions(+), 1 deletion(-) diff --git a/include/linux/damon.h b/include/linux/damon.h index b86744642c9d3..c6cbf1edf331a 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,9 @@ 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. It should also set + * &damon_region->sampling_addr of each region if ``set_samples`` is true. * @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 +682,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 01715648f6e0c..f7c9b94b6436b 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) { @@ -3870,14 +3882,19 @@ 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 do_prep; unsigned int max_merge_score = 0, max_wsum; bool get_max_wsum; if (kdamond_wait_activation(ctx)) break; + do_prep = ctx->ops.prep_probes && damon_has_prep(ctx); + if (!access_check_disabled && ctx->ops.prepare_access_checks) ctx->ops.prepare_access_checks(ctx); + if (do_prep) + ctx->ops.prep_probes(ctx, access_check_disabled); kdamond_usleep(sample_interval); ctx->passed_sample_intervals++; @@ -3892,7 +3909,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 && !do_prep, + get_max_wsum); if (get_max_wsum) max_merge_score = max_wsum; } -- 2.47.3