All of lore.kernel.org
 help / color / mirror / Atom feed
* [RFC PATCH v1.3 00/11] mm/damon: update, optimize, and clean up doc, tests, and code
@ 2026-06-26  0:16 SeongJae Park
  2026-06-26  0:16 ` [RFC PATCH v1.3 01/11] Docs/mm/damon/design: update for DAMOS_QUOTA_NODE_ELIGIBLE_MEM_BP SeongJae Park
                   ` (10 more replies)
  0 siblings, 11 replies; 18+ messages in thread
From: SeongJae Park @ 2026-06-26  0:16 UTC (permalink / raw)
  Cc: SeongJae Park, Liam R. Howlett, Andrew Morton, Brendan Higgins,
	David Gow, David Hildenbrand, Jonathan Corbet, Lorenzo Stoakes,
	Michal Hocko, Mike Rapoport, Shuah Khan, Shuah Khan,
	Suren Baghdasaryan, Vlastimil Babka, damon, kunit-dev, linux-doc,
	linux-kernel, linux-kselftest, linux-mm

Patches 1 and 2 update the design and ABI documents for recently added
DAMON features.  Patches 3-7 add or update more unit and self tests for
DAMON to cover recently changed or added functions and sysfs files.
Patch 8 optimizes damon_commit_target_regions() to skip unnecessary
adjacent ranges setup.  Patches 9-11 clean and fix up recently added
DAMON sysfs interface code for readability.

Changes from RFC v1.2
- RFC v1.2: https://lore.kernel.org/20260625142357.103500-1-sj@kernel.org
- Fix broken sphinx syntax in patch 1.
- Drop unused counts[] for damon_rand() test in patch 3.
Changes from RFC v1.1
- RFC v1.1: https://lore.kernel.org/20260625050756.91115-1-sj@kernel.org
- Document nid requirement for node_eligible_mem_bp.
- Fix typos: s/memmcg/memcg/, s/geets/gets/.
- Drop damon_rnd() randomness test case; test boundness only.
- Fixup dests dir selftest to do real test with correct file permission
  checks.
Changes from RFC
- RFC: https://lore.kernel.org/20260624142008.87180-1-sj@kernel.org
- Rebase directly to latest mm-new.

SeongJae Park (11):
  Docs/mm/damon/design: update for DAMOS_QUOTA_NODE_ELIGIBLE_MEM_BP
  Docs/ABI/damon: document probe files
  mm/damon/tests/core-kunit: test damon_rand()
  selftests/damon/sysfs.sh: test multiple probe dirs creation
  selftests/damon/sysfs.sh: test {core,ops}_filters/ directories
  selftests/damon/sysfs.sh: test dests dir
  selftests/damon/sysfs.sh: test all files in quota goal dir
  mm/damon/core: reduce range setup in damon_commit_target_regions()
  mm/damon/sysfs: split probe setup function out
  mm/damon/sysfs: split out filters setup function
  mm/damon/sysfs: fix typos in probe_{add,rm}_dirs: s/attr/probe/

 .../ABI/testing/sysfs-kernel-mm-damon         |  40 +++++++
 Documentation/mm/damon/design.rst             |   6 +-
 mm/damon/core.c                               |  22 +++-
 mm/damon/sysfs.c                              | 102 ++++++++++--------
 mm/damon/tests/core-kunit.h                   |  15 +++
 tools/testing/selftests/damon/sysfs.sh        |  71 +++++++++++-
 6 files changed, 203 insertions(+), 53 deletions(-)


base-commit: 7221b218afc0bff75d656bb193cb6709737cbbf6
-- 
2.47.3

^ permalink raw reply	[flat|nested] 18+ messages in thread

* [RFC PATCH v1.3 01/11] Docs/mm/damon/design: update for DAMOS_QUOTA_NODE_ELIGIBLE_MEM_BP
  2026-06-26  0:16 [RFC PATCH v1.3 00/11] mm/damon: update, optimize, and clean up doc, tests, and code SeongJae Park
@ 2026-06-26  0:16 ` SeongJae Park
  2026-06-26  0:24   ` sashiko-bot
  2026-06-26  0:16 ` [RFC PATCH v1.3 02/11] Docs/ABI/damon: document probe files SeongJae Park
                   ` (9 subsequent siblings)
  10 siblings, 1 reply; 18+ messages in thread
From: SeongJae Park @ 2026-06-26  0:16 UTC (permalink / raw)
  Cc: SeongJae Park, Liam R. Howlett, Andrew Morton, David Hildenbrand,
	Jonathan Corbet, Lorenzo Stoakes, Michal Hocko, Mike Rapoport,
	Shuah Khan, Suren Baghdasaryan, Vlastimil Babka, damon, linux-doc,
	linux-kernel, linux-mm

Commit 9138e27a3bc3 ("mm/damon: add node_eligible_mem_bp goal metric")
introduced DAMOS_QUOTA_NODE_ELIGIBLE_MEM_BP but forgot updating the
DAMON design document for that.  Update.

Signed-off-by: SeongJae Park <sj@kernel.org>
---
 Documentation/mm/damon/design.rst | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/Documentation/mm/damon/design.rst b/Documentation/mm/damon/design.rst
index 2da7ca0d3d17a..f4efb51688853 100644
--- a/Documentation/mm/damon/design.rst
+++ b/Documentation/mm/damon/design.rst
@@ -686,9 +686,11 @@ mechanism tries to make ``current_value`` of ``target_metric`` be same to
   (1/10,000).
 - ``inactive_mem_bp``: Inactive to active + inactive (LRU) memory size ratio in
   bp (1/10,000).
+- ``node_eligible_mem_bp``: Scheme target access pattern-eligible memory ratio
+  of a node in bp (1/10,000).
 
-``nid`` is optionally required for only ``node_mem_used_bp``,
-``node_mem_free_bp``, ``node_memcg_used_bp`` and ``node_memcg_free_bp`` to
+``nid`` is optionally required for ``node_mem_used_bp``, ``node_mem_free_bp``,
+``node_memcg_used_bp``, ``node_memcg_free_bp`` and ``node_eligible_mem_bp`` to
 point the specific NUMA node.
 
 ``path`` is optionally required for only ``node_memcg_used_bp`` and
-- 
2.47.3

^ permalink raw reply related	[flat|nested] 18+ messages in thread

