From patchwork Thu Jan 9 17:51:19 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: SeongJae Park X-Patchwork-Id: 13933073 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 CB7FCE77197 for ; Thu, 9 Jan 2025 17:51:52 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id C07066B00B4; Thu, 9 Jan 2025 12:51:43 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id B8D356B00B6; Thu, 9 Jan 2025 12:51:43 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 9E08E6B00B7; Thu, 9 Jan 2025 12:51:43 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id 7C1886B00B4 for ; Thu, 9 Jan 2025 12:51:43 -0500 (EST) Received: from smtpin06.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id 39273120318 for ; Thu, 9 Jan 2025 17:51:43 +0000 (UTC) X-FDA: 82988656086.06.E1BE464 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by imf09.hostedemail.com (Postfix) with ESMTP id 7B28D14000A for ; Thu, 9 Jan 2025 17:51:41 +0000 (UTC) Authentication-Results: imf09.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=iOiV8xN+; spf=pass (imf09.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=1736445101; 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=ix4rX2LHLJWRMEMlitpt30LZfXj379qN39OYlUVwprs=; b=fJdczfBLh2k61j326/w+OmM77Kad/is0sVADBmc4HfAd2cCW95SMGxFGyVl+ILfgl0v722 yvOBpcr8GR2HwMgseaJTosqfSW0QZkQmVmlK7xGGUgHuJ/9kYNMnAXHi08eQWrqbgAv5FA 4fgkB5+xQkyXniTVZawqlZuBzvF7DEY= ARC-Authentication-Results: i=1; imf09.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=iOiV8xN+; spf=pass (imf09.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=1736445101; a=rsa-sha256; cv=none; b=23MOjJPetX2EI39ABUDmRZEpSmTQbwmaFWzDH6ELDMTik9uXTYD/GYKAng1BEafTVpu2cX I/zhDDVgXmCSsdAxfRYdHbyU3p1KrSRZfr8yOj7AZtQLUul1C06jI2sRS+22ntLkzghBDD CAU6AJicVlwaOY+HV2O+Ps3qF4PkSao= Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by dfw.source.kernel.org (Postfix) with ESMTP id 89A4A5C5CCC; Thu, 9 Jan 2025 17:50:59 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 36EFEC4CEE1; Thu, 9 Jan 2025 17:51:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1736445100; bh=/TwzvHzsYhMLVRMAly61w18SuFtGS0e8DIve8swoAg8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=iOiV8xN+tOzd6OhWGwRDcbApXOwx2OoSQwcl1ajO5uMihuqIeFetDPj9kO1jvRZI3 DCaVH7i0rTdMfXF9gctFxlGeo8ihHqNWZs0nADBR6YSrMd36r0n6p36YB1MuIFuRj1 /BMQS++22T1gOsjeEneFIB8/06l2tUcaCx5/BajT7ICW4t09cZsy+uQeu0Qyvjz7dx f8LNV/bZ+JLSt8fXU5hvrmJCT+A44RSIA0A4g8SuUGaxAAUCZaDwk07W+nPkt1v+gB qK+y9hp3bWU2vsD48OucJ/zTxW2Lmn30O1QwshQ0saR9Kd3SnNh47BIjxCa+9Mev5e F095E2SrYdR5A== From: SeongJae Park To: Andrew Morton Cc: SeongJae Park , damon@lists.linux.dev, linux-kernel@vger.kernel.org, linux-mm@kvack.org Subject: [PATCH v2 03/10] mm/damon/core: support damos_filter->allow Date: Thu, 9 Jan 2025 09:51:19 -0800 Message-Id: <20250109175126.57878-4-sj@kernel.org> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20250109175126.57878-1-sj@kernel.org> References: <20250109175126.57878-1-sj@kernel.org> MIME-Version: 1.0 X-Rspamd-Queue-Id: 7B28D14000A X-Stat-Signature: hd7s4ad7ubwaok491uzj4mwxzrosycs4 X-Rspam-User: X-Rspamd-Server: rspam11 X-HE-Tag: 1736445101-229565 X-HE-Meta: U2FsdGVkX1/LTLoPswhapI8wguubQUzsGEDYQxeWB/oQB4rLSamQH2G3hnlrSyvVTB8TH0ENL/95998c4ax+5RagMWVobBRJbqZarwOJ8pFLSYKKjgyNSMuIIQfd4AO3X5W8vkGfeNpq0Z3RBQiUikTLfoSZkwwr4qdAhdz9kKSA0dMPIHJjXXNho6uVh54+2IgovYL9bvT0lI+2KjPpgW4M4B+9MdsKhrMpGH4JR2O2/jHLubf0dGyWQXCeTGf2L832MCQqKgXstpOHRA+QeAxJ2wdBQWK4SvoIYPJNi5HOwaSMbx9g4M5htI25GU1o58nY+QYcIPJmt+PIM3U8DbuNLgjyxmhiwP5RpzAKUVDH/pYT7zcEkKwEBs2WHS+xu/gbYGKW3plhqclcnugq8CIiXkJt11AEuTQ1vTWur2tJeYkv//fmKyi8WsS5LPIHxrBCAMWRgVgRG0lc7dk8NWJ9LfHO9rqWfJtj/rRZPfs8F1e7a2dCWhfLEzsW0nUqdo4CerN58+LkiVQnRIJJriV0sy29t1984cTBUDCDgNGLfO4ZL0wAnq6QQxhYYDSCTzpb1csXadbIVdCIS5bdNsVOaX10JbyzsbiJuhICVEu3vgBJVSp4y89QREbjMnd60IpFrntpMRzUkYSCOgOKoHeviHdHUXTp5Ksuhgom6AVmINuydpt+lTKjtBHo8ZaTN6eQvciIT9pHIYJppfoAMHX0AoCn7ijPOu5i5mP17+PFp67Mp++ChLbxqCTfz6qO2+euJr6PaLI9MeW7tRomE+/GkbXtGK7DxQ/qZ6xsBxr1tRteAt8z21rUavPDZ2OecRu6r4HHuXmmjHI13MTdFw5f16IDJiRjwigARa6BgtGxR9dOJ0LfYbuQT1StBWpCBMLxcxPMoI8giJhNwGrn7WQEdy8Dait4q0z/6SaCWy2vSnGvQJeY6Jl++TSLYnkVF5A39fTwoB0kv34Wubj 62HvH16P D1H4rdJwC1EfZ1xMIXroH8w3OPN5Le/y0+MP4dfOX98c1KQmgsRurzBLTVBLzKj9e+KfV9IBhaYpSf2fZB0uBKmh/WN1ft8W9YweHNiWyk8UCMgQH6y4OIx4j7sDd8rGzt5bdziNW66t5YzqGRAaMC01hM1kpjKNyyy6Hd7DjJ2hpg+VLtsC9w+5C3z5knFN1o3UjCwsI0+aMZ/y4JyO4/aQV+Z0hihEr7my/ijY4PR/RSA7FTnwSiIgsr/eYKqzgL36yyHnIDBrZ/azeNkYnJNx45w== 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 filters supports allowing behavior, but the core layer's DAMOS filters handling logic still assumes only rejecting (filtering-out) behavior. Update the logic to aware of and respect the behavioral decision by reading damos_filter->allow when making the decision to exclude a region or not. 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 bdde532ebbc8..76707b0635d6 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->allow; } 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);