From patchwork Mon Jan 6 19:33:49 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: SeongJae Park X-Patchwork-Id: 13927785 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 88466E77198 for ; Mon, 6 Jan 2025 19:34:19 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id AD94B6B00A1; Mon, 6 Jan 2025 14:34:15 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 9EA5B6B00A2; Mon, 6 Jan 2025 14:34:15 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 7EF046B00A3; Mon, 6 Jan 2025 14:34:15 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0016.hostedemail.com [216.40.44.16]) by kanga.kvack.org (Postfix) with ESMTP id 52FE76B00A1 for ; Mon, 6 Jan 2025 14:34:15 -0500 (EST) Received: from smtpin08.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id 03D53140282 for ; Mon, 6 Jan 2025 19:34:14 +0000 (UTC) X-FDA: 82978028070.08.6ABDA8F Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by imf13.hostedemail.com (Postfix) with ESMTP id 4A8962000A for ; Mon, 6 Jan 2025 19:34:13 +0000 (UTC) Authentication-Results: imf13.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=soICbBBh; spf=pass (imf13.hostedemail.com: domain of sj@kernel.org designates 139.178.84.217 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=1736192053; 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=5E6LVu4rcKmXTf+SXGmOSyZmKEjwfbomAy4iNKf5CMs=; b=XQSQKgOlHajY3XIO3/hCW1Pgf+Bmu1iZ/Kk9XWG/71cIHShMYfSJ5+4izCbrFYNLrzOKxt GE0f0BFMUivajf4EI7GYeTjlAtvmOGS8BpwEiU9neoiNu2KhUMz92N0Kxhw9hhkw6RbaZ5 2wDcr/J0zsvnDq7/v4i8z/qRQBHo/is= ARC-Authentication-Results: i=1; imf13.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=soICbBBh; spf=pass (imf13.hostedemail.com: domain of sj@kernel.org designates 139.178.84.217 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=1736192053; a=rsa-sha256; cv=none; b=c+/oVd40OlsMLy96ZqxNjmYLugYqZjY/Tvj7UqcV6VX7xri5iCKaFxD7M5WlV5vaV0E1qz wtdN+znP/4fGsb9RF367vEChPm4NA7wx4MtLahKuJQ004d4TDLzmGqgJAdJzyfalI/eigL MHtnudx4yE4V1FA8Mo8VrxI5sCAcVTI= Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by dfw.source.kernel.org (Postfix) with ESMTP id 5EF865C4832; Mon, 6 Jan 2025 19:33:31 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 0D61BC4CEE1; Mon, 6 Jan 2025 19:34:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1736192052; bh=gyDMV+FruyDhiWfk/GjklBAZlivUpb/zLxkaa/kITkk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=soICbBBh6s9kcuWQgnfb1X77qFDfSe5g4Wyx2wZ8l/+vVknzQlnb6EOPWet++HK/D 833R1jvhQ3C8nR3Gp9aV+hilEbMoVTzbMW8Fes+p5nijob1BeP6UK06HiAK9ilzY8p H+Ei6gFOZyK2Fy57LuN9MMMgsIHdZYJx8LMjy0gUb82EcxsChqIEJg5xiVZH8wDvMg ocp3tHQf/mtk54LnOUu18i8wSnGKokU+Oq1BVKE0pqGFdM2JZjcVrTRoBQl+4PrvsI 3n2vbt8hCkuqc7/6bUxCmWOovS8Qz+j+eWiv9Kxez3Oj8b9ZFuSBf7UmEBnCzALGub YeKBQnvt/3Kjw== From: SeongJae Park To: Andrew Morton Cc: SeongJae Park , damon@lists.linux.dev, linux-kernel@vger.kernel.org, linux-mm@kvack.org Subject: [PATCH 04/16] mm/damon: ask apply_scheme() to report filter-passed region-internal bytes Date: Mon, 6 Jan 2025 11:33:49 -0800 Message-Id: <20250106193401.109161-5-sj@kernel.org> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20250106193401.109161-1-sj@kernel.org> References: <20250106193401.109161-1-sj@kernel.org> MIME-Version: 1.0 X-Rspamd-Queue-Id: 4A8962000A X-Rspamd-Server: rspam12 X-Stat-Signature: z46wmhxi8gpis6npqd8tptzn1ndz7zxc X-Rspam-User: X-HE-Tag: 1736192053-159842 X-HE-Meta: U2FsdGVkX18p/It55p8eonrF29YJ99/9rgqMwFwE6YDUi2PG3JMjZaS7NttIsu1qT0iQBLkb5jod6fcqr8e9C7MBN8YDgbiU2LFCxhuE3IkuGU5mbcAVrQJne23v+X8wImRclDnLPUDLM1JfBcGJV+gq9HdNI+3xHV2xoPJhddgPjWgsbZwLZRvDIvjEHZUj7KHVqv+9tDLck7So8792AFgu40B0x1G6EBbJPleY7o3w5OQiytcoK+d93sd3Yyk3M0HU4QvP3pxwGjjnxw7DHFBW7jdvH0+/bPmizWpy07GJvO4X+kf1miAcKXplMRt2mCgdfNCQKIaVh5GyUnInUaG/MnUtcAL81fbraW7vtPQIgKVSH5T12LVZHUtFqToZOCy09nvsBNEviYiy6GhiVbLzTTSsD9bjIAP4bxNGbeisWVwW72u/nW+LJtHnflrxtlVJYY5pDE4rDWIxJLtmQEy9MnajetInjkzGJIzJUP+CVsqy//pWQg33ju2gVoKdATxgVUCGp+UxXHQ5ltSzL+6P6koSo1vG+Qwtlb4bTPInS56FmujBKtRIiM2O2/XKwF2f2tW9kMXj9UzZJFs+qgGZ4rEdn1RnQgNRYGJ42vvPLb9Cei2Bc/+/0srSY+5SXcEFgpS0QVA1EDPzu0rYbxbb2sNSuNrs8gBXicICCuU4Nhjw96Zhzdbgp5uteghSZPliQ+xRASblwLXg64DUBuzkWUc8O8EDihk9cA/1qLa+7v2o70fNB6IgU3XW2yMuk8WeRzyla1hU9oYg5NpruWMiKxDFmyD7Ie4yDk6ZkvbON0zeEhu3cYldEoP6Yyk7tECBW/thCwIcTJDOFFaR4BiVp8jCC4NsKSwpgWFQhOj2zS9ca4uwOweSipF009QK0v9wNhT620XrI8hOqXTgnuU+uFrreLAnH7dqPInIMABllAkQUS9tRzpFnvA3RjU0XGhKjYwj2Rku9UgWsfR xXjq0giS 8aj70heBNU4Xwv+fCRiYlmXr6GBLP+UCXo8jE7qZhxuChKxJS8/46Pu4ZBzHWPD9NqKkirf1Tgh5P5L40/iZPq/nI3bxSn+G+Ina1WgABh1nsyhW5L8wRTH4Zz0htsEeFmMkuEo+bjXRczizDTMrV6tkiN869kNAqwynR65eaRGOZvlD6tQQuRDPLAMLvdlDyIpKdT6HSxKdacUwx3whwAiNdm2wi37+LMCE1Ri55As4dJigtyp5UM3G84msUOv9PfVCfRjXQGRul62UqXNskohARwQ== 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: Some DAMOS filter types including those for young page, anon page, and belonging memcg are handled by underlying DAMON operations set implementation, via damon_operations->apply_scheme() interface. How many bytes of the region have passed the filter can be useful for DAMOS scheme tuning and access pattern monitoring. Modify the interface to let the callback implementation reports back the number if possible. Signed-off-by: SeongJae Park --- include/linux/damon.h | 5 +++-- mm/damon/core.c | 4 +++- mm/damon/paddr.c | 2 +- mm/damon/vaddr.c | 2 +- 4 files changed, 8 insertions(+), 5 deletions(-) diff --git a/include/linux/damon.h b/include/linux/damon.h index b85eae388f5b..da003173210f 100644 --- a/include/linux/damon.h +++ b/include/linux/damon.h @@ -529,7 +529,8 @@ enum damon_ops_id { * @apply_scheme is called from @kdamond when a region for user provided * DAMON-based operation scheme is found. It should apply the scheme's action * to the region and return bytes of the region that the action is successfully - * applied. + * applied. It should also report how many bytes of the region has passed + * filters (&struct damos_filter) that handled by itself. * @target_valid should check whether the target is still valid for the * monitoring. * @cleanup is called from @kdamond just before its termination. @@ -546,7 +547,7 @@ struct damon_operations { struct damos *scheme); unsigned long (*apply_scheme)(struct damon_ctx *context, struct damon_target *t, struct damon_region *r, - struct damos *scheme); + struct damos *scheme, unsigned long *sz_filter_passed); bool (*target_valid)(struct damon_target *t); void (*cleanup)(struct damon_ctx *context); }; diff --git a/mm/damon/core.c b/mm/damon/core.c index d02a7d6da855..c6ccb4825c57 100644 --- a/mm/damon/core.c +++ b/mm/damon/core.c @@ -1523,6 +1523,7 @@ static void damos_apply_scheme(struct damon_ctx *c, struct damon_target *t, unsigned long sz = damon_sz_region(r); struct timespec64 begin, end; unsigned long sz_applied = 0; + unsigned long sz_ops_filter_passed = 0; int err = 0; /* * We plan to support multiple context per kdamond, as DAMON sysfs @@ -1568,7 +1569,8 @@ static void damos_apply_scheme(struct damon_ctx *c, struct damon_target *t, if (!err) { trace_damos_before_apply(cidx, sidx, tidx, r, damon_nr_regions(t), do_trace); - sz_applied = c->ops.apply_scheme(c, t, r, s); + sz_applied = c->ops.apply_scheme(c, t, r, s, + &sz_ops_filter_passed); } damos_walk_call_walk(c, t, r, s); ktime_get_coarse_ts64(&end); diff --git a/mm/damon/paddr.c b/mm/damon/paddr.c index a9ff35341d65..3530ef9c80bd 100644 --- a/mm/damon/paddr.c +++ b/mm/damon/paddr.c @@ -477,7 +477,7 @@ static unsigned long damon_pa_migrate(struct damon_region *r, struct damos *s) static unsigned long damon_pa_apply_scheme(struct damon_ctx *ctx, struct damon_target *t, struct damon_region *r, - struct damos *scheme) + struct damos *scheme, unsigned long *sz_filter_passed) { switch (scheme->action) { case DAMOS_PAGEOUT: diff --git a/mm/damon/vaddr.c b/mm/damon/vaddr.c index b9eaa20b73b9..a6174f725bd7 100644 --- a/mm/damon/vaddr.c +++ b/mm/damon/vaddr.c @@ -655,7 +655,7 @@ static unsigned long damos_madvise(struct damon_target *target, static unsigned long damon_va_apply_scheme(struct damon_ctx *ctx, struct damon_target *t, struct damon_region *r, - struct damos *scheme) + struct damos *scheme, unsigned long *sz_filter_passed) { int madv_action;