* [RFC PATCH v1.3 02/11] Docs/ABI/damon: document probe files
  2026-06-26  0:16 [RFC PATCH v1.3 00/11] mm/damon: update, optimize, and clean up doc, tests, and code SeongJae Park
  2026-06-26  0:16 ` [RFC PATCH v1.3 01/11] Docs/mm/damon/design: update for DAMOS_QUOTA_NODE_ELIGIBLE_MEM_BP SeongJae Park
@ 2026-06-26  0:16 ` SeongJae Park
  2026-06-26  0:25   ` sashiko-bot
  2026-06-26  0:16 ` [RFC PATCH v1.3 03/11] mm/damon/tests/core-kunit: test damon_rand() SeongJae Park
                   ` (8 subsequent siblings)
  10 siblings, 1 reply; 18+ messages in thread
From: SeongJae Park @ 2026-06-26  0:16 UTC (permalink / raw)
  Cc: SeongJae Park, Liam R. Howlett, Andrew Morton, David Hildenbrand,
	Lorenzo Stoakes, Michal Hocko, Mike Rapoport, Suren Baghdasaryan,
	Vlastimil Babka, damon, linux-kernel, linux-mm

DAMON ABI document is not updated for the DAMON probe sysfs files.
Update.

Signed-off-by: SeongJae Park <sj@kernel.org>
---
 .../ABI/testing/sysfs-kernel-mm-damon         | 40 +++++++++++++++++++
 1 file changed, 40 insertions(+)

diff --git a/Documentation/ABI/testing/sysfs-kernel-mm-damon b/Documentation/ABI/testing/sysfs-kernel-mm-damon
index b73e6bc28ea5f..f914aab79fced 100644
--- a/Documentation/ABI/testing/sysfs-kernel-mm-damon
+++ b/Documentation/ABI/testing/sysfs-kernel-mm-damon
@@ -157,6 +157,46 @@ Description:	Writing a value to this file sets the maximum number of
 		monitoring regions of the DAMON context as the value.  Reading
 		this file returns the value.
 
+What:		/sys/kernel/mm/damon/admin/kdamonds/<K>/contexts/<C>/monitoring_attrs/probes/nr_probes
+Date:		May 2026
+Contact:	SeongJae Park <sj@kernel.org>
+Description:	Writing a number 'N' to this file creates the number of
+		directories for each DAMON probe named '0' to 'N-1' under the
+		probes/ directory.
+
+What:		/sys/kernel/mm/damon/admin/kdamonds/<K>/contexts/<C>/monitoring_attrs/probes/<P>/filters/nr_filters
+Date:		May 2026
+Contact:	SeongJae Park <sj@kernel.org>
+Description:	Writing a number 'N' to this file creates the number of
+		directories for each DAMON probe filter named '0' to 'N-1'
+		under the filters/ directory.
+
+What:		/sys/kernel/mm/damon/admin/kdamonds/<K>/contexts/<C>/monitoring_attrs/probes/<P>/filters/<F>/type
+Date:		May 2026
+Contact:	SeongJae Park <sj@kernel.org>
+Description:	Writing to and reading from this file sets and gets the type of
+		the memory of the interest.
+
+What:		/sys/kernel/mm/damon/admin/kdamonds/<K>/contexts/<C>/monitoring_attrs/probes/<P>/filters/<F>/path
+Date:		May 2026
+Contact:	SeongJae Park <sj@kernel.org>
+Description:	If 'memcg' is written to the 'type' file, writing to and
+		reading from this file sets and gets the path to the memory
+		cgroup of the interest.
+
+What:		/sys/kernel/mm/damon/admin/kdamonds/<K>/contexts/<C>/monitoring_attrs/probes/<P>/filters/<F>/matching
+Date:		May 2026
+Contact:	SeongJae Park <sj@kernel.org>
+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/<K>/contexts/<C>/monitoring_attrs/probes/<P>/filters/<F>/allow
+Date:		May 2026
+Contact:	SeongJae Park <sj@kernel.org>
+Description:	Writing 'Y' or 'N' to this file sets whether to allow or reject
+		hitting the probe for the memory that satisfies the 'type' and
+		the 'matching' of the directory.
+
 What:		/sys/kernel/mm/damon/admin/kdamonds/<K>/contexts/<C>/targets/nr_targets
 Date:		Mar 2022
 Contact:	SeongJae Park <sj@kernel.org>
-- 
2.47.3

^ permalink raw reply related	[flat|nested] 18+ messages in thread

* [RFC PATCH v1.3 03/11] mm/damon/tests/core-kunit: test damon_rand()
  2026-06-26  0:16 [RFC PATCH v1.3 00/11] mm/damon: update, optimize, and clean up doc, tests, and code SeongJae Park
  2026-06-26  0:16 ` [RFC PATCH v1.3 01/11] Docs/mm/damon/design: update for DAMOS_QUOTA_NODE_ELIGIBLE_MEM_BP SeongJae Park
  2026-06-26  0:16 ` [RFC PATCH v1.3 02/11] Docs/ABI/damon: document probe files SeongJae Park
@ 2026-06-26  0:16 ` SeongJae Park
  2026-06-26  0:25   ` sashiko-bot
  2026-06-26  0:16 ` [RFC PATCH v1.3 04/11] selftests/damon/sysfs.sh: test multiple probe dirs creation SeongJae Park
                   ` (7 subsequent siblings)
  10 siblings, 1 reply; 18+ messages in thread
From: SeongJae Park @ 2026-06-26  0:16 UTC (permalink / raw)
  Cc: SeongJae Park, Andrew Morton, Brendan Higgins, David Gow, damon,
	kunit-dev, linux-kernel, linux-kselftest, linux-mm

Commit 9012c4e647df ("mm/damon: replace damon_rand() with a per-ctx
lockless PRNG") optimized DAMON for better performance.  Add a kunit
test for ensuring the bounds of the output.

Signed-off-by: SeongJae Park <sj@kernel.org>
---
 mm/damon/tests/core-kunit.h | 15 +++++++++++++++
 1 file changed, 15 insertions(+)

diff --git a/mm/damon/tests/core-kunit.h b/mm/damon/tests/core-kunit.h
index 1cfb8c176b873..282670b0fa908 100644
--- a/mm/damon/tests/core-kunit.h
+++ b/mm/damon/tests/core-kunit.h
@@ -1460,6 +1460,20 @@ static void damon_test_is_last_region(struct kunit *test)
 	damon_free_target(t);
 }
 
+static void damon_test_rand(struct kunit *test)
+{
+	struct damon_ctx ctx;
+	int i;
+
+	prandom_seed_state(&ctx.rnd_state, get_random_u64());
+	for (i = 0; i < 10000; i++) {
+		unsigned long rnd = damon_rand(&ctx, 0, 10);
+
+		KUNIT_EXPECT_GE(test, rnd, 0);
+		KUNIT_EXPECT_LE(test, rnd, 9);
+	}
+}
+
 static struct kunit_case damon_test_cases[] = {
 	KUNIT_CASE(damon_test_target),
 	KUNIT_CASE(damon_test_regions),
@@ -1489,6 +1503,7 @@ static struct kunit_case damon_test_cases[] = {
 	KUNIT_CASE(damon_test_set_filters_default_reject),
 	KUNIT_CASE(damon_test_apply_min_nr_regions),
 	KUNIT_CASE(damon_test_is_last_region),
+	KUNIT_CASE(damon_test_rand),
 	{},
 };
 
-- 
2.47.3

^ permalink raw reply related	[flat|nested] 18+ messages in thread

* [RFC PATCH v1.3 04/11] selftests/damon/sysfs.sh: test multiple probe dirs creation
  2026-06-26  0:16 [RFC PATCH v1.3 00/11] mm/damon: update, optimize, and clean up doc, tests, and code SeongJae Park
                   ` (2 preceding siblings ...)
  2026-06-26  0:16 ` [RFC PATCH v1.3 03/11] mm/damon/tests/core-kunit: test damon_rand() SeongJae Park
@ 2026-06-26  0:16 ` SeongJae Park
  2026-06-26  0:16 ` [RFC PATCH v1.3 05/11] selftests/damon/sysfs.sh: test {core,ops}_filters/ directories SeongJae Park
                   ` (6 subsequent siblings)
  10 siblings, 0 replies; 18+ messages in thread
