From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 22CEEC83F0A for ; Sun, 6 Jul 2025 20:01:06 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id B0C566B040A; Sun, 6 Jul 2025 16:00:42 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id ABE9D6B040B; Sun, 6 Jul 2025 16:00:42 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 985486B040C; Sun, 6 Jul 2025 16:00:42 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id 7DA5B6B040A for ; Sun, 6 Jul 2025 16:00:42 -0400 (EDT) Received: from smtpin12.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id 41A42B6FC7 for ; Sun, 6 Jul 2025 20:00:42 +0000 (UTC) X-FDA: 83634907524.12.66C6F9C Received: from tor.source.kernel.org (tor.source.kernel.org [172.105.4.254]) by imf30.hostedemail.com (Postfix) with ESMTP id BD4A98000F for ; Sun, 6 Jul 2025 20:00:40 +0000 (UTC) Authentication-Results: imf30.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=HUKnQNA1; spf=pass (imf30.hostedemail.com: domain of sj@kernel.org designates 172.105.4.254 as permitted sender) smtp.mailfrom=sj@kernel.org; dmarc=pass (policy=quarantine) header.from=kernel.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1751832040; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=7su7NcQ4du99BSNkl6d+jOmkEq26u8mtNNT97makBOM=; b=UQArD8fS/ll0bsBqz3ZQchxqmVbpNZHGAx5WWyyOIHXzQ1pFQ9GIg093fMaUNjx7XE5lQX tiNjNNDW+ZuOjX2U/aA652mRs2SdfFkODbyGuqdrwCKL4d65t9sis9BV+6VrgXkxp4q/+F uTynGTNb5qN+10WHYeWHT8lIXISzZjM= ARC-Authentication-Results: i=1; imf30.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=HUKnQNA1; spf=pass (imf30.hostedemail.com: domain of sj@kernel.org designates 172.105.4.254 as permitted sender) smtp.mailfrom=sj@kernel.org; dmarc=pass (policy=quarantine) header.from=kernel.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1751832040; a=rsa-sha256; cv=none; b=ShEmyJ026uJYF1egSUNicKgQP69eR1AazWHmS81oWEVpmSpzjLDJNqElbx9l1eCgKlr92i 1EjuGPPxI6ZABQvdsO07GM4fD59YCuzQiZ0zHd74XGH6454WlhtnSi0utdcUt/plaTs0FA W3FteEB/U2jqfTvK7Y6v9ZdKWmRvU/U= Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by tor.source.kernel.org (Postfix) with ESMTP id 54C9561460; Sun, 6 Jul 2025 20:00:40 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id D4271C4CEED; Sun, 6 Jul 2025 20:00:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1751832040; bh=UY8idiDxx1z6VY897USN60G0+UWHNTZfcQ9JenDI6ok=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=HUKnQNA15EstRNmSOh/lfXnqionSWBjs/fTP4t7hUoev5c8hq4F8mFMi7xh5Ieopx RQCOssCOkluQz/JD3vSkmQRnjIzettO5FOhFk7ojmODcJ243GO6R7kf0B1l6IgUGjs FkVVJnhAPAt9n5LhRjaeiMDFQ20wHC8odD4p/pAAT+8qKCKqB7n9GAoEQoNhuVpYYz g/rFh/3XJ8ftoGa4gB/nmmyD1Bp1uST+0vOWYzsLl6txc2eXxsx92z+5FKf6b1cdsv kIoFJD6l7LyFzWuLy3j+8PjVOA1d6HpLDi8TJO6JFXz/uo/QNS3zThRu7SzCZxmk8I hI1L8tqJj9vHw== From: SeongJae Park To: Cc: SeongJae Park , Andrew Morton , damon@lists.linux.dev, kernel-team@meta.com, linux-kernel@vger.kernel.org, linux-mm@kvack.org Subject: [RFC PATCH 14/14] mm/damon/core: remove damon_callback Date: Sun, 6 Jul 2025 13:00:18 -0700 Message-Id: <20250706200018.42704-15-sj@kernel.org> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20250706200018.42704-1-sj@kernel.org> References: <20250706200018.42704-1-sj@kernel.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Stat-Signature: h6bkqgf7esszagah3gxmabu76ddpcc6z X-Rspam-User: X-Rspamd-Server: rspam06 X-Rspamd-Queue-Id: BD4A98000F X-HE-Tag: 1751832040-357856 X-HE-Meta: U2FsdGVkX1/6BRKfRpXCDtFfG/hWKOPXPb1CmbzZkpmzurvWGIdIOUdRmDDSWbHM8sXaiYR8vbzAqBuwMXkcf/zuN9DLsLA5W4c+5jwnsn/IlYv1jiTVBIf3zZcY2AmEonq3vaq/yl6U7l/YSuBXFS2iPN3+6UiN5ehVQZzPe7iwdX93UIELsAaGRJI0pH5Zt4IjbbwMEAjC6qULfXGJEGms+afAIAjUrp8Om+JlSIsWWnG0elXOqKDvcyxV2HXiWdGL0Lk+FW+/0DV5huBtBemVl/Dsm7Fa2Rt3Sfg/ViDymhhIMYpSifYlp/AVowD4lF2aE5DgVZMRbLtJUl0XY2tmL9zETtca0Y7Azs19XrBerN1Ebwq9mGtz7F9W00thr+7m7rqc0rnMg50ZHEwYGHYkB2n+CN1gBzeB0t7tVHvRzAZ+M2sx9OTyRoKV9IU1n0eZi2eZf8H87UcLpZNSf4N2wQh1d1GRwPvsJR0ytc4/MaGNBoQSvm9rHQ8tI7yu1lOmmUNgIg1aiLCfX31MqOv8YJzCWPh0ESUq2Uks5RqIEmoYBelxAQ0mqAXbZU5Jk13vm30ZEHtVnpBv5QKEvAazuExWkOBGeDgwAqZPeKwVyhEy51da1ZDqV52a9kWEEWmkYYBIJk9+dij4d2Y+7wg8SMu+s5jVHuGvVM2Xjb25gvbkCFf+X1igSwjm8uAeSTBci+7xkMsJt30TgkegToLvMSXEXxUgOXLtHRfU0YWUqOlG2X5cPouEeWj7ONhYfBjtdOZom9643PXTd/4QscJc5qifDenr95jIsi7vWVk9feguic2ahjipU8LRyDixw2Th1bVqii9tUVUj/deN60bKeQgm2PTLBdKUGu7nYLr1hJDYHQ9s5QJpYGYMu1mD/YZRVzUPpu1N33WfPgZVwZfj2zKjmvMJV47fSvPGoPxWTQb3VReftAxKeusqDg3Hmw49qFv6zbOF3dHsXmg Htjv05qS HaMR/QzdvF0Ojm+SKA5xPG3y3fLFVLjt/8PM7mT4OnQ/EYL6bQtU2v8CM6Et4+gHwik2uq9I4qAthLvTkG8sBAg1pjs4ojMbYf6i1N6DYi3Kg1TxEztghzbxW2KtU0/hq9JT1+y67puFPqEOW1Gn5XmH7cUA1UQCc1PD+sjBPOXdxc3U20tMAWrhTINKW2edSsnoNgtc1r43QZWpTlg4PlXBuMEYVeASVyxjz9F7zwEDXSzp66Qcv5ePeynEKWtkj1RgO6kg2tm/0TAgBNjZen18R/g== X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: All damon_callback usages are replicated by damon_call() and damos_walk(). Remove damon_callback. Signed-off-by: SeongJae Park --- include/linux/damon.h | 31 +------------------------------ mm/damon/core.c | 26 +++++++------------------- 2 files changed, 8 insertions(+), 49 deletions(-) diff --git a/include/linux/damon.h b/include/linux/damon.h index 52b307db63de..5e5cabbf8190 100644 --- a/include/linux/damon.h +++ b/include/linux/damon.h @@ -628,34 +628,6 @@ struct damon_operations { void (*cleanup)(struct damon_ctx *context); }; -/** - * struct damon_callback - Monitoring events notification callbacks. - * - * @after_wmarks_check: Called after each schemes' watermarks check. - * @after_aggregation: Called after each aggregation. - * @before_terminate: Called before terminating the monitoring. - * - * The monitoring thread (&damon_ctx.kdamond) calls @before_terminate just - * before finishing the monitoring. - * - * The monitoring thread calls @after_wmarks_check after each DAMON-based - * operation schemes' watermarks check. If users need to make changes to the - * attributes of the monitoring context while it's deactivated due to the - * watermarks, this is the good place to do. - * - * The monitoring thread calls @after_aggregation for each of the aggregation - * intervals. Therefore, users can safely access the monitoring results - * without additional protection. For the reason, users are recommended to use - * these callback for the accesses to the results. - * - * If any callback returns non-zero, monitoring stops. - */ -struct damon_callback { - int (*after_wmarks_check)(struct damon_ctx *context); - int (*after_aggregation)(struct damon_ctx *context); - void (*before_terminate)(struct damon_ctx *context); -}; - /* * struct damon_call_control - Control damon_call(). * @@ -726,7 +698,7 @@ struct damon_intervals_goal { * ``mmap()`` calls from the application, in case of virtual memory monitoring) * and applies the changes for each @ops_update_interval. All time intervals * are in micro-seconds. Please refer to &struct damon_operations and &struct - * damon_callback for more detail. + * damon_call_control for more detail. */ struct damon_attrs { unsigned long sample_interval; @@ -816,7 +788,6 @@ struct damon_ctx { struct mutex kdamond_lock; struct damon_operations ops; - struct damon_callback callback; struct list_head adaptive_targets; struct list_head schemes; diff --git a/mm/damon/core.c b/mm/damon/core.c index 719373bcfaad..ebf483fc0b76 100644 --- a/mm/damon/core.c +++ b/mm/damon/core.c @@ -680,9 +680,7 @@ static bool damon_valid_intervals_goal(struct damon_attrs *attrs) * @attrs: monitoring attributes * * This function should be called while the kdamond is not running, an access - * check results aggregation is not ongoing (e.g., from &struct - * damon_callback->after_aggregation or &struct - * damon_callback->after_wmarks_check callbacks), or from damon_call(). + * check results aggregation is not ongoing (e.g., from damon_call(). * * Every time interval is in micro-seconds. * @@ -778,7 +776,7 @@ static void damos_commit_quota_goal( * DAMON contexts, instead of manual in-place updates. * * This function should be called from parameters-update safe context, like - * DAMON callbacks. + * damon_call(). */ int damos_commit_quota_goals(struct damos_quota *dst, struct damos_quota *src) { @@ -1137,7 +1135,7 @@ static int damon_commit_targets( * in-place updates. * * This function should be called from parameters-update safe context, like - * DAMON callbacks. + * damon_call(). */ int damon_commit_ctx(struct damon_ctx *dst, struct damon_ctx *src) { @@ -2444,9 +2442,6 @@ static int kdamond_wait_activation(struct damon_ctx *ctx) kdamond_usleep(min_wait_time); - if (ctx->callback.after_wmarks_check && - ctx->callback.after_wmarks_check(ctx)) - break; kdamond_call(ctx, false); damos_walk_cancel(ctx); } @@ -2503,10 +2498,9 @@ static int kdamond_fn(void *data) while (!kdamond_need_stop(ctx)) { /* * ctx->attrs and ctx->next_{aggregation,ops_update}_sis could - * be changed from after_wmarks_check() or after_aggregation() - * callbacks. Read the values here, and use those for this - * iteration. That is, damon_set_attrs() updated new values - * are respected from next iteration. + * be changed from kdamond_call(). Read the values here, and + * use those for this iteration. That is, damon_set_attrs() + * updated new values are respected from next iteration. */ unsigned long next_aggregation_sis = ctx->next_aggregation_sis; unsigned long next_ops_update_sis = ctx->next_ops_update_sis; @@ -2524,14 +2518,10 @@ static int kdamond_fn(void *data) if (ctx->ops.check_accesses) max_nr_accesses = ctx->ops.check_accesses(ctx); - if (ctx->passed_sample_intervals >= next_aggregation_sis) { + if (ctx->passed_sample_intervals >= next_aggregation_sis) kdamond_merge_regions(ctx, max_nr_accesses / 10, sz_limit); - if (ctx->callback.after_aggregation && - ctx->callback.after_aggregation(ctx)) - break; - } /* * do kdamond_call() and kdamond_apply_schemes() after @@ -2597,8 +2587,6 @@ static int kdamond_fn(void *data) damon_destroy_region(r, t); } - if (ctx->callback.before_terminate) - ctx->callback.before_terminate(ctx); if (ctx->ops.cleanup) ctx->ops.cleanup(ctx); kfree(ctx->regions_score_histogram); -- 2.39.5