From patchwork Thu Dec 26 22:14:38 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: SeongJae Park X-Patchwork-Id: 13921479 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 88130E77188 for ; Thu, 26 Dec 2024 22:15:08 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 6A65C6B0089; Thu, 26 Dec 2024 17:15:05 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 63BEE6B008C; Thu, 26 Dec 2024 17:15:05 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 45DDA6B008A; Thu, 26 Dec 2024 17:15:05 -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 278416B0088 for ; Thu, 26 Dec 2024 17:15:05 -0500 (EST) Received: from smtpin23.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id CEF161C7D97 for ; Thu, 26 Dec 2024 22:15:04 +0000 (UTC) X-FDA: 82938515226.23.3717676 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by imf08.hostedemail.com (Postfix) with ESMTP id 100AC160009 for ; Thu, 26 Dec 2024 22:14:34 +0000 (UTC) Authentication-Results: imf08.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=Z9IcquRo; spf=pass (imf08.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=1735251274; 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=QjEe6C0+d6KrZ3RrpNolfPc4r0Ow7ijUBsSTnw7xQuQo07vpKSuDJrxL99/xtA2eLcjcMc lj5YQzVg3TheclgPthUtDbo1GTMBxEgCm6v8jzsNJ4UwjlsfbUGTbUqWFpKl9hSn2gFGg0 Bk5o0v06mvdycBjyw2GQgrNFH7Ajf24= ARC-Authentication-Results: i=1; imf08.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=Z9IcquRo; spf=pass (imf08.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=1735251274; a=rsa-sha256; cv=none; b=D8lWOlGQ5LMH1tUlez1AuwAhNklZ+oiq668JkBSWCBSJm/LeT26GMmmrdjN14NfE/+Er44 R5VIby/42Xf1LcRjVqTJ+pbzg4qrXemaFk2UAkIkZAaUuEOuy7jAS7YWpXVyL547Z1AE9f TOwvVrMgCljx+sr2iu7aSNfW0mX4kxI= Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by dfw.source.kernel.org (Postfix) with ESMTP id AD83B5C6205; Thu, 26 Dec 2024 22:14:20 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 0557DC4CEE0; Thu, 26 Dec 2024 22:15:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1735251302; bh=8lAFL71XcvweH0oiSZgfTeKqV2YhADAZUO4RhEVof+M=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Z9IcquRomrqtfrXinUoNaq9+LqgDLr3RafzI/eSAraalwzMf6S7fnPCgPAl5KxSFw zsy+A0+Lm/+DNxEl1afKWgykWPImxukIdQbwmZrIaOVNqmkekNg+PrRtZa3NB09Bo4 dkkUjqXopVWZuXiesXbcCrfoVIDtX/vEtdmG1Qv3TO8cgEz5GG+AFAMDYUqDo/39AM q5X04z4lqWR+cqzPaEqYKmJPkvF+FBDIAuwvhSoghnIpb35DoI48ewPfAtnXIwaZbO 78on1CmjcqmTiT9gA90Lgk8Q6EzNCuxGWCkduYpYcP4+n0dmibxe7Nwul8pTFb1KWK StPoR5Bi2E2ZA== 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 03/10] mm/damon/core: support damos_filter->pass Date: Thu, 26 Dec 2024 14:14:38 -0800 Message-Id: <20241226221445.78433-4-sj@kernel.org> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20241226221445.78433-1-sj@kernel.org> References: <20241226221445.78433-1-sj@kernel.org> MIME-Version: 1.0 X-Rspamd-Server: rspam05 X-Stat-Signature: ho1rkzaug7iif6sq8cjjtj5ukthkx64g X-Rspamd-Queue-Id: 100AC160009 X-Rspam-User: X-HE-Tag: 1735251274-736555 X-HE-Meta: U2FsdGVkX18EJqwh5UIO0Wch8jVV1LBfbQxQiKRbrW9fK9sSoWCblTpY72qMAVKXBtcLyw/61G3qHmeXgzrvrtm+eO7YeZQofCDWfzUk8pLnhibbEbvv5/hJdK2Ujn7XZT0bdklWJ1n0rDjH2zm8hQzavDpUJr2+//Er2MXPvEUZ4c7/B9q2tw6vA0Xej32IWDkf5JRTrtpIc7CWv+sVSAjDaCagVuwAgmEex7y34hd6g2na3Bv0LNb61oHB3iJtUU/PvGmnkzsI4c3eizoCOY8kfD0Jop7PxvQYnKshuFXs+GDbBccN1we5wOk5dmWzuz5mUq7KGLKkwhNkuqMD0JaC1RxZ5I5KWkLRlAw+g2P2h5ckX2RUFC0LOK+nYt3fdNFbJ7igUUn2ZIujfcW45LVFBZQyfNj1GiPQheqECR2+C7dmNsKUNHcOEn3V83/iNe8xUM8QefvdAzerQuNqdcB8IqTzIOSyXEYxjbxImi7nBg8jD+7OR/ES+lK4f4pwcYW785JNQEbbufyakdMjaBb1v8JZShzpumRthGtheZ9kviL87fn6zVU53/a9hbLNq4exbZuKYrkYpW/bmqzNUIKHJJPJDQIZak1m5s/4n7tjk8viaeLB7PR2IzA/D+kw7IAOPXCTcrvjdTi1Gt5upl3gi2XQT3trJ9grrvVxmM7MO48G2zgUB5Xtb9yCikBZuEkQJSsYBN13ce5yZ1LRPGDnzfGjtPVMJ6WPHyA/8QcqQqejoHqklk6+KoqnXsFA68hobN1wNCQZUoiY5EFJoX+kUrGKLe1g5gjaehDVz8B6I61G/bY3flMLl2R2RoLYO2eYedP30qx9mtUzK/vPRbvsZThYMecm+3Aefp6wptyKxs3EtLN2RmHcJMOLn2Xw3NLlXf6hHrn4TkLS6LCvFQ2PYyLz3V/jtmGvDvtGSMwW2fh0jarY/iFDhkq9asqeMAV+jxSo3PeueR7atsd C/dsqaup Avn/GXmd18HsS9u9ANNJffTQ6ypfJdKufNG7Maa0neH4FBTkB126RScf81arHNdb8Pz63BU1igc9+thW94BMQ5X/Kace2Ay6Ojgh0pvdvGL6T9JoD/M5rnyI8Azcni/HOMSVQ1oGM+Wt9PxefUpttnvm/zy1MtkWEWJ44KJmcpAmB8ZpZ2WCNmLux9F6xZoDGsuM78nYS9KwfCpbUzmbD3BliXkoECs6jL5OFcEgVhcNejMNDjzV5VOrOD4BXlCTNhYqrRBef/46vxZTr/BrZauS92A== 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);