From: SeongJae Park @ 2026-06-26  0:16 UTC (permalink / raw)
  Cc: SeongJae Park, Shuah Khan, damon, linux-kernel, linux-kselftest,
	linux-mm

DAMON sysfs essential file operations test (sysfs.sh) was extended to
test DAMON probes sysfs directory, by commit 14885da09b0f
("selftests/damon/sysfs.sh: test probes dir").  Unlike other DAMON sysfs
files, it is testing only a single directory case.  Extend it for
multiple directories.

Signed-off-by: SeongJae Park <sj@kernel.org>
---
 tools/testing/selftests/damon/sysfs.sh | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/tools/testing/selftests/damon/sysfs.sh b/tools/testing/selftests/damon/sysfs.sh
index 78f4badb5bebb..0f2ef462a6b6a 100755
--- a/tools/testing/selftests/damon/sysfs.sh
+++ b/tools/testing/selftests/damon/sysfs.sh
@@ -346,8 +346,13 @@ test_probes()
 	ensure_write_succ "$probes_dir/nr_probes" "1" "valid input"
 	test_probe "$probes_dir/0"
 
+	ensure_write_succ "$probes_dir/nr_probes" "2" "valid input"
+	test_probe "$probes_dir/0"
+	test_probe "$probes_dir/1"
+
 	ensure_write_succ "$probes_dir/nr_probes" "0" "valid input"
 	ensure_dir "$probes_dir/0" "not_exist"
+	ensure_dir "$probes_dir/1" "not_exist"
 }
 
 test_monitoring_attrs()
-- 
2.47.3

^ permalink raw reply related	[flat|nested] 18+ messages in thread

* [RFC PATCH v1.3 05/11] selftests/damon/sysfs.sh: test {core,ops}_filters/ directories
  2026-06-26  0:16 [RFC PATCH v1.3 00/11] mm/damon: update, optimize, and clean up doc, tests, and code SeongJae Park
                   ` (3 preceding siblings ...)
  2026-06-26  0:16 ` [RFC PATCH v1.3 04/11] selftests/damon/sysfs.sh: test multiple probe dirs creation SeongJae Park
@ 2026-06-26  0:16 ` SeongJae Park
  2026-06-26  0:16 ` [RFC PATCH v1.3 06/11] selftests/damon/sysfs.sh: test dests dir SeongJae Park
                   ` (5 subsequent siblings)
  10 siblings, 0 replies; 18+ messages in thread
From: SeongJae Park @ 2026-06-26  0:16 UTC (permalink / raw)
  Cc: SeongJae Park, Shuah Khan, damon, linux-kernel, linux-kselftest,
	linux-mm

DAMON sysfs interface essential file operations test (sysf.sh) is not
testing DAMOS {core,ops}_filters directories.  Add the tests.

Signed-off-by: SeongJae Park <sj@kernel.org>
---
 tools/testing/selftests/damon/sysfs.sh | 28 ++++++++++++++++++++++----
 1 file changed, 24 insertions(+), 4 deletions(-)

diff --git a/tools/testing/selftests/damon/sysfs.sh b/tools/testing/selftests/damon/sysfs.sh
index 0f2ef462a6b6a..07a33995be852 100755
--- a/tools/testing/selftests/damon/sysfs.sh
+++ b/tools/testing/selftests/damon/sysfs.sh
@@ -103,10 +103,28 @@ test_filter()
 {
 	filter_dir=$1
 	ensure_file "$filter_dir/type" "exist" "600"
-	ensure_write_succ "$filter_dir/type" "anon" "valid input"
-	ensure_write_succ "$filter_dir/type" "memcg" "valid input"
-	ensure_write_succ "$filter_dir/type" "addr" "valid input"
-	ensure_write_succ "$filter_dir/type" "target" "valid input"
+
+	local dir_name=$(basename "$(dirname "$filter_dir")")
+	if  [ "$dir_name" = "filters" ] || [ "$dir_name" = "ops_filters" ]
+	then
+		ensure_write_succ "$filter_dir/type" "anon" "valid input"
+		ensure_write_succ "$filter_dir/type" "memcg" "valid input"
+	fi
+	if  [ "$dir_name" = "filters" ] || [ "$dir_name" = "core_filters" ]
+	then
+		ensure_write_succ "$filter_dir/type" "addr" "valid input"
+		ensure_write_succ "$filter_dir/type" "target" "valid input"
+	fi
+	if [ "$dir_name" = "core_filters" ]
+	then
+		ensure_write_fail "$filter_dir/type" "anon" "ops type"
+		ensure_write_fail "$filter_dir/type" "memcg" "ops type"
+	fi
+	if [ "$dir_name"  = "ops_filters" ]
+	then
+		ensure_write_fail "$filter_dir/type" "addr" "core type"
+		ensure_write_fail "$filter_dir/type" "target" "core type"
+	fi
 	ensure_write_fail "$filter_dir/type" "foo" "invalid input"
 	ensure_file "$filter_dir/matching" "exist" "600"
 	ensure_file "$filter_dir/memcg_path" "exist" "600"
@@ -208,6 +226,8 @@ test_scheme()
 	test_quotas "$scheme_dir/quotas"
 	test_watermarks "$scheme_dir/watermarks"
 	test_filters "$scheme_dir/filters"
+	test_filters "$scheme_dir/core_filters"
+	test_filters "$scheme_dir/ops_filters"
 	test_stats "$scheme_dir/stats"
 	test_tried_regions "$scheme_dir/tried_regions"
 }
-- 
2.47.3

^ permalink raw reply related	[flat|nested] 18+ messages in thread

* [RFC PATCH v1.3 06/11] selftests/damon/sysfs.sh: test dests dir
  2026-06-26  0:16 [RFC PATCH v1.3 00/11] mm/damon: update, optimize, and clean up doc, tests, and code SeongJae Park
                   ` (4 preceding siblings ...)
  2026-06-26  0:16 ` [RFC PATCH v1.3 05/11] selftests/damon/sysfs.sh: test {core,ops}_filters/ directories SeongJae Park
@ 2026-06-26  0:16 ` SeongJae Park
  2026-06-26  0:16 ` [RFC PATCH v1.3 07/11] selftests/damon/sysfs.sh: test all files in quota goal dir SeongJae Park
                   ` (4 subsequent siblings)
  10 siblings, 0 replies; 18+ messages in thread
From: SeongJae Park @ 2026-06-26  0:16 UTC (permalink / raw)
  Cc: SeongJae Park, Shuah Khan, damon, linux-kernel, linux-kselftest,
	linux-mm

DAMON selftest interface essential file operations test (sysfs.sh) is
not testing DAMOS dests/ directory.  Add the test.

Signed-off-by: SeongJae Park <sj@kernel.org>
---
 tools/testing/selftests/damon/sysfs.sh | 24 ++++++++++++++++++++++++
 1 file changed, 24 insertions(+)

diff --git a/tools/testing/selftests/damon/sysfs.sh b/tools/testing/selftests/damon/sysfs.sh
index 07a33995be852..b88bf7b98d7f7 100755
--- a/tools/testing/selftests/damon/sysfs.sh
+++ b/tools/testing/selftests/damon/sysfs.sh
@@ -99,6 +99,29 @@ test_stats()
 	done
 }
 
