From patchwork Mon Jan 6 19:33:51 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: SeongJae Park X-Patchwork-Id: 13927787 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 E1959E77199 for ; Mon, 6 Jan 2025 19:34:24 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id B4DF86B00A4; Mon, 6 Jan 2025 14:34:17 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id AD4096B00A6; Mon, 6 Jan 2025 14:34:17 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 8B1F46B00A5; Mon, 6 Jan 2025 14:34:17 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id 6616A6B00A3 for ; Mon, 6 Jan 2025 14:34:17 -0500 (EST) Received: from smtpin28.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id DEEFB80292 for ; Mon, 6 Jan 2025 19:34:16 +0000 (UTC) X-FDA: 82978028112.28.15FD7C9 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by imf29.hostedemail.com (Postfix) with ESMTP id 4F6D5120006 for ; Mon, 6 Jan 2025 19:34:15 +0000 (UTC) Authentication-Results: imf29.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=YGjmLeiU; spf=pass (imf29.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=1736192055; 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=g71QxxRLtmP+EXQFUXo44lgeKTrfyrK5oGSS4WBhddU=; b=lHKY+nJ5djhKU3thhe4zYs7REMC7VPoyaK7AF2f4pPNKl+1r1N37vhHjxzbPyTLjj4WW6H hFKCpYZyhZIEt6Sc1aWaYH9cNi6HrdKLpxDXe9XigaAypPOgZV1pzrT06V1zBIQyqNvQIL Ay5f/yyKCXbt0HyZZ6IAxbvUAAmZOvo= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1736192055; a=rsa-sha256; cv=none; b=ieATX3qAt/cyH4V/DP/Cl5GMmbSJH2qD9H0EuWpKKXS1FY4DCh9Ua4zlMmQFx0CfXS26/o PysVPP3GQY70QumM4MSWbSpdcg1RhMy0m1TVfUWGAdkWpHpMF2n7vMyV05JHwCbb/qih+p G7LDIlkIPYk29ykU1+fkxBYfodnIMS0= ARC-Authentication-Results: i=1; imf29.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=YGjmLeiU; spf=pass (imf29.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 Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by dfw.source.kernel.org (Postfix) with ESMTP id 787465C503A; Mon, 6 Jan 2025 19:33:33 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 3EF43C4CEE1; Mon, 6 Jan 2025 19:34:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1736192054; bh=g81jBx5R64ofCs/+zCq5N7Um6JZR0CPZvNzSfSj4qFY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=YGjmLeiURNXmHa2AE4peDuREnuTW8zRsFNpulcMswaELc6PGc9Thi5MSy4pRcfEzn prnaEukjxB4D2DBQAqTf0n6CLUxIb2pnX8x4ylZ4KCCPuJPq5STZ0By3fzSMwpjBA2 kxXFjcPHlxZqKc6Xf1DNVnauc8ZNUSUh7Qr2wUZvcklzHpPmy4Dxf5qEpt0Uo5r7zx y9kZng7r2YoCsAMCI5ulud68kZpexiwHJkwhRgiGByRa1kVWNtkgQ08Oohzh9NOXou T5uHsUNn4nhnGX/zzC9QsM5FA9KXZdf+iMcfG6jeZNwrFbWLWGQu7yjSMrVnStIHrw h+QOw4chsZINQ== From: SeongJae Park To: Andrew Morton Cc: SeongJae Park , damon@lists.linux.dev, linux-kernel@vger.kernel.org, linux-mm@kvack.org Subject: [PATCH 06/16] mm/damon/paddr: report filter-passed bytes back for DAMOS_STAT action Date: Mon, 6 Jan 2025 11:33:51 -0800 Message-Id: <20250106193401.109161-7-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: 4F6D5120006 X-Rspam-User: X-Rspamd-Server: rspam07 X-Stat-Signature: wowy1gj6exandfh4z79ah54eeo5tqwnt X-HE-Tag: 1736192055-609691 X-HE-Meta: U2FsdGVkX1+L0yNpS2wxjSmbFYAlt/liOHkREWZTXGPNvD7cDvlOhulaNLtlU3aE03KJJ5KQ2HLRLTf12I8WW3/wI1Az7/erAeYQvH/ExB5wbohbXdSdt2Pza2HIaj+7a7lwCJtJvxnCzyG8PEAqO7aH5g9undzRoRNZsZ2ZCzcgVwez0Ty30zxnju+q9OCH9GzQhxni9GGCs2e85uroZMA3tC89L2AHlgIhv4gBT+dR3JkZiWW/CBJ7Vo1NeInzT4nhWoCNAwq7uaMBIaSMkwn+wLVGeMYF7QVBmyImlg819WexVC/9znXak6jnFKs/9pYYfGNpYFw9J3sL7KDVg4AAwFlk2BhEo6V7836m5qzpMUBMZn0IqfrUPVPEf7e2qZLpm/0LpQhl4QsmzFr+KncvEFaZGEBfNJLiTm8Pz7/uGzXobTxXCr0V3+3PMQhX80w6tNFMCI8HbOK1SpMa6JpLSRijrKm83tN9LvTODMRpCpyRTSyL24ApH/vs3H2eCF5/ig1ZEJ1F6gP2QG9oV4Jf73aZz2d3dKHK0zDOVPIHnNW/QTg1rb1ybUDLj6Xgrxnx5ZOLyduvn/YDpvW8CqbvdSilkiEOB8vqzTB9DLi9sb5sYZGUcWwUVIWOSaU4aCCelU1dcvjpstYnV8Fg3pF7ikUj1A1LO+LUlkBgUi8TF9KVjE18rEN6/qqHRn0HGO+7ut5bbzBzyHxR4LZkY8DZXCpyXMMM/TOLg05LDBL6hSPCUOglpc3k9sOTiaPcm8/+gRmgy1G5HJtLxH/C8JKemdV43rcsT2M+rDY6NV5ghrWAzykw0iC0poDa69bElmeqs1iyrPzww6RNTgYVBGtfId+TOJl7B6kVNiw2H2LRrU7vCP96dUmj+yssA20EBbvfq8oHZnP5tj+NdCzbg04k70ns9tTcc8YsoLv8uQP0rKZIxelI/vQaCa4gjLNQK0MEPN5e7FAbVnrlwl3 wBY6k8W1 E5B3OVDEwVhhP4Dzj68OD21wHllxd1wUjnGJ/i9Cb3qEKzYpqGHx2AXj6UWe+oO77L8M++uCRl06qXrm/MJmiWL5JhfQ1ASkTlj8xqCOXw4OVOku0dLG1bGl7mJey5lZLrPVcW0GaLfssAlTFkiH7vX0NnSr+qKCMDaO0p+ooGn1ppNsx5Th6KHLMExOfhjYUtnOqE8mSSwwjhHVFMuKHu7y2c6fZVttwicZggqI48NVwb1Ft9R5UdgfJ1BgJdlvT+J7OG8To9KHKs7ohScT3EnQp2A== 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: DAMOS_STAT action handling of paddr DAMON operations set implementation is simply ignoring the region-internal DAMOS filters, and therefore not reporting back the filter-passed bytes. Apply the filters and report back the information. Before this change, DAMOS_STAT was doing nothing for DAMOS filters. Hence users might see some performance regressions. Such regression for use cases where no region-internal DAMOS filter is added to the scheme will be negligible, since this change avoids unnecessary filtering works if no such filter is installed. For old users who are using DAMOS_STAT with the types of filters, the regression could be visible depending on the size of the region and the overhead of the installed DAMOS filters. But, because the filters were completely ignored before in the use case, no real users would really depend on such use case that makes no point. Signed-off-by: SeongJae Park --- mm/damon/paddr.c | 35 ++++++++++++++++++++++++++++++++++- 1 file changed, 34 insertions(+), 1 deletion(-) diff --git a/mm/damon/paddr.c b/mm/damon/paddr.c index 5944316a0b4c..b0c283808ba6 100644 --- a/mm/damon/paddr.c +++ b/mm/damon/paddr.c @@ -485,6 +485,39 @@ static unsigned long damon_pa_migrate(struct damon_region *r, struct damos *s, return applied * PAGE_SIZE; } +static bool damon_pa_scheme_has_filter(struct damos *s) +{ + struct damos_filter *f; + + damos_for_each_filter(f, s) + return true; + return false; +} + +static unsigned long damon_pa_stat(struct damon_region *r, struct damos *s, + unsigned long *sz_filter_passed) +{ + unsigned long addr; + LIST_HEAD(folio_list); + + if (!damon_pa_scheme_has_filter(s)) + return 0; + + for (addr = r->ar.start; addr < r->ar.end; addr += PAGE_SIZE) { + struct folio *folio = damon_get_folio(PHYS_PFN(addr)); + + if (!folio) + continue; + + if (damos_pa_filter_out(s, folio)) + goto put_folio; + else + *sz_filter_passed += folio_size(folio); +put_folio: + folio_put(folio); + } + return 0; +} static unsigned long damon_pa_apply_scheme(struct damon_ctx *ctx, struct damon_target *t, struct damon_region *r, @@ -501,7 +534,7 @@ static unsigned long damon_pa_apply_scheme(struct damon_ctx *ctx, case DAMOS_MIGRATE_COLD: return damon_pa_migrate(r, scheme, sz_filter_passed); case DAMOS_STAT: - break; + return damon_pa_stat(r, scheme, sz_filter_passed); default: /* DAMOS actions that not yet supported by 'paddr'. */ break;