From patchwork Thu Dec 19 04:03:14 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: SeongJae Park X-Patchwork-Id: 13914446 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 B6B49E7718B for ; Thu, 19 Dec 2024 04:03:53 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id CD7576B008C; Wed, 18 Dec 2024 23:03:47 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id C868C6B0093; Wed, 18 Dec 2024 23:03:47 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id B23AA6B0095; Wed, 18 Dec 2024 23:03:47 -0500 (EST) 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 922D26B008C for ; Wed, 18 Dec 2024 23:03:47 -0500 (EST) Received: from smtpin25.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id 4A9E71C7E33 for ; Thu, 19 Dec 2024 04:03:47 +0000 (UTC) X-FDA: 82910363592.25.41E3529 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by imf23.hostedemail.com (Postfix) with ESMTP id 02D5D140006 for ; Thu, 19 Dec 2024 04:03:23 +0000 (UTC) Authentication-Results: imf23.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=iTssS2WH; spf=pass (imf23.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=1734580991; 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=wGRTTw/mPkqf354FJQdjzpd4vfVVMZaisaA5YWT1/Aw=; b=DgIkVc0maYzdo4aHxM7m588uQjf+pirCDb2L49B0mLhNAoYaePmWFClMi8aKMfifdVs5Fx wgxySRFQPp1Kh9QDUDnZ65WEnEhqf8Mz7jpqN6S+VD/7nddTfZ+6uEIzPSa3A3wMrC6UlT /ESPxIVbxdaSfJxu+ZKzqtqor7R7gwo= ARC-Authentication-Results: i=1; imf23.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=iTssS2WH; spf=pass (imf23.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=1734580991; a=rsa-sha256; cv=none; b=0NZ5ukzcZojaIGW5aIaOzUQAAFqBQ7djiBM7Jt0lxXllfLb99CBfckq//rFguYkZAkjaq1 o+viIJ9Qn4D0mqupzlB4zO1g/3CjZsPBR6rFPzV9vqxm7UQyelPxlhrcn4mgV1p+SgzvJq 3wYhvWv4X7l3M+kxo5qlomfZS017Lq4= Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by dfw.source.kernel.org (Postfix) with ESMTP id E45A35C6633; Thu, 19 Dec 2024 04:03:02 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 75B53C4CEDC; Thu, 19 Dec 2024 04:03:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1734581024; bh=cxxjnWzTe5muZlyce9kFDTQgXHn3SHgY8i5MGv2pqZo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=iTssS2WHa66nMxFXS8zkggEJKRiPlZhTv/5Zpsv2QxVDqaGQA7KH7vHCko5ztski9 OQUNAnp+dZB4iXhLf91mAESi/UjJPsCHf4hm4oa1aKv1fZAKrw9imbq2C4AJAtGHhn Pm/XbpgXz8TKmBurz16QCq4Iko9WWZfU8KDyx6Kf3KCT+3PCt/3dkZr9aao31ut32R ZNNjgsBhnwvAgruO6gbWm+XvlSl9FNcTmXLF8GJ20Hbig3tVW6ccrAgQlVF5ZK+h7D ACT0lwhXKmci4+z4wTfVMPehGxkoulRuz6U+s9TYHvbrQdbCjCJ38PdPnuMPI2r3F1 jLOzvmSj+I2bg== From: SeongJae Park To: Cc: kernel-team@meta.com, SeongJae Park , damon@lists.linux.dev, linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: [RFC PATCH 05/18] mm/damon: ask apply_scheme() to report filter-passed region-internal bytes Date: Wed, 18 Dec 2024 20:03:14 -0800 Message-Id: <20241219040327.61902-6-sj@kernel.org> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20241219040327.61902-1-sj@kernel.org> References: <20241219040327.61902-1-sj@kernel.org> MIME-Version: 1.0 X-Rspamd-Server: rspam06 X-Rspamd-Queue-Id: 02D5D140006 X-Rspam-User: X-Stat-Signature: p5qjicudxa1d8r3k4o7uir35gqy61ynw X-HE-Tag: 1734581003-568792 X-HE-Meta: U2FsdGVkX1+7KvceKTRME24ccOesJG7sOlnvNG5rRaYzSn1J2eW6I0RUIesK/k8dr7+ce3H0B5FJp0vmKkXSfFCOy9fYh3OWdPwGbSnWzQWsUZBnqhc9ppuPfeVvRlLEBq7r9qJ4EoQs44awTdt+Jl5SS3giCcfCCHSBtawFijDiTP/6CXXFrv5q8ymlQ3YMPL2da6+IbsgU8Z5yyxlakidTila0f9twpxSmCXKmk3W+tek/NhxtkalMYiFeMLnczv55+jK4jENhjROYE53iPgXY9FDEe1qoci17Vim+sHj/TG18Lbkhrsti86hx4y8vQUlL7e5lEufSClNcC2xHWC9sfmP+hY7mzf2TB/ODi/l0Kr9k4kHK+P/2IrlhmipMV1ayTVotc1C/8KeLw0o1xPgVnY/0IZ8j3sywdsHHmiMWYSp4remQj3wNN2bNOlO5aG3njrKR3y4Yt+MKtsDGlnkd2I6IfCnjTQKcY7thJUaLSlBnO+eiJ35AjjNDumFybNkERLw1uw51bIq+/23VJTakZczmxCPua4SorkUQdX9qqKDMIxz2y+aMrltW/+CWJCJlHKNcYKal4fDecLJU6w2eSdzBuNnX1F4eRFw+Rrww/mZukCLw3e+PuTPSAWbY1YrToLRvq8fbeIQ/wyngcR/5061XUpTifkc04Vndni3XLMf39CGkHfvyXrSLrfyYkEoWkfmHGSbOxS/EWYKNqmjIQWSItWP4zcsoCMIYPKMpBn3inDKy0WJJgi1A45oNxA3I/PnqXQVr0N6enKJUt41LGgN1al29B5yVXVN3MLqAB4JsTkPZ15lkRKi03ShaV1Dp9MQBKRS4vanj+dXLHbXTXUMV1BaScc3spcKFBMfhJk9FGqQ1YZItOtqtvge40LCjTnuatTXwltWZSwsIA3t70uEFuVZ+Lt53nBUBToyGa1YbpV6lllgOb6cnC9dSmEhbBm8yH7OGCRvyys8 5f5wVr9N juFB5KQfqB6YwvReIR7LBz0eDOThNasICL3+uehuRDc1hDotwl0hhhnOR0lzdIjfEXsFYYer4nLP7qurzgPRwZKFLxiA/DAYxUolUZXltxOclfDg5ZR6ZZDosDxcERd3eRALo9nUAd5zbHeI/vuzLCOeZTkg/31/jQXzMVD3Y4+ksLTbjZM5XGKptQ19cq/hlO63R8+nX4OlPEUDMF8QYC/UCZiGTCkMWIEqtNQrfDkBCWzSUTobU4XYkjACLZ6p//pdKi5s53agCU4v6hdjnobXNxw== 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 f66fa0ab9350..bff39c23f16e 100644 --- a/include/linux/damon.h +++ b/include/linux/damon.h @@ -534,7 +534,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. @@ -551,7 +552,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 d8c223954996..c7ae95d6b7ba 100644 --- a/mm/damon/core.c +++ b/mm/damon/core.c @@ -1517,6 +1517,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 @@ -1563,7 +1564,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); } ktime_get_coarse_ts64(&end); quota->total_charged_ns += timespec64_to_ns(&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;