+test_dest()
+{
+	dest_dir=$1
+	ensure_file "$dest_dir/id" "exist" "600"
+	ensure_file "$dest_dir/weight" "exist" "600"
+}
+
+test_dests()
+{
+	dests_dir=$1
+	ensure_file "$dests_dir/nr_dests" "exist" "600"
+	ensure_write_succ "$dests_dir/nr_dests" "1" "valid input"
+	test_dest "$dests_dir/0"
+
+	ensure_write_succ "$dests_dir/nr_dests" "2" "valid input"
+	test_dest "$dests_dir/0"
+	test_dest "$dests_dir/1"
+
+	ensure_write_succ "$dests_dir/nr_dests" "0" "valid input"
+	ensure_dir "$dests_dir/0" "not_exist"
+	ensure_dir "$dests_dir/1" "not_exist"
+}
+
 test_filter()
 {
 	filter_dir=$1
@@ -225,6 +248,7 @@ test_scheme()
 	ensure_file "$scheme_dir/apply_interval_us" "exist" "600"
 	test_quotas "$scheme_dir/quotas"
 	test_watermarks "$scheme_dir/watermarks"
+	test_dests "$scheme_dir/dests"
 	test_filters "$scheme_dir/filters"
 	test_filters "$scheme_dir/core_filters"
 	test_filters "$scheme_dir/ops_filters"
-- 
2.47.3

^ permalink raw reply related	[flat|nested] 18+ messages in thread

* [RFC PATCH v1.3 07/11] selftests/damon/sysfs.sh: test all files in quota goal dir
  2026-06-26  0:16 [RFC PATCH v1.3 00/11] mm/damon: update, optimize, and clean up doc, tests, and code SeongJae Park
                   ` (5 preceding siblings ...)
  2026-06-26  0:16 ` [RFC PATCH v1.3 06/11] selftests/damon/sysfs.sh: test dests dir SeongJae Park
@ 2026-06-26  0:16 ` SeongJae Park
  2026-06-26  0:16 ` [RFC PATCH v1.3 08/11] mm/damon/core: reduce range setup in damon_commit_target_regions() SeongJae Park
                   ` (3 subsequent siblings)
  10 siblings, 0 replies; 18+ messages in thread
From: SeongJae Park @ 2026-06-26  0:16 UTC (permalink / raw)
  Cc: SeongJae Park, Shuah Khan, damon, linux-kernel, linux-kselftest,
	linux-mm

DAMON sysfs interface for DAMOS quota has quite extended since its
initial introduction.  The test case for that in DAMON sysfs interface
essential file operations test (sysfs.sh) has not accordingly extended,
though.  Extend the test case to test all existing files.

Signed-off-by: SeongJae Park <sj@kernel.org>
---
 tools/testing/selftests/damon/sysfs.sh | 14 ++++++++++++++
 1 file changed, 14 insertions(+)

diff --git a/tools/testing/selftests/damon/sysfs.sh b/tools/testing/selftests/damon/sysfs.sh
index b88bf7b98d7f7..811173cb89449 100755
--- a/tools/testing/selftests/damon/sysfs.sh
+++ b/tools/testing/selftests/damon/sysfs.sh
@@ -199,6 +199,20 @@ test_goal()
 	ensure_dir "$goal_dir" "exist"
 	ensure_file "$goal_dir/target_value" "exist" "600"
 	ensure_file "$goal_dir/current_value" "exist" "600"
+	ensure_file "$goal_dir/target_metric" "exist" "600"
+	local fpath="$goal_dir/target_metric"
+	ensure_write_succ "$fpath" "user_input" "valid input"
+	ensure_write_succ "$fpath" "some_mem_psi_us" "valid input"
+	ensure_write_succ "$fpath" "node_mem_used_bp" "valid input"
+	ensure_write_succ "$fpath" "node_mem_free_bp" "valid input"
+	ensure_write_succ "$fpath" "node_memcg_used_bp" "valid input"
+	ensure_write_succ "$fpath" "node_memcg_free_bp" "valid input"
+	ensure_write_succ "$fpath" "active_mem_bp" "valid input"
+	ensure_write_succ "$fpath" "inactive_mem_bp" "valid input"
+	ensure_write_succ "$fpath" "node_eligible_mem_bp" "valid input"
+	ensure_write_fail "$fpath" "foo" "invalid input"
+	ensure_file "$goal_dir/nid" "exist" "600"
+	ensure_file "$goal_dir/path" "exist" "600"
 }
 
 test_goals()
-- 
2.47.3

^ permalink raw reply related	[flat|nested] 18+ messages in thread

* [RFC PATCH v1.3 08/11] mm/damon/core: reduce range setup in damon_commit_target_regions()
  2026-06-26  0:16 [RFC PATCH v1.3 00/11] mm/damon: update, optimize, and clean up doc, tests, and code SeongJae Park
                   ` (6 preceding siblings ...)
  2026-06-26  0:16 ` [RFC PATCH v1.3 07/11] selftests/damon/sysfs.sh: test all files in quota goal dir SeongJae Park
@ 2026-06-26  0:16 ` SeongJae Park
  2026-06-26  0:16 ` [RFC PATCH v1.3 09/11] mm/damon/sysfs: split probe setup function out SeongJae Park
                   ` (2 subsequent siblings)
  10 siblings, 0 replies; 18+ messages in thread
From: SeongJae Park @ 2026-06-26  0:16 UTC (permalink / raw)
  Cc: SeongJae Park, Andrew Morton, damon, linux-kernel, linux-mm

damon_commit_target_regions() calls damon_set_regions() for updating the
destination target's monitoring target region boundaries.  It sets the
boundaries same to source target's monitoring regions, even if they are
adjacent.  Meanwhile, damon_set_region() sets the destination target
regions exactly the same to the source, only when the target regions are
empty.  When there are existing target regions, only a few regions are
expanded or shrunk to fit on only the boundaries for disjoint regions in
the source.  Hence the adjacent source ranges mean nothing in common
cases.  When there are many regions, such adjacent range setup is only a
waste of time and space.  We recently found [1] it is actually causing
memory overhead.  Setup the ranges for only distinct ranges.

[1] https://lore.kernel.org/20260603112306.58490-1-akinobu.mita@gmail.com

Signed-off-by: SeongJae Park <sj@kernel.org>
---
 mm/damon/core.c | 22 +++++++++++++++++-----
 1 file changed, 17 insertions(+), 5 deletions(-)

diff --git a/mm/damon/core.c b/mm/damon/core.c
index 7e4b9affc5b06..ce5294cb1b4f3 100644
--- a/mm/damon/core.c
+++ b/mm/damon/core.c
@@ -1349,21 +1349,33 @@ static struct damon_target *damon_nth_target(int n, struct damon_ctx *ctx)
 static int damon_commit_target_regions(struct damon_target *dst,
 		struct damon_target *src, unsigned long src_min_region_sz)
 {
-	struct damon_region *src_region;
+	struct damon_region *src_region, *prev = NULL;
 	struct damon_addr_range *ranges;
 	int i = 0, err;
 
-	damon_for_each_region(src_region, src)
-		i++;
+	damon_for_each_region(src_region, src) {
+		if (!prev || prev->ar.end != src_region->ar.start)
+			i++;
+		prev = src_region;
+	}
 	if (!i)
 		return 0;
 
 	ranges = kmalloc_objs(*ranges, i, GFP_KERNEL | __GFP_NOWARN);
 	if (!ranges)
 		return -ENOMEM;
+	prev = NULL;
 	i = 0;
-	damon_for_each_region(src_region, src)
-		ranges[i++] = src_region->ar;
+	damon_for_each_region(src_region, src) {
+		if (!prev) {
+			ranges[i].start = src_region->ar.start;
+		} else if (prev->ar.end != src_region->ar.start) {
+			ranges[i++].end = prev->ar.end;
+			ranges[i].start = src_region->ar.start;
+		}
+		prev = src_region;
+	}
+	ranges[i++].end = damon_last_region(src)->ar.end;
 	err = damon_set_regions(dst, ranges, i, src_min_region_sz);
 	kfree(ranges);
 	return err;
-- 
2.47.3

^ permalink raw reply related	[flat|nested] 18+ messages in thread

* [RFC PATCH v1.3 09/11] mm/damon/sysfs: split probe setup function out
  2026-06-26  0:16 [RFC PATCH v1.3 00/11] mm/damon: update, optimize, and clean up doc, tests, and code SeongJae Park
                   ` (7 preceding siblings ...)
  2026-06-26  0:16 ` [RFC PATCH v1.3 08/11] mm/damon/core: reduce range setup in damon_commit_target_regions() SeongJae Park
@ 2026-06-26  0:16 ` SeongJae Park
  2026-06-26  0:16 ` [RFC PATCH v1.3 10/11] mm/damon/sysfs: split out filters setup function SeongJae Park
  2026-06-26  0:16 ` [RFC PATCH v1.3 11/11] mm/damon/sysfs: fix typos in probe_{add,rm}_dirs: s/attr/probe/ SeongJae Park
  10 siblings, 0 replies; 18+ messages in thread
From: SeongJae Park @ 2026-06-26  0:16 UTC (permalink / raw)
  Cc: SeongJae Park, Andrew Morton, damon, linux-kernel, linux-mm

damon_sysfs_set_probes() function is relatively long.  It has two nested
loop for setting two nested entities, namely probe and filter.  Split
out the probe level setup for readability.

Signed-off-by: SeongJae Park <sj@kernel.org>
---
 mm/damon/sysfs.c | 80 ++++++++++++++++++++++++++++--------------------
 1 file changed, 46 insertions(+), 34 deletions(-)

diff --git a/mm/damon/sysfs.c b/mm/damon/sysfs.c
index 2e95e3bac774d..982d824f63c21 100644
--- a/mm/damon/sysfs.c
+++ b/mm/damon/sysfs.c
@@ -1899,47 +1899,59 @@ static int damon_sysfs_set_attrs(struct damon_ctx *ctx,
 	return damon_set_attrs(ctx, &attrs);
 }
 
-static int damon_sysfs_set_probes(struct damon_ctx *ctx,
-		struct damon_sysfs_probes *sys_probes)
+static int damon_sysfs_set_probe(struct damon_probe *probe,
+		struct damon_sysfs_probe *sys_probe)
 {
+	struct damon_sysfs_filters *sys_filters;
 	int i;
 
-	for (i = 0; i < sys_probes->nr; i++) {
-		struct damon_sysfs_filters *sys_filters =
-			sys_probes->probes_arr[i]->filters;
-		struct damon_probe *c;
-		int j;
+	sys_filters = sys_probe->filters;
+	if (!sys_filters)
+		return 0;
 
-		if (!sys_filters)
-			continue;
-		c = damon_new_probe();
-		if (!c)
+	for (i = 0; i < sys_filters->nr; i++) {
+		struct damon_sysfs_filter *sys_filter =
+			sys_filters->filters_arr[i];
+		struct damon_filter *filter;
+
+		filter = damon_new_filter(sys_filter->type,
+				sys_filter->matching,
+				sys_filter->allow);
+		if (!filter)
 			return -ENOMEM;
-		damon_add_probe(ctx, c);
-
-		for (j = 0; j < sys_filters->nr; j++) {
-			struct damon_sysfs_filter *sys_filter =
-				sys_filters->filters_arr[j];
-			struct damon_filter *filter;
-
-			filter = damon_new_filter(sys_filter->type,
-					sys_filter->matching,
-					sys_filter->allow);
-			if (!filter)
-				return -ENOMEM;
-			if (filter->type == DAMON_FILTER_TYPE_MEMCG) {
-				int err;
-
-				err = damon_sysfs_memcg_path_to_id(
-						sys_filter->path,
-						&filter->memcg_id);
-				if (err) {
-					damon_destroy_filter(filter);
-					return err;
-				}
+		if (filter->type == DAMON_FILTER_TYPE_MEMCG) {
+			int err;
+
+			err = damon_sysfs_memcg_path_to_id(
+					sys_filter->path,
+					&filter->memcg_id);
+			if (err) {
+				damon_destroy_filter(filter);
+				return err;
 			}
-			damon_add_filter(c, filter);
 		}
+		damon_add_filter(probe, filter);
+	}
+	return 0;
+}
+
+static int damon_sysfs_set_probes(struct damon_ctx *ctx,
+		struct damon_sysfs_probes *sys_probes)
+{
+	int i, err;
+
+	for (i = 0; i < sys_probes->nr; i++) {
+		struct damon_sysfs_probe *sys_probe;
+		struct damon_probe *p;
+
+		p = damon_new_probe();
+		if (!p)
+			return -ENOMEM;
+		damon_add_probe(ctx, p);
+		sys_probe = sys_probes->probes_arr[i];
+		err = damon_sysfs_set_probe(p, sys_probe);
+		if (err)
+			return err;
 	}
 	return 0;
 }
-- 
2.47.3

^ permalink raw reply related	[flat|nested] 18+ messages in thread

* [RFC PATCH v1.3 10/11] mm/damon/sysfs: split out filters setup function
  2026-06-26  0:16 [RFC PATCH v1.3 00/11] mm/damon: update, optimize, and clean up doc, tests, and code SeongJae Park
                   ` (8 preceding siblings ...)
  2026-06-26  0:16 ` [RFC PATCH v1.3 09/11] mm/damon/sysfs: split probe setup function out SeongJae Park
@ 2026-06-26  0:16 ` SeongJae Park
  2026-06-26  0:16 ` [RFC PATCH v1.3 11/11] mm/damon/sysfs: fix typos in probe_{add,rm}_dirs: s/attr/probe/ SeongJae Park
  10 siblings, 0 replies; 18+ messages in thread
From: SeongJae Park @ 2026-06-26  0:16 UTC (permalink / raw)
  Cc: SeongJae Park, Andrew Morton, damon, linux-kernel, linux-mm

damon_sysfs_set_probe() is doing not only probe setup but also filters
setup.  Split out filters setup for readability.

Signed-off-by: SeongJae Park <sj@kernel.org>
---
 mm/damon/sysfs.c | 20 +++++++++++++-------
 1 file changed, 13 insertions(+), 7 deletions(-)

diff --git a/mm/damon/sysfs.c b/mm/damon/sysfs.c
index 982d824f63c21..f3bb146b204df 100644
--- a/mm/damon/sysfs.c
+++ b/mm/damon/sysfs.c
@@ -1899,16 +1899,11 @@ static int damon_sysfs_set_attrs(struct damon_ctx *ctx,
 	return damon_set_attrs(ctx, &attrs);
 }
 
-static int damon_sysfs_set_probe(struct damon_probe *probe,
-		struct damon_sysfs_probe *sys_probe)
+static int damon_sysfs_set_filters(struct damon_probe *probe,
+		struct damon_sysfs_filters *sys_filters)
 {
-	struct damon_sysfs_filters *sys_filters;
 	int i;
 
-	sys_filters = sys_probe->filters;
-	if (!sys_filters)
-		return 0;
-
 	for (i = 0; i < sys_filters->nr; i++) {
 		struct damon_sysfs_filter *sys_filter =
 			sys_filters->filters_arr[i];
@@ -1935,6 +1930,17 @@ static int damon_sysfs_set_probe(struct damon_probe *probe,
 	return 0;
 }
 
+static int damon_sysfs_set_probe(struct damon_probe *probe,
+		struct damon_sysfs_probe *sys_probe)
+{
+	struct damon_sysfs_filters *sys_filters;
+
+	sys_filters = sys_probe->filters;
+	if (!sys_filters)
+		return 0;
+	return damon_sysfs_set_filters(probe, sys_filters);
+}
+
 static int damon_sysfs_set_probes(struct damon_ctx *ctx,
 		struct damon_sysfs_probes *sys_probes)
 {
-- 
2.47.3

^ permalink raw reply related	[flat|nested] 18+ messages in thread

* [RFC PATCH v1.3 11/11] mm/damon/sysfs: fix typos in probe_{add,rm}_dirs: s/attr/probe/
  2026-06-26  0:16 [RFC PATCH v1.3 00/11] mm/damon: update, optimize, and clean up doc, tests, and code SeongJae Park
                   ` (9 preceding siblings ...)
  2026-06-26  0:16 ` [RFC PATCH v1.3 10/11] mm/damon/sysfs: split out filters setup function SeongJae Park
@ 2026-06-26  0:16 ` SeongJae Park
  10 siblings, 0 replies; 18+ messages in thread
From: SeongJae Park @ 2026-06-26  0:16 UTC (permalink / raw)
  Cc: SeongJae Park, Andrew Morton, damon, linux-kernel, linux-mm

damon_sysfs_probe_{add,rm}_dirs names a variable for damon_sysf_probe
as 'attr'.  Probably a trivial copy-pasta error, but it makes the code
not pleasant to read.  Fix those.

Signed-off-by: SeongJae Park <sj@kernel.org>
---
 mm/damon/sysfs.c | 16 ++++++++--------
 1 file changed, 8 insertions(+), 8 deletions(-)

diff --git a/mm/damon/sysfs.c b/mm/damon/sysfs.c
index f3bb146b204df..36d71f1675426 100644
--- a/mm/damon/sysfs.c
+++ b/mm/damon/sysfs.c
@@ -1068,7 +1068,7 @@ static struct damon_sysfs_probe *damon_sysfs_probe_alloc(void)
 	return kzalloc_obj(struct damon_sysfs_probe);
 }
 
-static int damon_sysfs_probe_add_dirs(struct damon_sysfs_probe *attr)
+static int damon_sysfs_probe_add_dirs(struct damon_sysfs_probe *probe)
 {
 	struct damon_sysfs_filters *filters;
 	int err;
@@ -1076,22 +1076,22 @@ static int damon_sysfs_probe_add_dirs(struct damon_sysfs_probe *attr)
 	filters = damon_sysfs_filters_alloc();
 	if (!filters)
 		return -ENOMEM;
-	attr->filters = filters;
+	probe->filters = filters;
 
 	err = kobject_init_and_add(&filters->kobj, &damon_sysfs_filters_ktype,
-			&attr->kobj, "filters");
+			&probe->kobj, "filters");
 	if (err) {
 		kobject_put(&filters->kobj);
-		attr->filters = NULL;
+		probe->filters = NULL;
 	}
 	return err;
 }
 
