From patchwork Thu Dec 19 04:03:17 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: SeongJae Park X-Patchwork-Id: 13914449 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 0BE48E7718A for ; Thu, 19 Dec 2024 04:04:01 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 0EF026B0096; Wed, 18 Dec 2024 23:03:51 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 0084C6B0099; Wed, 18 Dec 2024 23:03:50 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id DE3716B009A; Wed, 18 Dec 2024 23:03:50 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) by kanga.kvack.org (Postfix) with ESMTP id B716C6B0096 for ; Wed, 18 Dec 2024 23:03:50 -0500 (EST) Received: from smtpin03.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id 81F2D1C8358 for ; Thu, 19 Dec 2024 04:03:50 +0000 (UTC) X-FDA: 82910363466.03.52CB7F2 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by imf24.hostedemail.com (Postfix) with ESMTP id 95BE918000F for ; Thu, 19 Dec 2024 04:03:44 +0000 (UTC) Authentication-Results: imf24.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=DBmQQXmZ; spf=pass (imf24.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=1734580998; a=rsa-sha256; cv=none; b=U4xv1PNFhms4dpjWwn8ZkBMtmxArPTH7phYg9d0SAOL6A2i0FqAMhpGMXSuGdDyToc1J/J 1eqizHLChJ6JHyGwgTqH6nwjZJLcz5kLTPCUDRBZ0uTa8JFDQqe4VHI+CHi6JY2kKEpH6x hWLY+6HlT0l/UDwEFdhEw1f/21bakXU= ARC-Authentication-Results: i=1; imf24.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=DBmQQXmZ; spf=pass (imf24.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=1734580998; 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=oc1IgQR2qQmGhZfUPUK0JUYmgfSMjZ5sZN8URZ4MtOo=; b=HPg5pMw65/gHVknIqEe0vX5TOdg4/6Nw9XV2exx6vXLfMOJCR9QQplYGGwGHy94dVS9FsJ qwkN8Pc1M/KV2kgDuPDYWqxtCJiM+ThVfuTadiS39ZM9GFGDHlAlGbv555b9MSg400+VQx D7s5VXJKjuLMlVCRto5fj12SXcL4lQQ= Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by dfw.source.kernel.org (Postfix) with ESMTP id 259595C664E; Thu, 19 Dec 2024 04:03:06 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id D239BC4CED6; Thu, 19 Dec 2024 04:03:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1734581028; bh=64D8a6jEKpsztUjzJW7u7/dJMtao+tMWa0luqj3yM0M=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=DBmQQXmZIOIzv5rl3Sq/NBNabDLR6GahdM2WjV4Ilu0m0t00lMHKeClh3MFv8z2Qy +sIXM5KGE/KBmNlWN7szTk8ucFGmzSRWp8Wmewl0/Dhr1A1vLEL2bd4D3I0LyRreVV PrZIr/PctZNuWPZwMzNxn/zrpr3E1Zh0DCtst3435UjDHeWAQqXByNN3HBUYKEsGZe aB3TtSjRyZ0CQeu1cC2u9vDYqYqB1jwW+cvNUqlTFIfG5cLuUknjpkaodwSKbfDIF+ FrQP77iHzd8QeOe7WMPUl0sHVFXFJjY3kPT+YAAcv5otXGHeHEE9jv1qgdrpJH3g/l wC8CNBbAKoWmw== 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 08/18] mm/damon/core: implement per-scheme filter-passed bytes stat Date: Wed, 18 Dec 2024 20:03:17 -0800 Message-Id: <20241219040327.61902-9-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-Queue-Id: 95BE918000F X-Stat-Signature: g6r7qjpq1j17a46y8au4sadr4oinbewy X-Rspam-User: X-Rspamd-Server: rspam09 X-HE-Tag: 1734581024-321675 X-HE-Meta: U2FsdGVkX190DzMz+QuZnb5j3Gi0ilx1JjTPyCcDZmbf/jxedaxxAq2uROC3WqVQ6wbp/MpoanIjxOT3v7NZ1tu7xYaPrPOJ81hK01eWzjpOwlfFggD/UdmHqwoLBOwO+4YPe3FY9h92p6McHR1aDyQmiuhOgvK/oivL3L79f7I44cezfSFX5wQTu0aHw9pYbVqMxywPK4ukl6AWvf98Mrm97JUKrNTIcZQcUiY5nvYp7A5hg9EBcGQIDjUnBw820jDaoqL/2TicckMzpZ9XK9uwOHKaOtn1JM/oLNpawKCGNb/X+RXy0F+otWjW0Xc0W9Z2Tw8G9RCxcpcc1dn/VRmPRt4Zp6F4iuyBHkUExotyI9QofngniU9AXaFbyPcfiS0nG8+TcfNjFLKhxeUvdHAp+baw9g3YnnfiC7b+Ad7ErGv4Pe4aP65GToF8JfoVeOv0naa/L3Hf6hoj4RD3oIIbZ7GFfNxcnlfAJL1uW2m6kMOMY8hlVhsdSCkru8Ooosi0aQ3xQNiJTCi6ju/DnPFxw4j2n6GOu8Q6A7HLghQF2+pbNBfxjWGzzwnmpS/z2N+bGAJbxm0snzv0UyIrsq+s73dSUVbow3pXDg+1A17Ya+rtS8AQOsf8a7Q2093vLdDzd+FCs32tLXPcEH2uMCJ54c8a4Mzh4jqYOAfL4n93zHf3b02ho6OHmWCZx2hf2mPwHHXTUgn69SIde+oaSshSg9VRQUpHtoPbbjVg6fL5vV0SGTioUusABeI7TL27r2k75pbKO8IO+BjjcE026UWSWvndrkFTZlblvXF1Wy9f7saYh1vLC9WbD1X+OoAIZz2NJ01vQwPt8iIYENd+JNr5XFizN5F6ncdrCo58+d3n25VHX2g1Mr4sZ+xFr7DK8XMIUvRWn1qZi6NA34YvydMdXeFv4lseLIB/QpQhd9PpqFYH7exVelnMuchZQFfMq4K3vexWxfn5J+XzxTQ u0INS6k+ VAf2mDSh3QIp4seRBdg3M4LTGjAqWuEKLhdiH7BHY9/Ppf/SjNkOlc9CVip2ry7QaU5qzB2cZQ/t9A37NiS24D00bjrHFgCwk5PCVSvAfcqCBJG95HDkUB1WFW2Z6AXL8tAQLRyU0Btl+M2tJ5dkRKe25qNWAs8x/I5/miDviWc7jji3vr0uhBjrFTa9vnVsR7grGkMXpDH94mSS5e6PZ69y6so8Zzgx7magIwZUhk7SDjsY= 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 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 bff39c23f16e..4a68bb38aad5 100644 --- a/include/linux/damon.h +++ b/include/linux/damon.h @@ -291,6 +291,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 @@ -315,6 +317,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 c7ae95d6b7ba..8540e8f91260 100644 --- a/mm/damon/core.c +++ b/mm/damon/core.c @@ -1354,13 +1354,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, @@ -1580,7 +1582,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,