From nobody Fri Dec 19 20:53:10 2025 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 E26351F63FE; Tue, 7 Jan 2025 20:18:09 +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=1736281090; cv=none; b=eUtkBhlZsVrtvjy87ZKsBLeOoGj1IcZywxX36np3NxZPPGOWhivOWCTKwSm0PNu8CuOItJ4CXB+kFaxzqwhmh00osSRPpyJD91LLgxqjCjaVGNHmFHzssyu7IwVKhR3QH4cR0sp07mnmfy2qS6e6SMq7L6Gl1DBklluMBBBcBxQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736281090; c=relaxed/simple; bh=97I76lDfvaM6L2LOAAduyShBBxqQhcZ1zQRaRPWTvuU=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=N8v2NL4BuBrlwTGMjFYdkT4hUwlwSikxO+yi5kgQZbqUyGle0KZcQy/PuV8eNM/kf/B9gHpdPHSPcVmq7x3SOGtqO6NRCQSiIGwUHhx89ZXhQV756TLjVzUS5hTP8C70RApch9/Z7nTgfADsr3C/jjd/yBTwZMDhxw9BXUtfixY= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=sjMBpWAI; 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="sjMBpWAI" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 3B874C4CEDE; Tue, 7 Jan 2025 20:18:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1736281089; bh=97I76lDfvaM6L2LOAAduyShBBxqQhcZ1zQRaRPWTvuU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=sjMBpWAIL0F+1FBB03PXptlqXI5T1nzKca9WFZ4dkXqiSWkqFFNLPc5FewJragYFo PHRjacKSyjgfSmKHiElJMUHk+Ispxlbfx4rXzxWPsIIP5YOGUvOQGgKU/+sUWL9eA0 a7h4Xm/ZxaZ7/whlpg0x3PXzW70D517Oozp/7iBdzkJ0qCrBa0ag+fKEQY7bpfdKqO hhBcnVqucCBCsivL3cu3sWicCS3EtgbNMEOeCvpLBPIcVR8GEymQDsMurSfo/71k+a 8mDcL1f6i5mJ8fbP/FHPEuEs/pv2tKww3/ovQRMwFUSBSDa2YJx9kVxqlASSrP63++ tedpPoOWjAODg== From: SeongJae Park To: Andrew Morton Cc: SeongJae Park , damon@lists.linux.dev, linux-kernel@vger.kernel.org, linux-mm@kvack.org Subject: [PATCH 01/10] mm/damon: fixup damos_filter kernel-doc Date: Tue, 7 Jan 2025 12:17:30 -0800 Message-Id: <20250107201739.79484-2-sj@kernel.org> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20250107201739.79484-1-sj@kernel.org> References: <20250107201739.79484-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 298b1a831e62..72afba74ac6d 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 Fri Dec 19 20:53:10 2025 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 EEB0D1F709F; Tue, 7 Jan 2025 20:18:10 +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=1736281091; cv=none; b=IUANmrbCkvbaqQJIeFbXvseHOCSN4xj0GVwxqEZoRY1BYkZI3GImomYPIeiR7e/xX1VlW6RZeIzXB2yr0zwMJ0BOSBzmkNSD2Jh3PlMVUk8jH6bgl06vRSt4hmtI7nML6maNjy/hP4qkclzUIuxs5Wz5uqasw/ibQUw1BoQ8H/k= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736281091; c=relaxed/simple; bh=ChVZwNMuI/bsAh0W8ok2wqpnVeqESRBGmTcn2DPnef0=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=IlnHJqL+0Adzy9TnTdN3BCpoMkOxjSYqcDn4lUf9BQhOSSMRHVahYdH8OCc1zt9xO2yVzi/u6Pz5ExjOH0teG/JLQli4XwJUVEyUcz6uUWGPhKaJYZJS36/94KID/qoW7VTgmSD8Agmza23rza20NVa+UJNKseLB8ODSm/LR6q4= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=ZIWbmkCF; 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="ZIWbmkCF" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 569CFC4CED6; Tue, 7 Jan 2025 20:18:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1736281090; bh=ChVZwNMuI/bsAh0W8ok2wqpnVeqESRBGmTcn2DPnef0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ZIWbmkCF3+DLxU4uCCvggXf/JXln14DDVlxSUH0FgTRRshNE8iKyxdroUJnsGPmaK EB1FBF5+V+7KQW4otNae+aZTWIQ+q5ddFZLBTJx/xR5ANK6saj1wEqmVkJ9rmJ3Yec wxTW/2EarAmiOmoBxh9SMXFKVFDKNYsVKBlWgkkMk08R29R8Jcj6Q0ZVh1qlV+myfW 8Kgm96dyYY00511DZGeFqsOpU7GF7HNhqQpiGpFC5ObOVEtjZkKq0Ish0VpEXWZapZ yVcx2Ed+SNg23fVcvkBNH5lv+2nPpjQv1iaqDRGQ+1ELMDqMDxw+P3rr+caS9hlRMk NfLNkN8yEdaHA== From: SeongJae Park To: Andrew Morton Cc: SeongJae Park , damon@lists.linux.dev, linux-kernel@vger.kernel.org, linux-mm@kvack.org Subject: [PATCH 02/10] mm/damon/core: add damos_filter->pass field Date: Tue, 7 Jan 2025 12:17:31 -0800 Message-Id: <20250107201739.79484-3-sj@kernel.org> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20250107201739.79484-1-sj@kernel.org> References: <20250107201739.79484-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. Add a field anmed 'pass' to damos_filter. The field will be used to indicate whether the filter should work for inclusion or not. Following two commits will make the core and operations set layer, which handles the damos_filter object, respect the field, respectively. 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 72afba74ac6d..baeb884ed156 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 Fri Dec 19 20:53:10 2025 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 1DD2E1F75B1; Tue, 7 Jan 2025 20:18:11 +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=1736281092; cv=none; b=L1LOXYW7Jm/oYt5op06Dnm+kC3X06HweC2QZYHkDOHXlJ9/HkQWuicKtDpS3YClHS5hlT9FkdVl1u2C/Xzx4yXeL0yxPrimvAKFHVFtNCvyw1JB3RJKs+chFW5xwFhOq0tJl0eY0Bcef1IipjRXR14nhII0XziM4R/VxGeKSSso= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736281092; c=relaxed/simple; bh=8dJ+7o3sCM8L0VHB+MIi4xnhlr9EGI5a92hneWpjd7A=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=ubfw2OckpW63zX4Q1PgwFPZvyEfdeehFqYWSgsbe8TUTL69dPWN7KHH+UafR3UUzq0lCds9JNCkclUBFUGhM/B5RkEQGueiwyX7thwykNX36vIjsclsxOTbFbylQ+ce0+WOXzHxyhNJ0Cj5G1ybUkUYa346j1qiFcfjB9t4OpfQ= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=CWU0WB/N; 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="CWU0WB/N" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 6731EC4CEE4; Tue, 7 Jan 2025 20:18:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1736281091; bh=8dJ+7o3sCM8L0VHB+MIi4xnhlr9EGI5a92hneWpjd7A=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=CWU0WB/NlOmPRlgpVp5m6RizW/pJ7oVD8+xl/FMKgbU+0l849UfMQ+bx5pW52r/0c BhraHHr+hJTeDKyZWncd/S20vMMjbhTnHWP80XDrChQe5eXeoDOqFUHwSXm4oYxeW9 OIei9pW07xsVcqt8umUfH4Aq2WKPjmPC8JR3CjgGOSgM0M5+LbKE1Zvlz418cHYKy9 O+dLe6tmh+Gf+eEUjfh7ilHJL8FKyHiTpBstSaqYLvEphpK2h5W3+UCowXPsKMPrB+ IApVUYru99Kv9kHVsac+1s1qT3KXq6ayNiit4h1VoypnP+BdLicKGj95Vu012enfPx 3KtCbp1sNaPHQ== From: SeongJae Park To: Andrew Morton Cc: SeongJae Park , damon@lists.linux.dev, linux-kernel@vger.kernel.org, linux-mm@kvack.org Subject: [PATCH 03/10] mm/damon/core: support damos_filter->pass Date: Tue, 7 Jan 2025 12:17:32 -0800 Message-Id: <20250107201739.79484-4-sj@kernel.org> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20250107201739.79484-1-sj@kernel.org> References: <20250107201739.79484-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" Respect damos_filter->pass from core layer's DAMOS filed handling logic, by making the decision to pass a region in the middle of the filters evaluation depending on the damos_filter->pass field. 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 Fri Dec 19 20:53:10 2025 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 EC89C1F76BD; Tue, 7 Jan 2025 20:18:12 +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=1736281093; cv=none; b=uyGj7ybY1/VXgwt9GJ5k1vdNy4qYTHHmRnAkcA9ZaMYv/zCQeTWuRwIbJ6rU6SbBi94290gE4dV8eX2OsCwBCPyGTHZofvHmhdgJbLANow57sJ67AI7iTNmsNDSjBq3Z5glf0C2SuE8lQcYrs5QqRI83stpfpFAOME+TPZlQVW8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736281093; c=relaxed/simple; bh=tuhpVdSKJ2wYJgPTltwUOs4MNNvfzkT5HUY0DvCph2Y=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=BdC0MdnhESiMTWyQ8YG244qVGxZPKOLHIXTH/8OYCabfUS8DyC7scFeRp2BlqGUCCBd5PIrYY/TrFNK/ZxAnhxXr7Hz6SFDxcWOQUqPm20TkiaN//9z8krHIfvsiD9hfDkJ6K0Q9wEOmcrOCu65rPl2ia1mFx0C9NShM45PEoYc= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=Ap52vc9L; 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="Ap52vc9L" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 7607CC4CED6; Tue, 7 Jan 2025 20:18:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1736281092; bh=tuhpVdSKJ2wYJgPTltwUOs4MNNvfzkT5HUY0DvCph2Y=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Ap52vc9LCXHiCrhKByqmNaZeFczwv/M3myDnZsagTT2jKr3KDAlahQJP9r5GqYAmv WhKuWXffp4rYtiwln3h1pBXvNPlXzU5tSlvAD+ws9ysKEeBkh3meWpdRD0at3HjVj0 B6Hq4BehmjXL9thObdsImAwxK7v2vNkDpEhocsaSygZgLDB5wF0SdLxwu4IKQqnvOc 9Z0iH54fE6QJLIO1AKsEAcxKJ7AN5BMaRMldWHKy/oMeF+1X3FzQLLP8URzqoY7/ZH lfW/eDK4hEYKmg6YfVEWrTK2waCVR/PjjspebITjSF3NVv4J8tOWw+rvDOyehpGgYf 31sLK6Tcvtk1A== From: SeongJae Park To: Andrew Morton Cc: SeongJae Park , damon@lists.linux.dev, linux-kernel@vger.kernel.org, linux-mm@kvack.org Subject: [PATCH 04/10] mm/damon/paddr: support damos_filter->pass Date: Tue, 7 Jan 2025 12:17:33 -0800 Message-Id: <20250107201739.79484-5-sj@kernel.org> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20250107201739.79484-1-sj@kernel.org> References: <20250107201739.79484-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" Respect damos_filter->pass from 'paddr', which is a DAMON operations set implementation for the physical address space and supports a few types of region-internal DAMOS filters (anon, memcg and young). The change is similar to that of the previous commit for core layer update. 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 Fri Dec 19 20:53:10 2025 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 253AB1F8666; Tue, 7 Jan 2025 20:18:13 +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=1736281094; cv=none; b=Ll+uo3yD8DluFFBGnz5QPi3ftOsW59cgBH9WMmOKYCYRdSP7baHScn6CN6Izh0AnNYG6/WjAU1+uPC6wZFii6WOqvmDzR8CKvjOdev9/mXeSfr/IYHM+94SZjOjvuP38H8OaZNNrFOnHIcfsGMh17xj4MBy+Uu/zPVyjYaQunbs= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736281094; c=relaxed/simple; bh=SeGgDvPfXuXgeFvtGluC78K25dToIj5MV+FyPl+BzUU=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=qDcXCfKmtCep1o35ratt+2BmQyQ0NBeDff8plc13sy36+PShTUOe5Dm1/QsVYP+w1lhJEe+c4zTzot5mBiJqDfnVj03tcwS5zSJBk63/hArfiOXX6/B1Rn9sUQ1POUVJvgUGD9wb5PvwKB7n3mPGNpb6T+Zj79O4oknFkBPCa08= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=OxeN3wM1; 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="OxeN3wM1" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 8E427C4CEDE; Tue, 7 Jan 2025 20:18:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1736281093; bh=SeGgDvPfXuXgeFvtGluC78K25dToIj5MV+FyPl+BzUU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=OxeN3wM1Vi1ShZ4pD2Rd4hdVw6Q7pn9tsFM/OnmFfbLKq4vdhzB8yi0XG9CUdls77 nDdeUxE1UjCDw9/z8lYYUtlYUSnh/cIhMGztGIxuZf+QPxJS9prq0NBjr+ym28T3kU gV9SOvM/KWk/rtRb0zI77NdRZJ7ldMThEWIbUhpEkMVPBtJGJ/N++5WuWzFsiR3rx+ 8/vbaa97U8+Vu9KJHF2kzFc9y/T5co7hS9ezK5u9UnTK/Wk9Kt0zr5/hByOAOb94+z GcnUN7id7QXHugoMQ+PmBGYtA/JF/vt+PzYaHwDc9qNXihcnUwjLQsj25XkllfjBGh p46hnywfBlBMw== From: SeongJae Park To: Andrew Morton Cc: SeongJae Park , damon@lists.linux.dev, linux-kernel@vger.kernel.org, linux-mm@kvack.org Subject: [PATCH 05/10] mm/damon: add pass argument to damos_new_filter() Date: Tue, 7 Jan 2025 12:17:34 -0800 Message-Id: <20250107201739.79484-6-sj@kernel.org> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20250107201739.79484-1-sj@kernel.org> References: <20250107201739.79484-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 API users should set damos_filter->pass manually to use a DAMOS pass filter, since damos_new_filter() unsets the field always. 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 baeb884ed156..27593dadbd76 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 Fri Dec 19 20:53:10 2025 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 630641F869A; Tue, 7 Jan 2025 20:18:15 +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=1736281095; cv=none; b=HA6YghPEtX9N16e8nm0mavjHrcSilMcfRz4sK51F7Yi0xq/r48Hqchr/edIDEbkoo+6fe3Ol1bxmIfx9TMG4aCsePbTzUt1Nm5IOtvUg6GaV6nJLhdEWfRYCYTLHovd5VSNEUAZCTbAddHRerg8XeWZ14lvEG2dFt5N4drgGSdM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736281095; c=relaxed/simple; bh=ZERQXRIpbhEDVEpD6J6LgTdFsTQpbeeZuCqI48fC6sI=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=nbHz+WHSQk8NF5FAylSnItntVlhDSzEPoZXO2nmeAFeC4t6dP+5KYP3I4DgF+RDlJ8wXXxEZQ9cacukie6jRXNTbsu8Z733WzYVRqELE6Djyxj3EoRkaOPn0C4L1e4jN9UnvNYUvXBgVypoItDjF34McL1OI3BI1vqodlHZE7Vw= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=slJilpwI; 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="slJilpwI" Received: by smtp.kernel.org (Postfix) with ESMTPSA id AE4C5C4CED6; Tue, 7 Jan 2025 20:18:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1736281094; bh=ZERQXRIpbhEDVEpD6J6LgTdFsTQpbeeZuCqI48fC6sI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=slJilpwIOoWc2ruriXmweZYgn+/8so1cWoZ3VtcHYglEtfsQV3O5P/QcknYVWIl/6 Uj0dxHDQ4mFZQtIY755fd7pfC0oFdHjkFMyPMYtjAbmXbFcUggxCRpTakGpP852ZIB 7AgH7fKhj9cBedscF09kRtT7rEtw32LCiK+0HpAhqMMZ1JiQgmQivgjQMx/tI5jI3A Y+psKcsEi6caa/3wxr3kuMlvxtQf7UOsp50JIS4qNs8zIqExutcm3WC5DPjUbSxBgC 6PaUBjyu6mJA6AOD3Cr8srUrjYMY890PaT0zEfQlMEtz77lbUXwCgu7u6xQOFnC1/O JQnwkn3DV+TLA== From: SeongJae Park To: Andrew Morton Cc: SeongJae Park , damon@lists.linux.dev, linux-kernel@vger.kernel.org, linux-mm@kvack.org Subject: [PATCH 06/10] mm/damon/sysfs-schemes: add a file for setting damos_filter->pass Date: Tue, 7 Jan 2025 12:17:35 -0800 Message-Id: <20250107201739.79484-7-sj@kernel.org> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20250107201739.79484-1-sj@kernel.org> References: <20250107201739.79484-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 Fri Dec 19 20:53:10 2025 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 248411F891F; Tue, 7 Jan 2025 20:18:16 +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=1736281096; cv=none; b=pBt34/b0YNSqIaIpP7wtw6EtCa9W0UTqsbcegENVXcowcmKUxN40X2AVSSB7MtUHQAIcFaiTjWfTJwTs/4OznOPQh7EZ5q76tmttX1E2otsaa+HxegvrPpaNOTT0TW8/3oefp2Q3W7X8h/XApgFrTJtjkPoqrk4ZANOrGfvwu9k= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736281096; c=relaxed/simple; bh=HXA5UPYM/GgxhLgL56pBJuUIhF/kTZ/VCy8SKfZbnOs=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=bS5x/LGjJsMZC592GYw9kO+K0APjv59kCIfir1ol4oH+AuyFw3UOyIGIORxSn4YEgLSgIjit/Uq/sOsm+sKyAYiIgdqY7KY80kWKH/27GwpA5OdBVofmomUYXFofGqiNmpAXSeThjblnX6zxNyvFqqP3273KJ5hw5It1o97M/2w= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=AkcueAy9; 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="AkcueAy9" Received: by smtp.kernel.org (Postfix) with ESMTPSA id CF4E6C4AF0C; Tue, 7 Jan 2025 20:18:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1736281096; bh=HXA5UPYM/GgxhLgL56pBJuUIhF/kTZ/VCy8SKfZbnOs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=AkcueAy99tJZzibzNuROIjVEKSp3HVa0hplQr2dlkw1Gb4ZhWDBNd/cLD/u/ExntH 1S/U5SbspW4U4kLrmfEBFI6cn8HblH6UfAiESFY4H8iIbszBodE56UyX7SMBYU6WXz HVYY7E7ePgU6U6V+HYBMV5VdL1FLM/XgidFBv/I6K+8a6YcRCd/pjavVsIt5/57KGX MwyETpH0e2xqRJOjCZIdiskc7WpdNznQpjK9OKaF+Mhw9Uqry1eCro0XRRfVCB4ozr KIz6kJd4eaY1KZj4C97MNDy1IZwc1WP6gJErNxNCPX6D5NYyYCj7liTu3SrtGNfBKi z0G4cHcLCp99g== From: SeongJae Park To: Andrew Morton Cc: SeongJae Park , Jonathan Corbet , damon@lists.linux.dev, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org Subject: [PATCH 07/10] Docs/mm/damon/design: document pass/block filters behaviors Date: Tue, 7 Jan 2025 12:17:36 -0800 Message-Id: <20250107201739.79484-8-sj@kernel.org> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20250107201739.79484-1-sj@kernel.org> References: <20250107201739.79484-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 | 34 +++++++++++++++++++++++++++---- 1 file changed, 30 insertions(+), 4 deletions(-) diff --git a/Documentation/mm/damon/design.rst b/Documentation/mm/damon/des= ign.rst index 449eb33688c2..3682e719b8a6 100644 --- a/Documentation/mm/damon/design.rst +++ b/Documentation/mm/damon/design.rst @@ -504,9 +504,35 @@ 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 evaluated in the insta= lled +order. If a part of memory is matched to one of the filter, next filters = are +ignored. If a part of memory is not matched to any of the filters, the de= fault +behavior is applied. That is, as long as it fulfills other conditions of = the +scheme including the access pattern and quotas, the action will be applied= to +the part of the memory. + +For example, let's assume 1) a filter for passing anonymous pages and 2) +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 or not, since it matches with the first filter. If the page is not +anonymous but young, the scheme's action will not be applied, since the se= cond +filter blocks it. If the page is neither anonymous nor young, no filter is +involved, so the action will be applied to the page. + +The fact that the action can be applied to any memory as long as no block +filter explicitly excluded it means that installing pass filters without a= ny +block filter after those is same to not installing the pass filters, in te= rms +of the ``action`` applying. Statistics for DAMOS filters will still be +accounted, though. It is therefore still useful for monitoring purpose. =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 +542,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 Fri Dec 19 20:53:10 2025 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 90CC71F8AE9; Tue, 7 Jan 2025 20:18:17 +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=1736281098; cv=none; b=ST85vV5+dos6Pjw+jpLzxXDnaPxp2t50kjgPQjc8Yha8N9+zYB5hV4GciV9ulCpOEtMS4Sug1LYZYLQnOO0qf+GPSZbMQKUmarlrFvMkiLVeQU2EzUTc2VbonHeufblNE2ZTG08Sae5ZmiFFJVdYf6HyP1lQiQF2Rx/3QWiq500= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736281098; c=relaxed/simple; bh=juadYvUhIrNs11RvqR4w499ufNXf6y5+YZmNZP0gQvA=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=Q63VSiVb1/QHk3f9Dy2hZUSGPx7CzZNHw0FVbllGXtmNsjeL1psWnHbpkRb1Ib9b/pq+q/je4eL42umzwKyW1DsBeBjO0B2mEZbOZLFhDhKG71EPegqiYVERwuJTHwFFzA6fJZMvLee8O+pSDB/8luZA2QVbCOPKBwaiTR3B3iE= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=VbdBW1E9; 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="VbdBW1E9" Received: by smtp.kernel.org (Postfix) with ESMTPSA id F20F9C4AF09; Tue, 7 Jan 2025 20:18:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1736281097; bh=juadYvUhIrNs11RvqR4w499ufNXf6y5+YZmNZP0gQvA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=VbdBW1E9YONp1KjOtXnLbXq53XWAzctVY97ritUODquibRxUPZZWiU5WkzWFXjWRY kU2UIFngMpXjNhx655Rrt+wkjr2ZCe5TRPd/ek/hZ6zWiYaNUm5vrpDbW6/Zh4BEHj D8iSZ005boFIlqHbL5Ml5NfI1Pv7D9s946fqPhleNWK8z0DW61x0o/Bnth/rP/bSJ4 SR9DGqZJ/0fJ0mIw7A4zcp2NXX2edgROmOyrZ+PpvFj3fObM3QtELW2Knf5e/F2I2I shbTXX1RbNLRguI7G75mWmQA3Y2IKE9EyRCd8uwvOI3o8DlKWYjXlJmhESDXDyskhz z1pmCBCFhzegA== From: SeongJae Park To: Andrew Morton Cc: SeongJae Park , damon@lists.linux.dev, linux-kernel@vger.kernel.org, linux-mm@kvack.org Subject: [PATCH 08/10] Docs/ABI/damon: document DAMOS filter pass sysfs file Date: Tue, 7 Jan 2025 12:17:37 -0800 Message-Id: <20250107201739.79484-9-sj@kernel.org> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20250107201739.79484-1-sj@kernel.org> References: <20250107201739.79484-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 Fri Dec 19 20:53:10 2025 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 D8FC11F8AF4; Tue, 7 Jan 2025 20:18:18 +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=1736281099; cv=none; b=lNip2TpCnc8A9cjApC3xHDpmPCdCTJ6MBttMLViNTtLg9NDAj65mCU4hy4qEwJbCY8qPeMmIqAaOm1Mk9OK6oxyfdPMy1XYEK3OlWLNz8ElIdOTkoocrrJzhFh/Z7YGlLisJ5xhRKQ7sgrY94g4izH8gzYdxIUJKbOLwETMpWSQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736281099; c=relaxed/simple; bh=jufb0sHL1L5krYu5xZ9uPN7YQ+OC0Evk60XYWVCJy7g=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=jjAiCuzw7VeYZJmIhA0/q46q+q2jQRYbNGq0WfL7DLJ8OYwOmZnb8tTgYpcqsFMiXVsy1M0BFxaoktkzYuipiw2R+zFbY8o33FFDRoBCsZiGtcQTFCKgyf6JX9nIeinuoRlgQDZLupbzBEQ4NdJBcPHJmzedq8oGINnQHAf0iQw= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=rRBPMc02; 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="rRBPMc02" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 3FD29C4CEDD; Tue, 7 Jan 2025 20:18:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1736281098; bh=jufb0sHL1L5krYu5xZ9uPN7YQ+OC0Evk60XYWVCJy7g=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=rRBPMc02CwogiTNi5E146sB1ifHgBJA2nZgVoBsESH66eEv+lycI38Q0SlqUy/xOb NMjHjZ2SEar/bVvmTWvwe3wt+Ux5Q844tzODLcdHJIrM4z5n4hz46NI0Io8laCjXPv ihZwM/eHP4dY8rtp+QXrFDijR6eGOxOw/OfKBab9RajpdYr5N+dkpD1hdDn9DeY1BM 7sw5pC7TaW6wJY0E2yUVytvSrPLTWV0C3GQTVMQh54VcSxYJq/qQ/wgbqx81AtrBiW jCYlXyACtoCqGDvcV2hLKxjDlfpI/SDXQ2UJ/ad0hTi6/yF0bHa6KpNFi83UWmk1wv af20A1eVXJHSg== From: SeongJae Park To: Andrew Morton Cc: SeongJae Park , Jonathan Corbet , damon@lists.linux.dev, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org Subject: [PATCH 09/10] Docs/admin-guide/mm/damon/usage: omit DAMOS filter details in favor of design doc Date: Tue, 7 Jan 2025 12:17:38 -0800 Message-Id: <20250107201739.79484-10-sj@kernel.org> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20250107201739.79484-1-sj@kernel.org> References: <20250107201739.79484-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 71cf29ae8502..8df3357dcfa3 100644 --- a/Documentation/admin-guide/mm/damon/usage.rst +++ b/Documentation/admin-guide/mm/damon/usage.rst @@ -411,13 +411,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. @@ -434,14 +438,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 Fri Dec 19 20:53:10 2025 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 AD8141F8EED; Tue, 7 Jan 2025 20:18:19 +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=1736281099; cv=none; b=OIRzyvGWY+EZa0svkPbFcak/cLay23g9On21Zihm/aelHTwK0kGQSk6Wq8XbqMyFJ8es2lbRDOIusA/urSeQHepGqVIEeZzDLkFRmkxIr3qL/rshe+MSPBlcXsiV0u45QxI0r7HJtUOedXmoIHpotr2vfPu2E7UQKjDUxH/0y64= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736281099; c=relaxed/simple; bh=jFfn5t+dponFAGP3JrCrxaFExzSUl0AtcYmSwZg8NL8=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version:Content-Type; b=q0JQybbe/S+dSetr9cFDd8ZU/LZYNiY8UWCfR+53Zwx0OOBDRQ23Da6kxaaCupORTn03QLjGBeqzUz7Qx+15H4j/5JJtRAuqd3eYe/L5ImY7RT+8fRWNqWaURWmZJwvK4vUnyNpzvNQNhIhYVBqugcRWDfHTMpYs/gDLwbqzm6c= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=ell3Q7Yy; 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="ell3Q7Yy" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 653BCC4CEE0; Tue, 7 Jan 2025 20:18:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1736281099; bh=jFfn5t+dponFAGP3JrCrxaFExzSUl0AtcYmSwZg8NL8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ell3Q7YyhnMjQuSHIgsYWdtxHKNCvQFvRlshmwRsgkIDZEu8EuiOyfjNdUmTLSTCn IBqPoOoSLWO0vZZUfc0dj7R8xfulqbLkAam9UNg1AC/MWNZdeXPvUv6BWO0VQFCsX9 ZmjgVBfqS5AUEo3zaH43JvbCq2sVU0RndAmQykdMOFZZNuvTSyMHdLXxhCEov9t9pl Yv247oIGa4qDtKX1II71Bj83kdG9XBcw8w6MVxruhWxF7FvYCBqP5BPuIf0yab2aYV Tk1UOyrtxbtg1LghJlv5zea4jl51FbkyGnIMnKRTMlTRB8KSDG+5PGBlyiRcg0nswr e7qUcvirZ6mSw== From: SeongJae Park To: Andrew Morton Cc: SeongJae Park , Jonathan Corbet , damon@lists.linux.dev, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org Subject: [PATCH 10/10] Docs/admin-guide/mm/damon/usage: document DAMOS filter 'pass' sysfs file Date: Tue, 7 Jan 2025 12:17:39 -0800 Message-Id: <20250107201739.79484-11-sj@kernel.org> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20250107201739.79484-1-sj@kernel.org> References: <20250107201739.79484-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 8df3357dcfa3..77064c704bf2 100644 --- a/Documentation/admin-guide/mm/damon/usage.rst +++ b/Documentation/admin-guide/mm/damon/usage.rst @@ -83,7 +83,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 @@ -406,13 +406,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 @@ -422,25 +423,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