-static void damon_sysfs_probe_rm_dirs(struct damon_sysfs_probe *attr)
+static void damon_sysfs_probe_rm_dirs(struct damon_sysfs_probe *probe)
 {
-	if (attr->filters) {
-		damon_sysfs_filters_rm_dirs(attr->filters);
-		kobject_put(&attr->filters->kobj);
+	if (probe->filters) {
+		damon_sysfs_filters_rm_dirs(probe->filters);
+		kobject_put(&probe->filters->kobj);
 	}
 }
 
-- 
2.47.3

^ permalink raw reply related	[flat|nested] 18+ messages in thread

* Re: [RFC PATCH v1.3 01/11] Docs/mm/damon/design: update for DAMOS_QUOTA_NODE_ELIGIBLE_MEM_BP
  2026-06-26  0:16 ` [RFC PATCH v1.3 01/11] Docs/mm/damon/design: update for DAMOS_QUOTA_NODE_ELIGIBLE_MEM_BP SeongJae Park
@ 2026-06-26  0:24   ` sashiko-bot
  2026-06-26  0:31     ` SeongJae Park
  0 siblings, 1 reply; 18+ messages in thread
From: sashiko-bot @ 2026-06-26  0:24 UTC (permalink / raw)
  To: SeongJae Park; +Cc: damon

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:

Pre-existing issues:
- [High] Truncation of 64-bit phys_addr_t to 32-bit unsigned long in damos_get_node_eligible_mem_bp leads to incorrect metric calculation on 32-bit systems.
--

commit 569eb38d08bfaf4718faa6440d86cad7ba9478b7
Author: SeongJae Park <sj@kernel.org>

Docs/mm/damon/design: update for DAMOS_QUOTA_NODE_ELIGIBLE_MEM_BP

Commit 9138e27a3bc3 introduced DAMOS_QUOTA_NODE_ELIGIBLE_MEM_BP but forgot
updating the DAMON design document for that. This commit updates the
documentation to include the missing metric.

> diff --git a/Documentation/mm/damon/design.rst b/Documentation/mm/damon/design.rst
> --- a/Documentation/mm/damon/design.rst
> +++ b/Documentation/mm/damon/design.rst
> @@ -686,9 +686,11 @@ mechanism tries to make ``current_value`` of ``target_metric`` be same to
>    (1/10,000).
>  - ``inactive_mem_bp``: Inactive to active + inactive (LRU) memory size ratio in
>    bp (1/10,000).
> +- ``node_eligible_mem_bp``: Scheme target access pattern-eligible memory ratio
> +  of a node in bp (1/10,000).

[Severity: High]
This isn't a bug introduced by this patch, but while reviewing this metric, I
noticed a pre-existing issue in its implementation.

In mm/damon/core.c:damos_get_node_eligible_mem_bp(), 64-bit phys_addr_t byte
counts are cast to 32-bit unsigned long before ratio calculation:

	if (!(unsigned long)total_eligible)
		return 0;

	return mult_frac((unsigned long)node_eligible, 10000,
			(unsigned long)total_eligible);

On 32-bit systems with PAE, if the amount of eligible memory exceeds 4GB,
will this truncation cause the metric to calculate completely incorrect ratios
(e.g., reporting > 10000 basis points) or erroneously return 0 due to modulo
arithmetic?

This could cause the DAMOS quota tuner to adjust quotas wrongly, potentially
resulting in extremely aggressive or completely ineffective memory actions.

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260626001644.85825-1-sj@kernel.org?part=1

^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: [RFC PATCH v1.3 03/11] mm/damon/tests/core-kunit: test damon_rand()
  2026-06-26  0:16 ` [RFC PATCH v1.3 03/11] mm/damon/tests/core-kunit: test damon_rand() SeongJae Park
@ 2026-06-26  0:25   ` sashiko-bot
  2026-06-26  0:39     ` SeongJae Park
  0 siblings, 1 reply; 18+ messages in thread
From: sashiko-bot @ 2026-06-26  0:25 UTC (permalink / raw)
  To: SeongJae Park; +Cc: damon

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Low] Incomplete test coverage: the test misses the 64-bit execution branch of damon_rand().
--

