From patchwork Mon Jan 6 19:33:52 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: SeongJae Park X-Patchwork-Id: 13927788 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 7B26DE77188 for ; Mon, 6 Jan 2025 19:34:27 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 88BF36B00A5; Mon, 6 Jan 2025 14:34:18 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 83CD36B00A6; Mon, 6 Jan 2025 14:34:18 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 6DC276B00A7; Mon, 6 Jan 2025 14:34:18 -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 486076B00A5 for ; Mon, 6 Jan 2025 14:34:18 -0500 (EST) Received: from smtpin08.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id 10978AE6F0 for ; Mon, 6 Jan 2025 19:34:18 +0000 (UTC) X-FDA: 82978028196.08.AD25F16 Received: from nyc.source.kernel.org (nyc.source.kernel.org [147.75.193.91]) by imf20.hostedemail.com (Postfix) with ESMTP id 75E2A1C0017 for ; Mon, 6 Jan 2025 19:34:16 +0000 (UTC) Authentication-Results: imf20.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=gAYIhQk+; spf=pass (imf20.hostedemail.com: domain of sj@kernel.org designates 147.75.193.91 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=1736192056; 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=pR5h4DC6BpAl2A1XklNIIg7rh2vXbyRzmbAD51vFfQQ=; b=eE+MbvxKh+QYtM6kRjUQz52iZA5+Ps52Yqjby845DRwwtFtdJY+A3NBMKAgOF4v9SVkibg dkKDugtXwHbfQgyXHaVgyeAfcMVtIbcD1Eup+ytSGoli3jIV+fUtgaSC3VmfSJSyFoB+1L /LdHs7AUB4virQ86AOmmTyGVYxIvWJQ= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1736192056; a=rsa-sha256; cv=none; b=cZMldAZ35MuOMoJOdL06aMiXVQhuFwYozReIkf9K3aIFn02hAXWjhTbT6Ji1k77rZB0+fa 8tmLh2e6QF2P2YtNym5QN7tYGUgNRbnAQKPmh2+ZuUjwq8Gwb4PLaxXn6jq9BdOfDbC8Lm rOIoAYb9sOgcLfH7Ki8+RQ+jqbx8wTM= ARC-Authentication-Results: i=1; imf20.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=gAYIhQk+; spf=pass (imf20.hostedemail.com: domain of sj@kernel.org designates 147.75.193.91 as permitted sender) smtp.mailfrom=sj@kernel.org; dmarc=pass (policy=quarantine) header.from=kernel.org Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by nyc.source.kernel.org (Postfix) with ESMTP id 0DEBEA418F5; Mon, 6 Jan 2025 19:32:27 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 66CE4C4CED2; Mon, 6 Jan 2025 19:34:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1736192055; bh=2LH1SS+mcAmlUxCwzoptXsvLS0Q9wTfZdyaAciByRN8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=gAYIhQk+ZNsHH1AnWzsQzrhkNcdktCCWYi8JwOkrZT2ipR6JsnMpZyThIUdGJwJJ2 m/6qUBaDjKqS5CPI3GgUipsWQJVyTRunXGG7Fi89wrukN65NVpMsLW31CPl+qnHozZ GkvF8Vx1AJIjOP0tsLZtYWeWpcPtc/BTrTkEyDlCeeR39HCLh8u4jQdIie0GAXynQC yNg8FYT63DxRJa5SY7VV/4CVV/0ELLoPG1zaTNXYuPGa+uaCSSWHAqxbrEIh0+5ZwI c3ZyQq5uE1liDUXvdmCx443KSGnIyAm6JvOsVQNTgsNepYr0TPkMc2rr+0ZSy/bziT Y3gfvMfiLQJ6A== From: SeongJae Park To: Andrew Morton Cc: SeongJae Park , damon@lists.linux.dev, linux-kernel@vger.kernel.org, linux-mm@kvack.org Subject: [PATCH 07/16] mm/damon/core: implement per-scheme ops-handled filter-passed bytes stat Date: Mon, 6 Jan 2025 11:33:52 -0800 Message-Id: <20250106193401.109161-8-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: 75E2A1C0017 X-Rspam-User: X-Rspamd-Server: rspam07 X-Stat-Signature: 8743uc7jqaej1og9ufayieqyf55m6p4f X-HE-Tag: 1736192056-640559 X-HE-Meta: U2FsdGVkX1+25lZyP0QAKkj+bSwHduxn5kSuiJKl3NW6r1OODVZfgy9OaRFV43ShxPdNK/MkBwp0Eg6bI9YQl3iKT7Eb/hIlSIFKlz+p3Atf9cvy3JLSUWLQ+zjHHIzJ3e3BvNp0gU576Y9pDb5oh8zmWfcrBWFz77byppM7YeXs6OwH49sNIFY2d8Sc19/ArpQHeZ6+p+cu7CwJ0cFRzRgFVx6Xf5g9WZV9x12nfXN+F+2X7k0H3enfOVvANUCeEjjT9RywqoguFCYD9xnuQIhZC1Ewgh6Ec+n61cve+KC7yRJwOr6pIFq/Ox4WYMjIAVS/e9ntulgbG/GoRQ2hgWyrMfSyvN99F4in7KDaD3xpdeRyj+Lsx/rydtS6+bfzpyO8D8qyEen2xmAILOVWUkjQweMKT9TGjgI2MQ7K4FmpHu3rAwCP1NJ7FIZtusTedXj43Nzu5iokmmjFyp4IH5gGzdLwZiYvtbYe7M8OONjZNyjwARiqm6YT0rKKYstWnPJ+mGLCw/IfuaWWeyU1fvH8N3MxhrH5Qk0Brdn0hvMTEY1CnQFFMGDIehWzSP6hiXvQ9bWBMPFPgEWUlbWBBtyMbEpCV/Zm9urgU+h3G6AcBT4p2r1FuY61RJMGd+4TbD3fD3yz5Ch82bfYw7TbuRld+oqREdyiVqBwIj2tMH2YhMCZXLLdMFyrAbPU1LYyjshVm6qAXm9L2GR9HhxKGmRDsaBf6/4eeuQXMFd9P6UqqJ7FL6pa97yTYWl90CFjcRPqn2WbJa8k1K1rCPpLmFD+SFyyopPHkwNr99+oNNhZGIPI8vU5A5fbC8hCzhzSgDVoRF8RPEp+8c+5/YRlIJrz/IICrbkC8HeKzRH4sxf3n0je1ZEX9zT97YIftj0ESvC0Ah9bFWrSpmY0DvBc4zP47XfTfaq66TKYT5+sMAK+VtoSalE1mDrmZfTyZMHYYFqf0Ifxg4FLFbCzvyq NWZ2tvam cvwnKMicMuzNogg6Vp9VhyeT89OZNg5j/QGxeW5+lGS2TOvXugzXuJnaC0p2DcRyivG2BhUGCrggI+LrjzPwFXSCVtCaWfImTdLcdznJu0r0JtChXF7yUXVKu7ZIbQCLHN+nIIiwPjnZsuQg+Ewn9eN1IVs4mCRTezhHZ1+9L+9HszaK6Xlcsilbiw0fJcS1cVdSTKphvMX6KHdlS/shfOk1aSluzsjaRoFwV8kSUCoRpM1Q= 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: Implement a new per-DAMOS scheme statistic field, namely sz_ops_filter_passed, using the changed damon_operations->apply_scheme() interface. It counts total bytes of memory that given DAMOS action tried to be applied, and passed the operations layer handled region-internal filters of the scheme. DAMON API users can access it using DAMON-internal safe access features such as damon_call() and/or damos_walk(). Signed-off-by: SeongJae Park --- include/linux/damon.h | 3 +++ mm/damon/core.c | 6 ++++-- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/include/linux/damon.h b/include/linux/damon.h index da003173210f..2a93dbe06ecc 100644 --- a/include/linux/damon.h +++ b/include/linux/damon.h @@ -286,6 +286,8 @@ struct damos_watermarks { * @sz_tried: Total size of regions that the scheme is tried to be applied. * @nr_applied: Total number of regions that the scheme is applied. * @sz_applied: Total size of regions that the scheme is applied. + * @sz_ops_filter_passed: + * Total bytes that passed ops layer-handled DAMOS filters. * @qt_exceeds: Total number of times the quota of the scheme has exceeded. * * "Tried an action to a region" in this context means the DAMOS core logic @@ -310,6 +312,7 @@ struct damos_stat { unsigned long sz_tried; unsigned long nr_applied; unsigned long sz_applied; + unsigned long sz_ops_filter_passed; unsigned long qt_exceeds; }; diff --git a/mm/damon/core.c b/mm/damon/core.c index c6ccb4825c57..c4ce72a86d81 100644 --- a/mm/damon/core.c +++ b/mm/damon/core.c @@ -1362,13 +1362,15 @@ static bool damos_skip_charged_region(struct damon_target *t, } static void damos_update_stat(struct damos *s, - unsigned long sz_tried, unsigned long sz_applied) + unsigned long sz_tried, unsigned long sz_applied, + unsigned long sz_ops_filter_passed) { s->stat.nr_tried++; s->stat.sz_tried += sz_tried; if (sz_applied) s->stat.nr_applied++; s->stat.sz_applied += sz_applied; + s->stat.sz_ops_filter_passed += sz_ops_filter_passed; } static bool __damos_filter_out(struct damon_ctx *ctx, struct damon_target *t, @@ -1586,7 +1588,7 @@ static void damos_apply_scheme(struct damon_ctx *c, struct damon_target *t, r->age = 0; update_stat: - damos_update_stat(s, sz, sz_applied); + damos_update_stat(s, sz, sz_applied, sz_ops_filter_passed); } static void damon_do_apply_schemes(struct damon_ctx *c,