From nobody Sun Feb 8 21:26:29 2026 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 920A91F7580; Fri, 27 Dec 2024 21:08:28 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1735333709; cv=none; b=aJz2PpfEWfPVquuriR8hk33px7o0dgJmgAPqsaaEM4R3xlBPJuTip/MJqcwgletHEbVaFmtb+ZAx+5obJGJ8ydo/9lNYSomHnMmsxs3NybQZWC0uM56PSNvYR9/iRxyLF+k0NmdnJLV3rwaFQm31EamJtVr+RjbuQjkyeUDUW4E= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1735333709; c=relaxed/simple; bh=BqfFuozL0F0mxvXeJ3OdZ9G2Y0SIHcS2uBA23Vwog2k=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=Ct85ZthPU7mBQ1KTFQgI5TaWxdMgoKl1pjJ/v3rRQ+VOzB4MpXhWPA5Rf1eRfywgdV3pd7m7wtuFRqk7fM4XciaJPAtMeScmekhNrd3lJdavslk9Jd0290jysZPjNRpGxTuDJOjmRhuimoP2IYrIETVmm3Pml+Rmu+F3vZa0laE= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=tnUJit8n; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="tnUJit8n" Received: by smtp.kernel.org (Postfix) with ESMTPSA id EC4CAC4CED4; Fri, 27 Dec 2024 21:08:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1735333708; bh=BqfFuozL0F0mxvXeJ3OdZ9G2Y0SIHcS2uBA23Vwog2k=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=tnUJit8naTGjkWHL3DW4n2LgDjBhljJs3/AlXhk8vOKW2ODhnwksLa4AD6FosMtt/ CxxsY20yI4KKTgSOye90gFHjilVnGOYBnKXpH9lNWDVmyrXjPq66bqMkSDqc/+cBNe DEfb7ufAsYr4jf1XHfvVHDTuDS+ZacbU91Vs63RITRROYhr+vjDeavZkEygd5WnVMu vYm21Ke3on1fFF+z7XVlgEQsKYxG9YBib5wdq+cqKCo5SJLlx2dGm3Q9I/9+2aUAeC n8SSjpFZTjnnP1hPlkN4jjfJUtYwDrkL732B2av7ax7t2sHP8/UEJp6fRO/0EWoCMB UM0X07Znk6JDQ== From: SeongJae Park To: Cc: SeongJae Park , damon@lists.linux.dev, kernel-team@meta.com, linux-kernel@vger.kernel.org, linux-mm@kvack.org Subject: [RFC PATCH v2 01/10] mm/damon: fixup damos_filter kernel-doc Date: Fri, 27 Dec 2024 13:08:10 -0800 Message-Id: <20241227210819.63776-2-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> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" The comment is slightly wrong. DAMOS filters are not only for pages, but general bytes of memory. Also the description of 'matching' is bit confusing, since DAMOS filters do only filtering out. Update the comments to be less confusing. Signed-off-by: SeongJae Park --- include/linux/damon.h | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/include/linux/damon.h b/include/linux/damon.h index 18449b5c45df..15f098372672 100644 --- a/include/linux/damon.h +++ b/include/linux/damon.h @@ -347,8 +347,8 @@ enum damos_filter_type { =20 /** * struct damos_filter - DAMOS action target memory filter. - * @type: Type of the page. - * @matching: If the matching page should filtered out or in. + * @type: Type of the target memory. + * @matching: If the @type-matching memory should be filtered out. * @memcg_id: Memcg id of the question if @type is DAMOS_FILTER_MEMCG. * @addr_range: Address range if @type is DAMOS_FILTER_TYPE_ADDR. * @target_idx: Index of the &struct damon_target of @@ -357,9 +357,10 @@ enum damos_filter_type { * @list: List head for siblings. * * Before applying the &damos->action to a memory region, DAMOS checks if = each - * page of the region matches to this and avoid applying the action if so. - * Support of each filter type depends on the running &struct damon_operat= ions - * and the type. Refer to &enum damos_filter_type for more detai. + * byte of the region matches to this given condition and avoid applying t= he + * action if so. Support of each filter type depends on the running &stru= ct + * damon_operations and the type. Refer to &enum damos_filter_type for mo= re + * details. */ struct damos_filter { enum damos_filter_type type; --=20 2.39.5 From nobody Sun Feb 8 21:26:29 2026 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 920491F7552; Fri, 27 Dec 2024 21:08:29 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1735333709; cv=none; b=PzjZow2Q9WwQutFC+OqlTVDocdJ0youenqX8vBcK1S53mE4Jyu0IZUgDRnbazS7hXNqs7P5/9T8NKOwwsmExfOlQyH1zGGQRI+n2xMdZDm4ERv5LIk+4rIlWx1X1M0N7Boodr1oOv0hlNOE19UZwKOsSvvxAr3jSjUGQX5XrVWU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1735333709; c=relaxed/simple; bh=DCAC3zBpwSlEJOxW64cidA0UEg6r7ucuAwa/fXFsTMo=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=ExHTp/zNLf81vo1mf/248cUpBNdLV0PEgpmNRPL79QhPiND/0j1UPlBIX/5VMueQS5XSF4ka74UjgBxV455sRfrgqj7LPLMdBtcfmKZOOKgoiQBYFMDQkjYTDUiDG0apL4rJM4wolA6cvOAhyu1fSsgKd7dKjcFkrjgT4Xe54hM= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=U0LGkOBO; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="U0LGkOBO" Received: by smtp.kernel.org (Postfix) with ESMTPSA id DE5A0C4CED0; Fri, 27 Dec 2024 21:08:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1735333709; bh=DCAC3zBpwSlEJOxW64cidA0UEg6r7ucuAwa/fXFsTMo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=U0LGkOBOaCxTAQrJhEA/mJ+FKf0Hr+hAtjySuGne2+MCCrD8OaEg50lgn7TQ5sxJI m1ZeaXaZdlRVoBlkFpo46P6jLqa1xnXvhEkacbkgDsnU5QJAdILnIWAdB2YulqYGsT uPvGKwli+oyh1tMuYmYbLGs12gXazBBv27TqPhCdDa1eVMRQkfe2Wn2PLgUeUBSfuT 7CzFw53jUSQdK4WVp3rvL6XfJYodN7KVM7rGEjfkMCvyWr47FPjJf4Gsc9Wc4XMiIW leC5w6Msxifg6dS+H0jWNfpi9FfwRpIpkLGsio8oLqwMKrtHgYteJdQOuhWUawjH0K yLUs0Cnve283Q== 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 02/10] mm/damon/core: add damos_filter->pass field Date: Fri, 27 Dec 2024 13:08:11 -0800 Message-Id: <20241227210819.63776-3-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> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" DAMOS filters work as only exclusive (block) filters. This makes it easy to be confused, and restrictive at combining multiple filters for various types of memory. To extend DAMOS filters for inclusion behavior, add a filed to damos_filter. Following commits will make the field to decide whether the filter should work as an exclusive (block) filter, or an inclusive (pass) filter. Signed-off-by: SeongJae Park --- include/linux/damon.h | 4 +++- mm/damon/core.c | 1 + 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/include/linux/damon.h b/include/linux/damon.h index 15f098372672..122c30e4ce19 100644 --- a/include/linux/damon.h +++ b/include/linux/damon.h @@ -348,7 +348,8 @@ enum damos_filter_type { /** * struct damos_filter - DAMOS action target memory filter. * @type: Type of the target memory. - * @matching: If the @type-matching memory should be filtered out. + * @matching: Whether this is for @type-matching memory. + * @pass: Whether the memory should pass-through the filter. * @memcg_id: Memcg id of the question if @type is DAMOS_FILTER_MEMCG. * @addr_range: Address range if @type is DAMOS_FILTER_TYPE_ADDR. * @target_idx: Index of the &struct damon_target of @@ -365,6 +366,7 @@ enum damos_filter_type { struct damos_filter { enum damos_filter_type type; bool matching; + bool pass; union { unsigned short memcg_id; struct damon_addr_range addr_range; diff --git a/mm/damon/core.c b/mm/damon/core.c index 52e50f183ffe..e54bd19d6f06 100644 --- a/mm/damon/core.c +++ b/mm/damon/core.c @@ -275,6 +275,7 @@ struct damos_filter *damos_new_filter(enum damos_filter= _type type, return NULL; filter->type =3D type; filter->matching =3D matching; + filter->pass =3D false; INIT_LIST_HEAD(&filter->list); return filter; } --=20 2.39.5 From nobody Sun Feb 8 21:26:29 2026 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 48CAB1F8AF7; Fri, 27 Dec 2024 21:08:30 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1735333710; cv=none; b=I645/7swi/Hzu/zwaEQk80jALMRU6Tn9knSn9NE9sPGj7wAmzH0gGEFBNF6mMf0U9iXVhVUtemdH7FvABCQjLE06fPckpXZI1MWIMxWUIjIVmvnrLKoYhJubQC6wxMiSFuiJKi8T0PtnXUYt5ap92gpddEmvgBqjlfdD9bT1YHY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1735333710; c=relaxed/simple; bh=8lAFL71XcvweH0oiSZgfTeKqV2YhADAZUO4RhEVof+M=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=liUVDrPbyaaVczD1NKuBx4AuAATdtUv1wizjrd+O7utZVCmulP5aS2le6VG8TU+Qf4WFJ8jzgTBEO5t3kGPBKcmQXlkZ2SaSq9h+sFuRwDjz8zORo2HgbDFQfIWLRm6wOEIYiJPKUd1/UMo1ykRDL78t4k8aj1iYeaGkm7CZ1Ck= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=EJzVNBWY; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="EJzVNBWY" 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> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" 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 +=3D sz_ops_filter_passed; } =20 -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 =3D false; @@ -1428,8 +1428,8 @@ static bool damos_filter_out(struct damon_ctx *ctx, s= truct damon_target *t, struct damos_filter *filter; =20 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); =20 /* 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); =20 /* region before the range */ r->ar.start =3D DAMON_MIN_REGION * 1; r->ar.end =3D 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); =20 /* region after the range */ r->ar.start =3D DAMON_MIN_REGION * 6; r->ar.end =3D 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); =20 /* region started before the range */ r->ar.start =3D DAMON_MIN_REGION * 1; r->ar.end =3D 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 =3D DAMON_MIN_REGION * 2; r->ar.end =3D 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); --=20 2.39.5 From nobody Sun Feb 8 21:26:29 2026 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C7C841F941B; Fri, 27 Dec 2024 21:08:31 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1735333711; cv=none; b=pg57NuLSw3fS37dDU8N0zC9eT0gOMSjNRDEo+eQRbZrbvzrPHQATaUA0xxnaPjbH42dmb3SIlK2m6F9jjqgQqeDNaLaZh7D2JkQF7PjlFIRLM3g2W3MJMLCq8p1GnBYPekbYZDMB8wKS8kbtPvvxV33NbEWOTKJrhofsf2M31Rw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1735333711; c=relaxed/simple; bh=SeMHzC1M39t8q6CCCk8soRnhB4lB7Sy3qIRyk7EYfrE=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=uKpgPFphxaBTgN/D5DAiaINX+3Gs1qSVnCKEgGThV90C+/ftxedaL0s8LRtvkYsgPVhUJ5qnoFhkeTYv+pnZ9xO3C6lgYe5O/n18tOkSnZ4owByglQMRHHQakidd1644enj2bZGBrLqjOYthon4b+EQbh7DKICpIUz/okBdh86Q= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=T9gQaHeb; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="T9gQaHeb" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 1C83CC4CED6; Fri, 27 Dec 2024 21:08:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1735333711; bh=SeMHzC1M39t8q6CCCk8soRnhB4lB7Sy3qIRyk7EYfrE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=T9gQaHebXbvQqfNyFuj5hWQDHLpGC3wzkpL37XweUv3w1CsosT2Q4AHPDfRQOLacG ChYhjPlY7LsFa00Zd/U+inTizRccRAYmIINCnYnS/yTaMflWorTQkXLLyHWU1XePef e7DexRXVaUxs8RxQawG0QuGuTRaUJg4ZN76rPpzyPEuCEh9Prz+/um2oFGFPdizJfK 4nnbrCmDMAuWQR0b4vlz/KlZBAdIU475j9WWH/rZGzqXRuC/VYYqzRvDB6FeKKxkva Ke1g5Jxvm+OQqs3MkQrPOK1PJMe5nVR8nG7rP9awY6rVVdYcMjz6qg1mBICTmOKqhq DdOX1E6fsswTQ== 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 04/10] mm/damon/paddr: support damos_filter->pass Date: Fri, 27 Dec 2024 13:08:13 -0800 Message-Id: <20241227210819.63776-5-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> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" 'paddr', a DAMON operations set implementation for the physical address space supports a few types of DAMOS filters (anon, memcg and young), but ignoring the ->pass field. Update the logic to support the behavior. Signed-off-by: SeongJae Park --- mm/damon/paddr.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/mm/damon/paddr.c b/mm/damon/paddr.c index b0c283808ba6..71cb02128b46 100644 --- a/mm/damon/paddr.c +++ b/mm/damon/paddr.c @@ -198,7 +198,7 @@ static unsigned int damon_pa_check_accesses(struct damo= n_ctx *ctx) return max_nr_accesses; } =20 -static bool __damos_pa_filter_out(struct damos_filter *filter, +static bool damos_pa_filter_match(struct damos_filter *filter, struct folio *folio) { bool matched =3D false; @@ -237,8 +237,8 @@ static bool damos_pa_filter_out(struct damos *scheme, s= truct folio *folio) struct damos_filter *filter; =20 damos_for_each_filter(filter, scheme) { - if (__damos_pa_filter_out(filter, folio)) - return true; + if (damos_pa_filter_match(filter, folio)) + return !filter->pass; } return false; } --=20 2.39.5 From nobody Sun Feb 8 21:26:29 2026 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C7E291F9A87; Fri, 27 Dec 2024 21:08:32 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1735333712; cv=none; b=fhZQ8oQUG1XTWSl3m9F8QoLS9M2XINzM1dT1TQrEjNSjYuLIKOE0AectlsZNjMpDLeJoBxdqT6Lplcdg1aldYubRzd+/+YzWmlRt76icNBiUoMWzKNZlsictQidZfMYEsKf3EP/yN77BV+XoZmkCQH3Jqiep38SLrPwyvYFYygk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1735333712; c=relaxed/simple; bh=xPDKx+cgGKS4vL2pTXGyaq2E/e6yLYc/uyg/ecrFVG0=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=ZrymIiWbHwwLdpPR09rDGCQik+8nuhp/7wqYyK07/9uS3EaRNDZxE+zKoLU0MuagGpYFuDX7eJPHp5nrLT7WtlyTGdEaYO4lbMS1zWQT+fINzZH53cfGrR/pl8sDKZJjRIa0re50W931sLJ4Ouywa9Ab3VFElfWm3Y1QSjI/EYM= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=FULY2tdg; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="FULY2tdg" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 2FFC0C4CED4; Fri, 27 Dec 2024 21:08:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1735333712; bh=xPDKx+cgGKS4vL2pTXGyaq2E/e6yLYc/uyg/ecrFVG0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=FULY2tdgi1VaO4rrf16MKP58oixHQI2N2jJn/F/gnUlRh3zifCIZDSg+EO6KzQdaj 3GGh53n0FQNy8mV2be3B1SdfQpVgCKLXkieHaUKXKwzKDfZTTK9S80krp4qqnSZjrU 1ZyOge3igtQM/3kvplwrHdGCFPUNTcMv6cPUINRZHh+vd4Hf6bKp+wbRD26nIjC/uB Rz9DMNNmuvr3aArpTA+t56Ghi+9EasW8BIelI1Ti7Lu10SXXMmhj80Oq+YQqbfwOYM mEyo0DS+QQMz4ryu7p3XPrHF+lTLxIu3oGGwzDIP4i/1P/ag0YEw+/YOSCCVMp3hK7 IOZIOD943H1Lg== 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 05/10] mm/damon: add pass argument to damos_new_filter() Date: Fri, 27 Dec 2024 13:08:14 -0800 Message-Id: <20241227210819.63776-6-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> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" damos_new_filter() sets damos_filter->pass as false always. The API users hence should manually set the field to use the filter as a pass filter. It is cumbersome and easy to mistake. Add an arugment for setting the field to damos_new_filter(). Signed-off-by: SeongJae Park --- include/linux/damon.h | 2 +- mm/damon/core.c | 7 ++++--- mm/damon/paddr.c | 3 ++- mm/damon/reclaim.c | 2 +- mm/damon/sysfs-schemes.c | 2 +- mm/damon/tests/core-kunit.h | 4 ++-- 6 files changed, 11 insertions(+), 9 deletions(-) diff --git a/include/linux/damon.h b/include/linux/damon.h index 122c30e4ce19..ad0360711aca 100644 --- a/include/linux/damon.h +++ b/include/linux/damon.h @@ -801,7 +801,7 @@ void damon_update_region_access_rate(struct damon_regio= n *r, bool accessed, struct damon_attrs *attrs); =20 struct damos_filter *damos_new_filter(enum damos_filter_type type, - bool matching); + bool matching, bool pass); void damos_add_filter(struct damos *s, struct damos_filter *f); void damos_destroy_filter(struct damos_filter *f); =20 diff --git a/mm/damon/core.c b/mm/damon/core.c index 71db2c754e6d..13f12d82de5f 100644 --- a/mm/damon/core.c +++ b/mm/damon/core.c @@ -266,7 +266,7 @@ int damon_set_regions(struct damon_target *t, struct da= mon_addr_range *ranges, } =20 struct damos_filter *damos_new_filter(enum damos_filter_type type, - bool matching) + bool matching, bool pass) { struct damos_filter *filter; =20 @@ -275,7 +275,7 @@ struct damos_filter *damos_new_filter(enum damos_filter= _type type, return NULL; filter->type =3D type; filter->matching =3D matching; - filter->pass =3D false; + filter->pass =3D pass; INIT_LIST_HEAD(&filter->list); return filter; } @@ -806,7 +806,8 @@ static int damos_commit_filters(struct damos *dst, stru= ct damos *src) continue; =20 new_filter =3D damos_new_filter( - src_filter->type, src_filter->matching); + src_filter->type, src_filter->matching, + src_filter->pass); if (!new_filter) return -ENOMEM; damos_commit_filter_arg(new_filter, src_filter); diff --git a/mm/damon/paddr.c b/mm/damon/paddr.c index 71cb02128b46..cd89500efc22 100644 --- a/mm/damon/paddr.c +++ b/mm/damon/paddr.c @@ -259,7 +259,8 @@ static unsigned long damon_pa_pageout(struct damon_regi= on *r, struct damos *s, } } if (install_young_filter) { - filter =3D damos_new_filter(DAMOS_FILTER_TYPE_YOUNG, true); + filter =3D damos_new_filter( + DAMOS_FILTER_TYPE_YOUNG, true, false); if (!filter) return 0; damos_add_filter(s, filter); diff --git a/mm/damon/reclaim.c b/mm/damon/reclaim.c index 9e0077a9404e..a675150965e0 100644 --- a/mm/damon/reclaim.c +++ b/mm/damon/reclaim.c @@ -221,7 +221,7 @@ static int damon_reclaim_apply_parameters(void) } =20 if (skip_anon) { - filter =3D damos_new_filter(DAMOS_FILTER_TYPE_ANON, true); + filter =3D damos_new_filter(DAMOS_FILTER_TYPE_ANON, true, false); if (!filter) goto out; damos_add_filter(scheme, filter); diff --git a/mm/damon/sysfs-schemes.c b/mm/damon/sysfs-schemes.c index deeaf23c1fcf..9a883e8aea1c 100644 --- a/mm/damon/sysfs-schemes.c +++ b/mm/damon/sysfs-schemes.c @@ -1901,7 +1901,7 @@ static int damon_sysfs_add_scheme_filters(struct damo= s *scheme, sysfs_filters->filters_arr[i]; struct damos_filter *filter =3D damos_new_filter(sysfs_filter->type, - sysfs_filter->matching); + sysfs_filter->matching, false); int err; =20 if (!filter) diff --git a/mm/damon/tests/core-kunit.h b/mm/damon/tests/core-kunit.h index 8f58d3424c21..532c6a6f21f9 100644 --- a/mm/damon/tests/core-kunit.h +++ b/mm/damon/tests/core-kunit.h @@ -411,7 +411,7 @@ static void damos_test_new_filter(struct kunit *test) { struct damos_filter *filter; =20 - filter =3D damos_new_filter(DAMOS_FILTER_TYPE_ANON, true); + filter =3D damos_new_filter(DAMOS_FILTER_TYPE_ANON, true, false); KUNIT_EXPECT_EQ(test, filter->type, DAMOS_FILTER_TYPE_ANON); KUNIT_EXPECT_EQ(test, filter->matching, true); KUNIT_EXPECT_PTR_EQ(test, filter->list.prev, &filter->list); @@ -425,7 +425,7 @@ static void damos_test_filter_out(struct kunit *test) struct damon_region *r, *r2; struct damos_filter *f; =20 - f =3D damos_new_filter(DAMOS_FILTER_TYPE_ADDR, true); + f =3D damos_new_filter(DAMOS_FILTER_TYPE_ADDR, true, false); f->addr_range =3D (struct damon_addr_range){ .start =3D DAMON_MIN_REGION * 2, .end =3D DAMON_MIN_REGION * 6}; =20 --=20 2.39.5 From nobody Sun Feb 8 21:26:29 2026 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 2537E1F9EAB; Fri, 27 Dec 2024 21:08:33 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1735333715; cv=none; b=KLiX+183fSusoKL+zL8hdharrPmQ8yYMHpnZ0QrMbzahlc/iyY9Zy76O73QMNZSpgEVaArOxwc2HxhTjeSvS9fKq/jh/Jwuv/Cnm5W9Oc1Z2nzbqKjeP985FcpzVAKrcfmVnT8Qc3832M0yHubpWT0pdr8JCJmZZ/FpfTdO1KUk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1735333715; c=relaxed/simple; bh=ZERQXRIpbhEDVEpD6J6LgTdFsTQpbeeZuCqI48fC6sI=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=Rkl2JHtH2tbwxqlVEbCDxcHqpp+eox6gJQE4VYKeuxVgGXI7b9L4+dEjCxHUZ6IK1UTosai4gYkfESXYGdQ8mY6KcVRteUKbnOzUKT9f5CtydIwBvkRww3wQlm6qQKXrbWQKN9cE5oRxXqku8T5rUkfOd/lsVl7wBnxlNXOBR6A= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=DrLt89ic; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="DrLt89ic" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 437FBC4CEE2; Fri, 27 Dec 2024 21:08:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1735333713; bh=ZERQXRIpbhEDVEpD6J6LgTdFsTQpbeeZuCqI48fC6sI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=DrLt89icA879gSM39Ub/e7HV147OGR4ZXrFChzBzd0p8ILo78pml8/I8T2/zDwh3h HwqflM4E+tOSgKiITbK/KpcoVrSaMURpRrKuUmmWrQYnL2tJ/UMRl21g8UZTJqEUMW u7/nRtrszEUkMjtWvMdxfLJNF96VeKKSqf7HLnDsmy79/C1QW6aGuOm19deAEEtY8r ZGSEt0Y0nqoSmj8QkS4XXzEUFf7ASUGCU9U0fp/5eSSd2JkMpfblFkMNE3Xa/SOU/C BVMNdxZus9nHeBjJpwZwK/p8HVVhNyPoUtgdRo0wOK6rChQGvh7k78/frABWDndXxx +ZHav/02/UuQA== 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 06/10] mm/damon/sysfs-schemes: add a file for setting damos_filter->pass Date: Fri, 27 Dec 2024 13:08:15 -0800 Message-Id: <20241227210819.63776-7-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> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Only kernel-space DAMON API users can use inclusive DAMOS filters. Add a sysfs file named 'pass' under DAMOS filter directory of DAMON sysfs interface, to let the user-space users use inclusive DAMOS filters. Signed-off-by: SeongJae Park --- mm/damon/sysfs-schemes.c | 32 +++++++++++++++++++++++++++++++- 1 file changed, 31 insertions(+), 1 deletion(-) diff --git a/mm/damon/sysfs-schemes.c b/mm/damon/sysfs-schemes.c index 9a883e8aea1c..9e171046ee94 100644 --- a/mm/damon/sysfs-schemes.c +++ b/mm/damon/sysfs-schemes.c @@ -313,6 +313,7 @@ struct damon_sysfs_scheme_filter { struct kobject kobj; enum damos_filter_type type; bool matching; + bool pass; char *memcg_path; struct damon_addr_range addr_range; int target_idx; @@ -385,6 +386,30 @@ static ssize_t matching_store(struct kobject *kobj, return count; } =20 +static ssize_t pass_show(struct kobject *kobj, + struct kobj_attribute *attr, char *buf) +{ + struct damon_sysfs_scheme_filter *filter =3D container_of(kobj, + struct damon_sysfs_scheme_filter, kobj); + + return sysfs_emit(buf, "%c\n", filter->pass ? 'Y' : 'N'); +} + +static ssize_t pass_store(struct kobject *kobj, + struct kobj_attribute *attr, const char *buf, size_t count) +{ + struct damon_sysfs_scheme_filter *filter =3D container_of(kobj, + struct damon_sysfs_scheme_filter, kobj); + bool pass; + int err =3D kstrtobool(buf, &pass); + + if (err) + return err; + + filter->pass =3D pass; + return count; +} + static ssize_t memcg_path_show(struct kobject *kobj, struct kobj_attribute *attr, char *buf) { @@ -482,6 +507,9 @@ static struct kobj_attribute damon_sysfs_scheme_filter_= type_attr =3D static struct kobj_attribute damon_sysfs_scheme_filter_matching_attr =3D __ATTR_RW_MODE(matching, 0600); =20 +static struct kobj_attribute damon_sysfs_scheme_filter_pass_attr =3D + __ATTR_RW_MODE(pass, 0600); + static struct kobj_attribute damon_sysfs_scheme_filter_memcg_path_attr =3D __ATTR_RW_MODE(memcg_path, 0600); =20 @@ -497,6 +525,7 @@ static struct kobj_attribute damon_sysfs_scheme_filter_= damon_target_idx_attr =3D static struct attribute *damon_sysfs_scheme_filter_attrs[] =3D { &damon_sysfs_scheme_filter_type_attr.attr, &damon_sysfs_scheme_filter_matching_attr.attr, + &damon_sysfs_scheme_filter_pass_attr.attr, &damon_sysfs_scheme_filter_memcg_path_attr.attr, &damon_sysfs_scheme_filter_addr_start_attr.attr, &damon_sysfs_scheme_filter_addr_end_attr.attr, @@ -1901,7 +1930,8 @@ static int damon_sysfs_add_scheme_filters(struct damo= s *scheme, sysfs_filters->filters_arr[i]; struct damos_filter *filter =3D damos_new_filter(sysfs_filter->type, - sysfs_filter->matching, false); + sysfs_filter->matching, + sysfs_filter->pass); int err; =20 if (!filter) --=20 2.39.5 From nobody Sun Feb 8 21:26:29 2026 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A953A1F9ABC; Fri, 27 Dec 2024 21:08:34 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1735333714; cv=none; b=maotbL0HuyYcIAuViJGsKQkrdBSp4BEFoSlCMLQ77ctNV7wfSP0atvNaTs52Esnma3cLxGZb0DfVD4Wfd5kkLwj6lZRVqkr1IlN73n/4fZ6JLcc6GLG6BNiW0atGYRECS9lY1mutSVfSusHmwIxM2FVsC/ZsZ79VPgD174bPzDA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1735333714; c=relaxed/simple; bh=//vhFtbVl0HM6He0HK/Z+ZVxsC9xYIvf1nEXj2Zge2g=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=aet3xe+sr2NMCIM1zWx3rUqxx2QC6jB+8+IPu7J/lyEOslqwRIE7GpPEdWfg8JpyW2gTA4qWs31Gyo6hCfXGzAZcEa89AsxXkli7bRjVAalmI1hbvqms1YaBE7EGlYSi/3CbpbUbdYsV3Zt4rNQEBMzAqPuLErJaEme88xcVI0w= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=EQUefMj+; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="EQUefMj+" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 5CD5EC4CED6; Fri, 27 Dec 2024 21:08:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1735333714; bh=//vhFtbVl0HM6He0HK/Z+ZVxsC9xYIvf1nEXj2Zge2g=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=EQUefMj+FWzM4VXbZDc5roHqMXa+dd9KuutCjSQ56NMbUULomhMHqHipp3Wt8VRJ8 SjtLPjHWtNuv0pMuFtHg6a2Jh7HSUXt96HVF+2RcySb2IC2QxdilgtLQYf7fqrKLy0 oPykW2Z0eAKxfvmtDy2AuQpNB7zW+mxWx8Qo+z8lRvc5+lDBQ5vbQwwNAD1tjUp4VP W46QWVpxZU5cVDdi2xiSOEIA4Aou+m7YChX4uD4y5seECyH9q9zP8iOYgPAJfbWLRw caCg2KF8cu0umenRO1N2fY/uPRQqIqGjrWAaznZFfEKsoWAFa6LhCJVwna5Sp+FrNJ nRcl1uIXj0ESw== From: SeongJae Park To: Cc: SeongJae Park , Andrew Morton , Jonathan Corbet , damon@lists.linux.dev, kernel-team@meta.com, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org Subject: [RFC PATCH v2 07/10] Docs/mm/damon/design: document pass/block filters behaviors Date: Fri, 27 Dec 2024 13:08:16 -0800 Message-Id: <20241227210819.63776-8-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> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Update DAMOS filters design document to describe the pass/block behavior of filters. Signed-off-by: SeongJae Park --- Documentation/mm/damon/design.rst | 29 +++++++++++++++++++++++++---- 1 file changed, 25 insertions(+), 4 deletions(-) diff --git a/Documentation/mm/damon/design.rst b/Documentation/mm/damon/des= ign.rst index 5ebb572d0999..0265aaef2544 100644 --- a/Documentation/mm/damon/design.rst +++ b/Documentation/mm/damon/design.rst @@ -504,9 +504,30 @@ have a list of latency-critical processes. =20 To let users optimize DAMOS schemes with such special knowledge, DAMOS pro= vides a feature called DAMOS filters. The feature allows users to set an arbitr= ary -number of filters for each scheme. Each filter specifies the type of targ= et -memory, and whether it should exclude the memory of the type (filter-out),= or -all except the memory of the type (filter-in). +number of filters for each scheme. Each filter specifies + +- a type of memory (``type``), +- whether it is for the memory of the type or all except the type + (``matching``), and +- whether it is to allow (pass through the filter) or reject (block) apply= ing + the scheme's action to the memory (``pass``). + +When multiple filters are installed, each filter is applied in the install= ed +order. If a memory is matched to one of the filter, followup filters are +ignored. For example, let's assume a filter for passing anonymous pages a= nd +another filter for blocking young pages are installed in the order. If a = page +of a region that eligible to apply the scheme's action is an anonymous pag= e, +the scheme's action will be applied to the page regardless of whether it is +young, since it matches with the first filter. On the other hand, if a pa= ge of +the region is a non-anonymous page, the scheme's action will be applied on= ly if +the page is young, since the second filter is also applied. + +Note that DAMOS action is eligible to be applied to any memory that satisf= ies +other conditions if no filter is isntalled. Meanwhile, DAMOS filters work= for +only memory that satisfies ``type`` and ``matching``. It means installing= only +pass filters is same to installing no filter, because pass filters dont' b= lock +memory of type that not specified to pass. For any use case, at least one +block filter should be installed as the last one. =20 For efficient handling of filters, some types of filters are handled by the core layer, while others are handled by operations set. In the latter cas= e, @@ -516,7 +537,7 @@ filter are not counted as the scheme has tried to the r= egion. In contrast, if a memory regions is filtered by an operations set layer-handled filter, it= is counted as the scheme has tried. This difference affects the statistics. =20 -Below types of filters are currently supported. +Below ``type`` of filters are currently supported. =20 - anonymous page - Applied to pages that containing data that not stored in files. --=20 2.39.5 From nobody Sun Feb 8 21:26:29 2026 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 0A6901F9ED8; Fri, 27 Dec 2024 21:08:35 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1735333716; cv=none; b=NIGKkUtAP6xuTDNZlt4C/24NB0qHX4BtN/mqyx3uVxmNQAgraEeFzFUj5CMJmCJlSIRtB0/0VlvSp2k8ylr1IqOHkmLglSednTIb7WQNtYFgvqkXTXC7Q9iW58s1038xyQ7r7lNE6Rydx/eTNxprKDfBFY80JTXvdPECRMniDMA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1735333716; c=relaxed/simple; bh=juadYvUhIrNs11RvqR4w499ufNXf6y5+YZmNZP0gQvA=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=nGjqglVa7SYYWjY2IpfYqtvt46c8bwxmvL0uDK3Y6Y61Uwp4WyWKKCBPWXj5XYG+HqCDCfLZLopX3kguFvIAf8Ih7QOhlS+KEvtpQpsc+aWQEr+khmwwmlGPYJCVHF+kUNhJqOfqnApRxHTm+T69pAKBpAKTEgshdz6wYo4e7W4= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=m4IyBksl; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="m4IyBksl" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 5B803C4CEDE; Fri, 27 Dec 2024 21:08:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1735333715; bh=juadYvUhIrNs11RvqR4w499ufNXf6y5+YZmNZP0gQvA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=m4IyBkslGMKYZNJiLFIYRx7cTpBwDbq/1qFhzl7L6T1PYTVFM1+OgorJmrz4xylvM ao/itzf0xuv7qUN1uUK+TDDbpsTvfI2MesZHMaXTES2pHVNTg3dsJaPn3NSh2yptbh bnqNuivcLLBtEoYId3SzgGlnQhBymT+h9mLn+3e5IU3Vsp1DFNmC8jA4xzszug34ov YsB06gbpCsEDW/aFHYlm3o1Jh1yhSOlXd1WI22AYYnzAC+ombVa0jUEZ8YU2SdXfPG 2H1GP6jbShzIYX5XItEvjiRjCc9mjDSuNB/oLoXw2+4B5FtL8xMM/PZifQF0M5I+54 aq2LTcsIhiUGA== From: SeongJae Park To: Cc: SeongJae Park , damon@lists.linux.dev, kernel-team@meta.com, linux-kernel@vger.kernel.org, linux-mm@kvack.org Subject: [RFC PATCH v2 08/10] Docs/ABI/damon: document DAMOS filter pass sysfs file Date: Fri, 27 Dec 2024 13:08:17 -0800 Message-Id: <20241227210819.63776-9-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> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Update DAMON ABI document for added DAMOS filter 'pass' file. Signed-off-by: SeongJae Park --- Documentation/ABI/testing/sysfs-kernel-mm-damon | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/Documentation/ABI/testing/sysfs-kernel-mm-damon b/Documentatio= n/ABI/testing/sysfs-kernel-mm-damon index 8c0acb31638b..688bd27d8602 100644 --- a/Documentation/ABI/testing/sysfs-kernel-mm-damon +++ b/Documentation/ABI/testing/sysfs-kernel-mm-damon @@ -355,10 +355,16 @@ Description: If 'target' is written to the 'type' fil= e, writing to or What: /sys/kernel/mm/damon/admin/kdamonds//contexts//schemes//fi= lters//matching Date: Dec 2022 Contact: SeongJae Park -Description: Writing 'Y' or 'N' to this file sets whether to filter out - pages that do or do not match to the 'type' and 'memcg_path', - respectively. Filter out means the action of the scheme will - not be applied to. +Description: Writing 'Y' or 'N' to this file sets whether the filter is for + the memory of the 'type', or all except the 'type'. + +What: /sys/kernel/mm/damon/admin/kdamonds//contexts//schemes//fi= lters//pass +Date: Dec 2024 +Contact: SeongJae Park +Description: Writing 'Y' or 'N' to this file sets whether to allow (pass + through the filter) or deny (be blocked by the filter) applying + the scheme's action to the memory that satisfies the 'type' and + the 'matching' of the directory. =20 What: /sys/kernel/mm/damon/admin/kdamonds//contexts//schemes//st= ats/nr_tried Date: Mar 2022 --=20 2.39.5 From nobody Sun Feb 8 21:26:29 2026 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B0D901F9F53; Fri, 27 Dec 2024 21:08:36 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1735333716; cv=none; b=DCUP678+OA+m1yVlMhN+cO4eeS7KXfNdKxDscdfkAzeTJ/3YjI7JVSCMaov4+iRUlH3cT9dODq4EuchHvJc/B/R24DgfTT1XJ7BCAqbLTQ/nteffjvErnAjAwY/K5MncEORdlogq6GTEt7KWVdgERpxg4+cRUiwGr8pQA6/g+Ys= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1735333716; c=relaxed/simple; bh=0f0Lpal72vM2StRK6no1fT4yLv96CM7EUNHKZOxnDlE=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=JQVWaYlldXByoEKzbWgA2s5Dt5Wrsjc/e0x1u++lGcp7y6XliSHzpGSAPcwX94yhAaJ1beQXH/fEcgN58jmxyh3budjzezZ5w/rHdG8RabS1ag20eX7d7mCHFFe/6h5Kl5pGAbxxbjJ+9uEl4UZVdiObnsNZWcT7iTPJsQopTn4= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=tzYuJeoj; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="tzYuJeoj" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 658FFC4CED0; Fri, 27 Dec 2024 21:08:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1735333716; bh=0f0Lpal72vM2StRK6no1fT4yLv96CM7EUNHKZOxnDlE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=tzYuJeojgz6j6mJfTpQyOG4GrL1j41APF9tsSPSYFQMX0DRnSeBmavDD/7J/0/A69 AlAbH/E30qYO/C4wnJEZQjluLnWJUNF2/Ouoc/IbtS/FvYMYWvJXCVRpZAbK49Z9f7 bMWp+d+KqNhLT5aABhtLng25SkuvJL/ozeazzuc/oSNMBTfC9PdRZExmDViMp+0Lob n3toGZI8sjyyZpS7epAyEkSebAciE67v+CJt7vPdFnqtKadshGuq5tgg55c8Bktikh pBhUrrf2YHV8j1e19xhg0/dQF20QW8l3J/JKoXo1ujbba8Li9ykDVaNmIm7ulStnjs CRcSYClGGGNdw== From: SeongJae Park To: Cc: SeongJae Park , Andrew Morton , Jonathan Corbet , damon@lists.linux.dev, kernel-team@meta.com, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org Subject: [RFC PATCH v2 09/10] Docs/admin-guide/mm/damon/usage: omit DAMOS filter details in favor of design doc Date: Fri, 27 Dec 2024 13:08:18 -0800 Message-Id: <20241227210819.63776-10-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> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" DAMON usage document is describing some details about DAMOS filters, which are also documented on the design doc. Deduplicate the details in favor of the design doc. Signed-off-by: SeongJae Park --- Documentation/admin-guide/mm/damon/usage.rst | 29 ++++++++++---------- 1 file changed, 14 insertions(+), 15 deletions(-) diff --git a/Documentation/admin-guide/mm/damon/usage.rst b/Documentation/a= dmin-guide/mm/damon/usage.rst index a891e830c2a1..fa8a5e4199b1 100644 --- a/Documentation/admin-guide/mm/damon/usage.rst +++ b/Documentation/admin-guide/mm/damon/usage.rst @@ -417,13 +417,17 @@ Each filter directory contains six files, namely ``ty= pe``, ``matcing``, file, you can write one of five special keywords: ``anon`` for anonymous p= ages, ``memcg`` for specific memory cgroup, ``young`` for young pages, ``addr`` = for specific address range (an open-ended interval), or ``target`` for specific -DAMON monitoring target filtering. In case of the memory cgroup filtering= , you -can specify the memory cgroup of the interest by writing the path of the m= emory -cgroup from the cgroups mount point to ``memcg_path`` file. In case of the -address range filtering, you can specify the start and end address of the = range -to ``addr_start`` and ``addr_end`` files, respectively. For the DAMON -monitoring target filtering, you can specify the index of the target betwe= en -the list of the DAMON context's monitoring targets list to ``target_idx`` = file. +DAMON monitoring target filtering. Meaning of the types are same to the +description on the :ref:`design doc `. + +In case of the memory cgroup filtering, you can specify the memory cgroup = of +the interest by writing the path of the memory cgroup from the cgroups mou= nt +point to ``memcg_path`` file. In case of the address range filtering, you= can +specify the start and end address of the range to ``addr_start`` and +``addr_end`` files, respectively. For the DAMON monitoring target filteri= ng, +you can specify the index of the target between the list of the DAMON cont= ext's +monitoring targets list to ``target_idx`` file. + You can write ``Y`` or ``N`` to ``matching`` file to filter out pages that= does or does not match to the type, respectively. Then, the scheme's action wi= ll not be applied to the pages that specified to be filtered out. @@ -440,14 +444,9 @@ pages of all memory cgroups except ``/having_care_alre= ady``.:: echo /having_care_already > 1/memcg_path echo Y > 1/matching =20 -Note that ``anon`` and ``memcg`` filters are currently supported only when -``paddr`` :ref:`implementation ` is being used. - -Also, memory regions that are filtered out by ``addr`` or ``target`` filte= rs -are not counted as the scheme has tried to those, while regions that filte= red -out by other type filters are counted as the scheme has tried to. The -difference is applied to :ref:`stats ` and -:ref:`tried regions `. +Refer to the :ref:`DAMOS filters design documentation +` for more details including when each of the +filters are supported and differences on stats. =20 .. _sysfs_schemes_stats: =20 --=20 2.39.5 From nobody Sun Feb 8 21:26:29 2026 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 1E12C1F2C45; Fri, 27 Dec 2024 21:08:37 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1735333718; cv=none; b=M6rR9eShTGQzB09rGMJmpawhZbrS1VEmqzzF1v5iCOKCRoelVgYA6EtWfrnk/yaKW5bXJsgD9Na3Wo1hc4FYAzTOHvO+6JNfyjLM5oqPeKOAXhHktKGVaBiOpg8IB8iM7RxTyM0S4lca6sylkhjYxtDqD0rD/FXYo7fCDOwxIN8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1735333718; c=relaxed/simple; bh=ZbbHwYTvObdK/b1twjLv8JU3nRNHBdenJ+FrDPH80HA=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version:Content-Type; b=I2TdYhDB2wklZk6253leLwY+MorHyfp6MMJ0qfPqVMfdBKP9hl9LzO8grGchUTilwySHqjNvnVVSiEs5rQh4su6P+Zu3NwH8z/xWHs4apujL1l42Dh0IEGyjFj9o9jeDzBV5AvtLljz3z+DOBK+uKVNIZPh8pihuwlN1ui1mOjc= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=o5jlTrkx; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="o5jlTrkx" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 74C85C4CED6; Fri, 27 Dec 2024 21:08:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1735333717; bh=ZbbHwYTvObdK/b1twjLv8JU3nRNHBdenJ+FrDPH80HA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=o5jlTrkx5zTKZTuesqU5n+9f0OdlVA6hmzTbZPvQ5JKsJVX4iiWKvrhvlnTRd7OI1 jMg2scciox/wPAFbbig/SR6u3qijlgCxEEwgwM3B/YUnHK4It0ucwis2zE64g0yKnl O4Pk/AaoN0liR3uJS5oabbMQA8hX1kHsOca2EXsUNaG05xng6BhB7HbMJfnxS2fkme swIsyhbsbQT8JA67gSg8xulL9WxUmLaRtujGTryjBLHFdZl7HSd2+JrJi0koki9Y/Q gX59WWnzh00P4rEsKygPW7X7H0VMXN9ENEovOPWSQWlGqR5Ex+JT/AMUvxB1TUnanB 9kZE6ytcH8XLA== From: SeongJae Park To: Cc: SeongJae Park , Andrew Morton , Jonathan Corbet , damon@lists.linux.dev, kernel-team@meta.com, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org Subject: [RFC PATCH v2 10/10] Docs/admin-guide/mm/damon/usage: document DAMOS filter 'pass' sysfs file Date: Fri, 27 Dec 2024 13:08:19 -0800 Message-Id: <20241227210819.63776-11-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> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Update DAMON usage document for the newly added 'pass' sysfs file for DAMOS filters. Signed-off-by: SeongJae Park --- Documentation/admin-guide/mm/damon/usage.rst | 34 ++++++++++++-------- 1 file changed, 20 insertions(+), 14 deletions(-) diff --git a/Documentation/admin-guide/mm/damon/usage.rst b/Documentation/a= dmin-guide/mm/damon/usage.rst index fa8a5e4199b1..ab343d6ac771 100644 --- a/Documentation/admin-guide/mm/damon/usage.rst +++ b/Documentation/admin-guide/mm/damon/usage.rst @@ -89,7 +89,7 @@ comma (","). =E2=94=82 =E2=94=82 =E2=94=82 =E2=94=82 =E2=94=82 =E2=94=82 =E2=94=82 = =E2=94=82 =E2=94=82 0/target_metric,target_value,current_value =E2=94=82 =E2=94=82 =E2=94=82 =E2=94=82 =E2=94=82 =E2=94=82 =E2=94=82 = :ref:`watermarks `/metric,interval_us,high,mid,low =E2=94=82 =E2=94=82 =E2=94=82 =E2=94=82 =E2=94=82 =E2=94=82 =E2=94=82 = :ref:`filters `/nr_filters - =E2=94=82 =E2=94=82 =E2=94=82 =E2=94=82 =E2=94=82 =E2=94=82 =E2=94=82 = =E2=94=82 0/type,matching,memcg_id + =E2=94=82 =E2=94=82 =E2=94=82 =E2=94=82 =E2=94=82 =E2=94=82 =E2=94=82 = =E2=94=82 0/type,matching,memcg_id,pass =E2=94=82 =E2=94=82 =E2=94=82 =E2=94=82 =E2=94=82 =E2=94=82 =E2=94=82 = :ref:`stats `/nr_tried,sz_tried,nr_applied,sz_applied,= sz_ops_filter_passed,qt_exceeds =E2=94=82 =E2=94=82 =E2=94=82 =E2=94=82 =E2=94=82 =E2=94=82 =E2=94=82 = :ref:`tried_regions `/total_bytes =E2=94=82 =E2=94=82 =E2=94=82 =E2=94=82 =E2=94=82 =E2=94=82 =E2=94=82 = =E2=94=82 0/start,end,nr_accesses,age,sz_filter_passed @@ -412,13 +412,14 @@ number (``N``) to the file creates the number of chil= d directories named ``0`` to ``N-1``. Each directory represents each filter. The filters are evalu= ated in the numeric order. =20 -Each filter directory contains six files, namely ``type``, ``matcing``, -``memcg_path``, ``addr_start``, ``addr_end``, and ``target_idx``. To ``ty= pe`` -file, you can write one of five special keywords: ``anon`` for anonymous p= ages, -``memcg`` for specific memory cgroup, ``young`` for young pages, ``addr`` = for -specific address range (an open-ended interval), or ``target`` for specific -DAMON monitoring target filtering. Meaning of the types are same to the -description on the :ref:`design doc `. +Each filter directory contains seven files, namely ``type``, ``matcing``, +``pass``, ``memcg_path``, ``addr_start``, ``addr_end``, and ``target_idx``= . To +``type`` file, you can write one of five special keywords: ``anon`` for +anonymous pages, ``memcg`` for specific memory cgroup, ``young`` for young +pages, ``addr`` for specific address range (an open-ended interval), or +``target`` for specific DAMON monitoring target filtering. Meaning of the +types are same to the description on the :ref:`design doc +`. =20 In case of the memory cgroup filtering, you can specify the memory cgroup = of the interest by writing the path of the memory cgroup from the cgroups mou= nt @@ -428,25 +429,30 @@ specify the start and end address of the range to ``a= ddr_start`` and you can specify the index of the target between the list of the DAMON cont= ext's monitoring targets list to ``target_idx`` file. =20 -You can write ``Y`` or ``N`` to ``matching`` file to filter out pages that= does -or does not match to the type, respectively. Then, the scheme's action wi= ll -not be applied to the pages that specified to be filtered out. +You can write ``Y`` or ``N`` to ``matching`` file to specify whether the f= ilter +is for memory that matches the ``type``. You can write ``Y`` or ``N`` to +``pass`` file to specify should this filter let the memory that satisfies = the +``type`` and ``matching`` pass though (allow) or be blocked by (reject) the +filter. Allowing means the scheme's action will be applied to the memory. =20 For example, below restricts a DAMOS action to be applied to only non-anon= ymous pages of all memory cgroups except ``/having_care_already``.:: =20 # echo 2 > nr_filters - # # filter out anonymous pages + # # block anonymous pages echo anon > 0/type echo Y > 0/matching + echo N > 0/pass # # further filter out all cgroups except one at '/having_care_already' echo memcg > 1/type echo /having_care_already > 1/memcg_path echo Y > 1/matching + echo N > 1/pass =20 Refer to the :ref:`DAMOS filters design documentation -` for more details including when each of the -filters are supported and differences on stats. +` for more details including how multiple filt= ers +of different ``pass`` works, when each of the filters are supported, and +differences on stats. =20 .. _sysfs_schemes_stats: =20 --=20 2.39.5