commit e5514cf11386fbde6faace5ed2dc4b93fedc4bf8
Author: SeongJae Park <sj@kernel.org>

mm/damon/tests/core-kunit: test damon_rand()

This commit adds a KUnit test for the recently introduced lockless PRNG in
damon_rand(). It validates that the generated numbers stay within the
requested bounds.

> diff --git a/mm/damon/tests/core-kunit.h b/mm/damon/tests/core-kunit.h
> index 1cfb8c176b873..282670b0fa908 100644
> --- a/mm/damon/tests/core-kunit.h
> +++ b/mm/damon/tests/core-kunit.h

[ ... ]

> @@ -1460,6 +1460,20 @@ static void damon_test_is_last_region(struct kunit *test)
>  	damon_free_target(t);
>  }
>  
> +static void damon_test_rand(struct kunit *test)
> +{
> +	struct damon_ctx ctx;
> +	int i;
> +
> +	prandom_seed_state(&ctx.rnd_state, get_random_u64());
> +	for (i = 0; i < 10000; i++) {
> +		unsigned long rnd = damon_rand(&ctx, 0, 10);

[Severity: Low]
Does this test miss the 64-bit execution branch of damon_rand()?

The damon_rand() function implements two distinct calculation paths: one for
spans <= U32_MAX and a 64-bit fallback for larger spans using
mul_u64_u64_shr().

Because this test hardcodes the bounds 0 and 10, the span evaluates to
<= U32_MAX. This guarantees that only the 32-bit path is executed, leaving
the 64-bit logic entirely untested on 64-bit architectures.

Would it be helpful to add another iteration or separate test case with a
span greater than U32_MAX to ensure full coverage of damon_rand()?

> +
> +		KUNIT_EXPECT_GE(test, rnd, 0);
> +		KUNIT_EXPECT_LE(test, rnd, 9);
> +	}
> +}

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260626001644.85825-1-sj@kernel.org?part=3

