From patchwork Fri Dec 27 21:08:12 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: SeongJae Park X-Patchwork-Id: 13922137 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 6F944E7718B for ; Fri, 27 Dec 2024 21:08:36 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 7AB3B6B0085; Fri, 27 Dec 2024 16:08:33 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 752A16B0089; Fri, 27 Dec 2024 16:08:33 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 5D7296B008C; Fri, 27 Dec 2024 16:08:33 -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 41E6C6B0085 for ; Fri, 27 Dec 2024 16:08:33 -0500 (EST) Received: from smtpin22.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id C784F46B66 for ; Fri, 27 Dec 2024 21:08:32 +0000 (UTC) X-FDA: 82941976404.22.08B11AB Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by imf23.hostedemail.com (Postfix) with ESMTP id 475D7140005 for ; Fri, 27 Dec 2024 21:08:02 +0000 (UTC) Authentication-Results: imf23.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=EJzVNBWY; dmarc=pass (policy=quarantine) header.from=kernel.org; spf=pass (imf23.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=1735333691; a=rsa-sha256; cv=none; b=fLN//wNjFnNG7DMgLHCkO+BLXzR2XSBPOHKZi4I0uIYBArLAYkqGR+/IzKJyl9TgCFx4Nx PE239UBsBnZav55EWv7LD8dKXrKy5pareYrNRcfPb6WZZG12ukEQmnNKdxNN+FmYQdZRw7 kn3Lo3p4LBTlc2mCiGARl87khNKHLds= ARC-Authentication-Results: i=1; imf23.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=EJzVNBWY; dmarc=pass (policy=quarantine) header.from=kernel.org; spf=pass (imf23.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=1735333691; 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=frNekgzakA7P0slnUDi6pxmpA7yyqEk+HqIMvaMEJjw=; b=VM43puO3FesD185iTO9s+wEGP1nvTf987tVeMWF9vnguaFYBBELTjUYcv98Nuso9qL/ufn zruIwhOr7BrZoAORVpuIWE7hyP6ewm9p4INTT3wksPxyytmKly97z8kO9Tpay+qa84vV3R kHLZsDgxRF6bN9cAYf51K/QaD9z8Xpg= Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by dfw.source.kernel.org (Postfix) with ESMTP id D1D1F5C5F8E; Fri, 27 Dec 2024 21:07:48 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 02235C4CED0; Fri, 27 Dec 2024 21:08:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1735333710; bh=8lAFL71XcvweH0oiSZgfTeKqV2YhADAZUO4RhEVof+M=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=EJzVNBWYphFZkOtBPdJPPmtseCQh8aCodCfWHA6zGsFaZoyOm7wf/6Gkrf+zh0X6p IFDJx59qa2/8QVP5fHwWITx+Pv2fzf7XtpKjziitqCa1VDxwiLon6GRigfM3aeTJy6 W4VMH/RFex9Ui73uFBUDh4vuASkXkVylxjnVJemDZl1iudx008xr44oza7x6qHgwHH heSAfinXQgs3uhms6XNUEmIvUWwGemujRl/AnyvNBInKM9fGJUh5tCSb5ViqK2LWPD KBiMcFlXO0bo/mEZOL8PnGsj1BDfktXUWB28Ix163MRQ7DekWjxvAmbZBxOssIwZWi RFS+ygz0rAp6g== From: SeongJae Park To: Cc: SeongJae Park , Andrew Morton , damon@lists.linux.dev, kernel-team@meta.com, linux-kernel@vger.kernel.org, linux-mm@kvack.org Subject: [RFC PATCH v2 03/10] mm/damon/core: support damos_filter->pass Date: Fri, 27 Dec 2024 13:08:12 -0800 Message-Id: <20241227210819.63776-4-sj@kernel.org> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20241227210819.63776-1-sj@kernel.org> References: <20241227210819.63776-1-sj@kernel.org> MIME-Version: 1.0 X-Rspam-User: X-Rspamd-Server: rspam03 X-Rspamd-Queue-Id: 475D7140005 X-Stat-Signature: sysf963jzh97xsgq3fm7644c5wxoa7s9 X-HE-Tag: 1735333682-793992 X-HE-Meta: U2FsdGVkX1+YC80d7rk2oXfWQn7HluwSKFBY06/Q8V7VzJDnZIOJjQ/APMhOSssUfljuNgYc0PcXC7NIxylcqut1DOYvCTX2JTME8PqzM+/CmHW5UNkUYQ4q+/k7Ry66rRfSgvLOSot8GCGoTDRpafoGrJEJH2SDMl7efpwrBLYeAhCoH8PLRmkTx9PbaKrzNq1z6x9iLHra82ldQbAeknGA2a2376xgf+CykYNaIshtOScWWbYJNQ8ETle0I6kaLufCiWmrR+QpzfkcgkeLmtWc4hZB6TBZgumITqg8OCyo8HUV8Et9g/BxbKF4o9YBaomDIFRIBhmXVZdjJgRoDl8e3sMPtBloF15+SyNhCJa8rSMHtSRzRMxVvh44WK9HtCZvPSjIth9YcwaTp2hJAvmAhKkg9uc3dP3FzEIpK3ZxouVrAHeAH5A3LgAw8uQTOvrqbZo8YZeocVNtJpLnZPHIfb2CYP4FTokmIq2TZDf3o4hNgdz+OSgZqzRQP9+30ldnOOrJJSKLZUcHFw+voqN0Wiymd6Do4DaqjjxxtRISSwiqmfhKi7L5P1HfVPdNuCYJ0AZbeebRjcQknK1zdlKZcz/lN0ZV3xPcOnMeL3fbZidKOo6Kabsu2wFsfrX8iX48oSEgZpyn1pBTuns3u6Ah+tRyPqYXZaUMLGi25avVVTOhA8gGLmH2Q5l5JMXagInVWiI6GOpf36gdJtZumjrOvRrYo17PMjy1bLvAG4MM1gQLwozJP8oHp4upX6UW7aQbobmq9szbYvafMUG9U7oMyAOy5AGayLn2NTrH//1wpnC3iNyzd5IEGaq0K80oD8GMZfiT56LHJr4hGlNYb+uPexAFlTR6iWjT5u0qL50NcGtr5isZlaf055HVLhUOERKlIRjuPSMsrnjlQ81iSmw5Jq99KRyP1uIVD3dfqkOrW3R2qKf8Vxz0kZgaQCUAY1SZwKqzdQZl+Xqs9JN Txqp80wV h/PmewqzrW69pQ2mndkqvSu37Vyer7tKOTS+Rv0h1xoea0FFNmUCUswkiCTqT4j2thXLjElHRgroRGMR31w7OYcJk0nv0MDm9sZ1rB92myy67KBsh6GU6fmrJSG8YXbgIB+oVnfciCRPh02YavEeBttNdmUjS+RV+bIr2Q+LELyxrgN7RKiSoZrgRZ36jXvzFRmQu9m2U3ChMANQvFN1/L/Jnm2XUFgxN4vheFt5hhs27U2FyJtYdy2eZ95+Gykuh0GRtjPeJfYjT4DA5yLskLqJh2g== 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: DAMON core logic is ignoring damos_filter->pass by assuming the value will be false. Respect it by dropping the assumption and reading the field when making the decision to whether filter out or in a region. Note that DAMOS action can be applied to any memory if no filter is installed, and DAMOS filters work only for memory that satisfies the 'type' and 'matching'. Hence installing pass filters without any block filter after them makes no filter-behavioral change. Signed-off-by: SeongJae Park --- mm/damon/core.c | 6 +++--- mm/damon/tests/core-kunit.h | 10 +++++----- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/mm/damon/core.c b/mm/damon/core.c index e54bd19d6f06..71db2c754e6d 100644 --- a/mm/damon/core.c +++ b/mm/damon/core.c @@ -1374,7 +1374,7 @@ static void damos_update_stat(struct damos *s, s->stat.sz_ops_filter_passed += sz_ops_filter_passed; } -static bool __damos_filter_out(struct damon_ctx *ctx, struct damon_target *t, +static bool damos_filter_match(struct damon_ctx *ctx, struct damon_target *t, struct damon_region *r, struct damos_filter *filter) { bool matched = false; @@ -1428,8 +1428,8 @@ static bool damos_filter_out(struct damon_ctx *ctx, struct damon_target *t, struct damos_filter *filter; damos_for_each_filter(filter, s) { - if (__damos_filter_out(ctx, t, r, filter)) - return true; + if (damos_filter_match(ctx, t, r, filter)) + return !filter->pass; } return false; } diff --git a/mm/damon/tests/core-kunit.h b/mm/damon/tests/core-kunit.h index cf22e09a3507..8f58d3424c21 100644 --- a/mm/damon/tests/core-kunit.h +++ b/mm/damon/tests/core-kunit.h @@ -434,25 +434,25 @@ static void damos_test_filter_out(struct kunit *test) damon_add_region(r, t); /* region in the range */ - KUNIT_EXPECT_TRUE(test, __damos_filter_out(NULL, t, r, f)); + KUNIT_EXPECT_TRUE(test, damos_filter_match(NULL, t, r, f)); KUNIT_EXPECT_EQ(test, damon_nr_regions(t), 1); /* region before the range */ r->ar.start = DAMON_MIN_REGION * 1; r->ar.end = DAMON_MIN_REGION * 2; - KUNIT_EXPECT_FALSE(test, __damos_filter_out(NULL, t, r, f)); + KUNIT_EXPECT_FALSE(test, damos_filter_match(NULL, t, r, f)); KUNIT_EXPECT_EQ(test, damon_nr_regions(t), 1); /* region after the range */ r->ar.start = DAMON_MIN_REGION * 6; r->ar.end = DAMON_MIN_REGION * 8; - KUNIT_EXPECT_FALSE(test, __damos_filter_out(NULL, t, r, f)); + KUNIT_EXPECT_FALSE(test, damos_filter_match(NULL, t, r, f)); KUNIT_EXPECT_EQ(test, damon_nr_regions(t), 1); /* region started before the range */ r->ar.start = DAMON_MIN_REGION * 1; r->ar.end = DAMON_MIN_REGION * 4; - KUNIT_EXPECT_FALSE(test, __damos_filter_out(NULL, t, r, f)); + KUNIT_EXPECT_FALSE(test, damos_filter_match(NULL, t, r, f)); /* filter should have split the region */ KUNIT_EXPECT_EQ(test, r->ar.start, DAMON_MIN_REGION * 1); KUNIT_EXPECT_EQ(test, r->ar.end, DAMON_MIN_REGION * 2); @@ -465,7 +465,7 @@ static void damos_test_filter_out(struct kunit *test) /* region started in the range */ r->ar.start = DAMON_MIN_REGION * 2; r->ar.end = DAMON_MIN_REGION * 8; - KUNIT_EXPECT_TRUE(test, __damos_filter_out(NULL, t, r, f)); + KUNIT_EXPECT_TRUE(test, damos_filter_match(NULL, t, r, f)); /* filter should have split the region */ KUNIT_EXPECT_EQ(test, r->ar.start, DAMON_MIN_REGION * 2); KUNIT_EXPECT_EQ(test, r->ar.end, DAMON_MIN_REGION * 6);