From patchwork Thu Dec 19 04:03:16 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: SeongJae Park X-Patchwork-Id: 13914448 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 9F1DAE7718B for ; Thu, 19 Dec 2024 04:03:58 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id B3B526B0095; Wed, 18 Dec 2024 23:03:49 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id A8F936B0096; Wed, 18 Dec 2024 23:03:49 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 927FF6B0098; Wed, 18 Dec 2024 23:03:49 -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 71EE86B0095 for ; Wed, 18 Dec 2024 23:03:49 -0500 (EST) Received: from smtpin16.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id 3B13312109B for ; Thu, 19 Dec 2024 04:03:49 +0000 (UTC) X-FDA: 82910364348.16.FF6C361 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by imf30.hostedemail.com (Postfix) with ESMTP id 6245480007 for ; Thu, 19 Dec 2024 04:02:45 +0000 (UTC) Authentication-Results: imf30.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=LLwCY7XC; dmarc=pass (policy=quarantine) header.from=kernel.org; spf=pass (imf30.hostedemail.com: domain of sj@kernel.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=sj@kernel.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1734581012; a=rsa-sha256; cv=none; b=ht2w+ukdiQdQSiIR3PTyH82YxX+Eynj7fCUD8yQZ9avHiOnd16r1uBDFSobqk3vRud/CgW m85i4tfDF28I8/wOHNqtOFGU8g6Aia48OLJ+RJ3zZnz7yq1Df1zXgmpsZIFCJT1qhIUlFa pJDMvfNV1vGA+PCfiOv7/e/8bxJ74Ys= ARC-Authentication-Results: i=1; imf30.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=LLwCY7XC; dmarc=pass (policy=quarantine) header.from=kernel.org; spf=pass (imf30.hostedemail.com: domain of sj@kernel.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=sj@kernel.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1734581012; 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=ry9mD2QkDiun4VCTmB90Ymzq+2NDMvQYWdeKqnhReVI=; b=vXf+GgQt4Duyv8Hdd6O2Z26JuFd2XTuGhc0ysSdz2DXr5J25jpvnGA2KEv4ewKlDAMpSZa lAnOse6bXI9zI4W9NapOGFH7Eu/JkFr8uyyGkbCJIaR23nBUsN/kb8APxrGyx0WvttgGbv AcH8iZvCI+0zsx0sNbz+yrLoPzx8o2w= Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by dfw.source.kernel.org (Postfix) with ESMTP id EE0485C65E6; Thu, 19 Dec 2024 04:03:04 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id A3310C4CED7; Thu, 19 Dec 2024 04:03:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1734581026; bh=v/ZiBRKbfbEykvCZNndO3AyZ9fQawvkE+ZCwqKdxiC0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=LLwCY7XCrXKLl9hrAIUoT8AM3rD7urUs/LxhpOgzcOc44OGsZAqdYBpczJLDfhqQd Ugn8zdzXuyFUXipe/UpgChq1b7JY/NSSHKYsY68x4fZXAormDkhvVroMcIe/ddmgPk D5agXjvf1pgf4EYBd60zHJfO5mxdeXSSJmE5+Y8ed9riJ927yCogDgGJb799JENyTg 3r74323OuSU6EHo5GhuZ/lCwdOUEnyVMddvXdn/N+WZKizVT590zkYNkgQURdZIeMk DD92sALUgMeLD5Zl1PeFhKkK30JIS8Ms3XQIYkLfaPg6jF/Hh3ZXtVFtLlWNZwSfTA r57yPAYktc80g== 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 07/18] mm/damon/paddr: report filter-passed bytes back for DAMOS_STAT action Date: Wed, 18 Dec 2024 20:03:16 -0800 Message-Id: <20241219040327.61902-8-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-Rspam-User: X-Rspamd-Server: rspam03 X-Rspamd-Queue-Id: 6245480007 X-Stat-Signature: ztbsn89qyrcnu8d35eu9y98szjq8gyj3 X-HE-Tag: 1734580965-495915 X-HE-Meta: U2FsdGVkX1983LhcNEmNIEs48uL/BOB+2ywk+nDhQunjtT4S264BonPqiXDUglyNLZTMXp0ObSBh7tz2praDBpfVPVnhRM+1bwd8gzJ5WiHBLMb6lFpJlqD2612BwdtaXAshOhrEFDnvblRZKgUByFDKAEK/Fref3Xklytzsk1o92iF76zYz/d00x1+MZoZF+Wh7/4Bo3GikFcxSwvzu5DEmuPl88Pat1toqVJpNKyE9q2D+Vf3CslRx89RvFb8UFYCGg38VUNynoaISlZHPVwEZ254+/s9Co203KmSzdIVpABWIkB1Cj89WHBVuolWnOIOvKl6cg5+Miq47UHE17GHicfOqYWtdKB2hB1mqZvi9rXpcHCHU0iT4C5LlvAVuHzZkh27FTbTPg8K1KM8tLPQ6VLTwEs9ksbco9/HLoyMqNoObc9PZMaQ4Eaxi4xQ4NMG7+NFp8b8niC2IK1gjxWESx54QQbc8jv11wOLtIEuFMph7QWaiMG+Qd78OSLG96//w/4Gt1Jz7BQLPUKm2ZSDhT44DqXI6KgxIrcFpTRXmtSsVC5nvdUw3OgidXKlaYrGeFgZRB88G/2OHgoVKq472Q/Ni2eMNkB7XjAYGtnQ1OmeWEUlyFEY8cvdICoO5fZJfx/9WB4zbkDucaYMp4PMt0oWflnCDZXAsHg3zg7Vj0annn6Ai+/eMzPamIgca01yNMZO95jhHTW9Tsri835D5PtsoGz9jXUYQ0fmKpi3WkfAvKqhzjE4RzZ6CsxjKrwiWjT1So+nf1fZT9Hoy31aDOR8gXa7MbNpoi6RhVtA449/8sDYfG/1kczESXtKpf+soLs4/Qzy+1txo0Q/i9Uu/jCD1qcsRXHCoN/0YYbUfYXOFMLzjYv18NJboHOCFKm/tNA1cagURFEG12uucmkYd6N/SiP+CHBuwg0r41XKQEfwXC/3/DDbXO2X3goaXAcd7euWXml+JcROn9p4 z/333Np/ v6ebqZam4i8L+6czmtE0Ehc3g/YUfRpZhmoxC0V8mXt2LvPZkGvhibCNJaeRCu0sKiZ5HanRIBqj1c+zWVmv/p7eR3dEC5cwdx2gmshnzyMPDRmfmlRWLgRimKapo40D5csSl9YxRpn6gFVWJZOqxwRxI5l/Urye5dq923U/ywaLEiBKpvrKK1PHsGmjJePs5kchYuehZ8cGRtaoUaV43Qjh3qFOHkj4D3gK7RcwJzxdDC+6cx269m+q3Uk3Z521n30mRIYLf16+dfjk61qeZbdAO0g== X-Bogosity: Ham, tests=bogofilter, spamicity=0.000005, 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 filters, and therefore not reporting back the filter-passed bytes. Apply the filtrs 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 filter is added to the scheme will be negligible, since this change implementation avoid unnecessary filtering works if no filter is installed. For old users who were using DAMOS_STAT with 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;