^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: [RFC PATCH v1.3 02/11] Docs/ABI/damon: document probe files
  2026-06-26  0:16 ` [RFC PATCH v1.3 02/11] Docs/ABI/damon: document probe files SeongJae Park
@ 2026-06-26  0:25   ` sashiko-bot
  2026-06-26  0:34     ` SeongJae Park
  0 siblings, 1 reply; 18+ messages in thread
From: sashiko-bot @ 2026-06-26  0:25 UTC (permalink / raw)
  To: SeongJae Park; +Cc: damon

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Low] The documentation for the probe filter 'type' attribute fails to enumerate the supported filter type values.
--

commit bda36c29fa892137debaa25d64442f7c3b5efd22
Author: SeongJae Park <sj@kernel.org>

Docs/ABI/damon: document probe files

This commit updates the DAMON ABI document to include descriptions for the
DAMON probe sysfs files.

> diff --git a/Documentation/ABI/testing/sysfs-kernel-mm-damon b/Documentation/ABI/testing/sysfs-kernel-mm-damon
> index b73e6bc28ea5f..f914aab79fced 100644
> --- a/Documentation/ABI/testing/sysfs-kernel-mm-damon
> +++ b/Documentation/ABI/testing/sysfs-kernel-mm-damon
[ ... ]
> +What:		/sys/kernel/mm/damon/admin/kdamonds/<K>/contexts/<C>/monitoring_attrs/probes/<P>/filters/<F>/type
> +Date:		May 2026
> +Contact:	SeongJae Park <sj@kernel.org>
> +Description:	Writing to and reading from this file sets and gets the type of
> +		the memory of the interest.

[Severity: Low]
Does this documentation need to enumerate the supported filter type values
(such as anon and memcg)?

Users reading the ABI documentation might not know what strings are valid to
write into the probe filter type file without this information.

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260626001644.85825-1-sj@kernel.org?part=2

^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: [RFC PATCH v1.3 01/11] Docs/mm/damon/design: update for DAMOS_QUOTA_NODE_ELIGIBLE_MEM_BP
  2026-06-26  0:24   ` sashiko-bot
@ 2026-06-26  0:31     ` SeongJae Park
  0 siblings, 0 replies; 18+ messages in thread
From: SeongJae Park @ 2026-06-26  0:31 UTC (permalink / raw)
  To: sashiko-bot; +Cc: SeongJae Park, damon

On Fri, 26 Jun 2026 00:24:48 +0000 sashiko-bot@kernel.org wrote:

> Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
> 
> Pre-existing issues:
> - [High] Truncation of 64-bit phys_addr_t to 32-bit unsigned long in damos_get_node_eligible_mem_bp leads to incorrect metric calculation on 32-bit systems.
> --
> 
> commit 569eb38d08bfaf4718faa6440d86cad7ba9478b7
> Author: SeongJae Park <sj@kernel.org>
> 
> Docs/mm/damon/design: update for DAMOS_QUOTA_NODE_ELIGIBLE_MEM_BP
> 
> Commit 9138e27a3bc3 introduced DAMOS_QUOTA_NODE_ELIGIBLE_MEM_BP but forgot
> updating the DAMON design document for that. This commit updates the
> documentation to include the missing metric.
> 
> > diff --git a/Documentation/mm/damon/design.rst b/Documentation/mm/damon/design.rst
> > --- a/Documentation/mm/damon/design.rst
> > +++ b/Documentation/mm/damon/design.rst
> > @@ -686,9 +686,11 @@ mechanism tries to make ``current_value`` of ``target_metric`` be same to
> >    (1/10,000).
> >  - ``inactive_mem_bp``: Inactive to active + inactive (LRU) memory size ratio in
> >    bp (1/10,000).
> > +- ``node_eligible_mem_bp``: Scheme target access pattern-eligible memory ratio
> > +  of a node in bp (1/10,000).
> 
> [Severity: High]
> This isn't a bug introduced by this patch, but while reviewing this metric, I
> noticed a pre-existing issue in its implementation.
> 
> In mm/damon/core.c:damos_get_node_eligible_mem_bp(), 64-bit phys_addr_t byte
> counts are cast to 32-bit unsigned long before ratio calculation:
> 
> 	if (!(unsigned long)total_eligible)
> 		return 0;
> 
> 	return mult_frac((unsigned long)node_eligible, 10000,
> 			(unsigned long)total_eligible);
> 
> On 32-bit systems with PAE, if the amount of eligible memory exceeds 4GB,
> will this truncation cause the metric to calculate completely incorrect ratios
> (e.g., reporting > 10000 basis points) or erroneously return 0 due to modulo
> arithmetic?
> 
> This could cause the DAMOS quota tuner to adjust quotas wrongly, potentially
> resulting in extremely aggressive or completely ineffective memory actions.

Known low priority issue.  Not a blocker.


Thanks,
SJ

[...]

^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: [RFC PATCH v1.3 02/11] Docs/ABI/damon: document probe files
  2026-06-26  0:25   ` sashiko-bot
@ 2026-06-26  0:34     ` SeongJae Park
  0 siblings, 0 replies; 18+ messages in thread
From: SeongJae Park @ 2026-06-26  0:34 UTC (permalink / raw)
  To: sashiko-bot; +Cc: SeongJae Park, damon

On Fri, 26 Jun 2026 00:25:45 +0000 sashiko-bot@kernel.org wrote:

> Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
> - [Low] The documentation for the probe filter 'type' attribute fails to enumerate the supported filter type values.
> --
> 
> commit bda36c29fa892137debaa25d64442f7c3b5efd22
> Author: SeongJae Park <sj@kernel.org>
> 
> Docs/ABI/damon: document probe files
> 
> This commit updates the DAMON ABI document to include descriptions for the
> DAMON probe sysfs files.
> 
> > diff --git a/Documentation/ABI/testing/sysfs-kernel-mm-damon b/Documentation/ABI/testing/sysfs-kernel-mm-damon
> > index b73e6bc28ea5f..f914aab79fced 100644
> > --- a/Documentation/ABI/testing/sysfs-kernel-mm-damon
> > +++ b/Documentation/ABI/testing/sysfs-kernel-mm-damon
> [ ... ]
> > +What:		/sys/kernel/mm/damon/admin/kdamonds/<K>/contexts/<C>/monitoring_attrs/probes/<P>/filters/<F>/type
> > +Date:		May 2026
> > +Contact:	SeongJae Park <sj@kernel.org>
> > +Description:	Writing to and reading from this file sets and gets the type of
> > +		the memory of the interest.
> 
> [Severity: Low]
> Does this documentation need to enumerate the supported filter type values
> (such as anon and memcg)?
> 
> Users reading the ABI documentation might not know what strings are valid to
> write into the probe filter type file without this information.

The beginning of the doc recommend users to refer to DAMON usage doc for more
details.  And there should be the list of the values, so let's not duplicate.

I would revisit this if a human user complains.


Thanks,
SJ

[...]

^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: [RFC PATCH v1.3 03/11] mm/damon/tests/core-kunit: test damon_rand()
  2026-06-26  0:25   ` sashiko-bot
@ 2026-06-26  0:39     ` SeongJae Park
  0 siblings, 0 replies; 18+ messages in thread
From: SeongJae Park @ 2026-06-26  0:39 UTC (permalink / raw)
  To: sashiko-bot; +Cc: SeongJae Park, damon

On Fri, 26 Jun 2026 00:25:19 +0000 sashiko-bot@kernel.org wrote:

> Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
> - [Low] Incomplete test coverage: the test misses the 64-bit execution branch of damon_rand().
> --
> 
> commit e5514cf11386fbde6faace5ed2dc4b93fedc4bf8
> Author: SeongJae Park <sj@kernel.org>
> 
> mm/damon/tests/core-kunit: test damon_rand()
> 
> This commit adds a KUnit test for the recently introduced lockless PRNG in
> damon_rand(). It validates that the generated numbers stay within the
> requested bounds.
> 
> > diff --git a/mm/damon/tests/core-kunit.h b/mm/damon/tests/core-kunit.h
> > index 1cfb8c176b873..282670b0fa908 100644
> > --- a/mm/damon/tests/core-kunit.h
> > +++ b/mm/damon/tests/core-kunit.h
> 
> [ ... ]
> 
> > @@ -1460,6 +1460,20 @@ static void damon_test_is_last_region(struct kunit *test)
> >  	damon_free_target(t);
> >  }
> >  
> > +static void damon_test_rand(struct kunit *test)
> > +{
> > +	struct damon_ctx ctx;
> > +	int i;
> > +
> > +	prandom_seed_state(&ctx.rnd_state, get_random_u64());
> > +	for (i = 0; i < 10000; i++) {
> > +		unsigned long rnd = damon_rand(&ctx, 0, 10);
> 
> [Severity: Low]
> Does this test miss the 64-bit execution branch of damon_rand()?
> 
> The damon_rand() function implements two distinct calculation paths: one for
> spans <= U32_MAX and a 64-bit fallback for larger spans using
> mul_u64_u64_shr().
> 
> Because this test hardcodes the bounds 0 and 10, the span evaluates to
> <= U32_MAX. This guarantees that only the 32-bit path is executed, leaving
> the 64-bit logic entirely untested on 64-bit architectures.
> 
> Would it be helpful to add another iteration or separate test case with a
> span greater than U32_MAX to ensure full coverage of damon_rand()?

I agree testing it together could be a good idea.  But not necessarily a
blocker of this patch.  I will consider adding more test cases including that
in future.


Thanks,
SJ

[...]

^ permalink raw reply	[flat|nested] 18+ messages in thread

end of thread, other threads:[~2026-06-26  0:39 UTC | newest]

Thread overview: 18+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-06-26  0:16 [RFC PATCH v1.3 00/11] mm/damon: update, optimize, and clean up doc, tests, and code SeongJae Park
2026-06-26  0:16 ` [RFC PATCH v1.3 01/11] Docs/mm/damon/design: update for DAMOS_QUOTA_NODE_ELIGIBLE_MEM_BP SeongJae Park
2026-06-26  0:24   ` sashiko-bot
2026-06-26  0:31     ` SeongJae Park
2026-06-26  0:16 ` [RFC PATCH v1.3 02/11] Docs/ABI/damon: document probe files SeongJae Park
2026-06-26  0:25   ` sashiko-bot
2026-06-26  0:34     ` SeongJae Park
2026-06-26  0:16 ` [RFC PATCH v1.3 03/11] mm/damon/tests/core-kunit: test damon_rand() SeongJae Park
2026-06-26  0:25   ` sashiko-bot
2026-06-26  0:39     ` SeongJae Park
2026-06-26  0:16 ` [RFC PATCH v1.3 04/11] selftests/damon/sysfs.sh: test multiple probe dirs creation SeongJae Park
2026-06-26  0:16 ` [RFC PATCH v1.3 05/11] selftests/damon/sysfs.sh: test {core,ops}_filters/ directories SeongJae Park
2026-06-26  0:16 ` [RFC PATCH v1.3 06/11] selftests/damon/sysfs.sh: test dests dir SeongJae Park
2026-06-26  0:16 ` [RFC PATCH v1.3 07/11] selftests/damon/sysfs.sh: test all files in quota goal dir SeongJae Park
2026-06-26  0:16 ` [RFC PATCH v1.3 08/11] mm/damon/core: reduce range setup in damon_commit_target_regions() SeongJae Park
2026-06-26  0:16 ` [RFC PATCH v1.3 09/11] mm/damon/sysfs: split probe setup function out SeongJae Park
2026-06-26  0:16 ` [RFC PATCH v1.3 10/11] mm/damon/sysfs: split out filters setup function SeongJae Park
2026-06-26  0:16 ` [RFC PATCH v1.3 11/11] mm/damon/sysfs: fix typos in probe_{add,rm}_dirs: s/attr/probe/ SeongJae Park

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.