Linux Kernel Selftest development
 help / color / mirror / Atom feed
* [PATCH 00/12] mm/damon: cleanup code, add test cases, and update guidances in docs
@ 2026-09-02  5:47 SJ Park
  2026-09-02  5:47 ` [PATCH 06/12] mm/damon/tests/core-kunit: extend set_regions() test for error case SJ Park
                   ` (6 more replies)
  0 siblings, 7 replies; 14+ messages in thread
From: SJ Park @ 2026-09-02  5:47 UTC (permalink / raw)
  To: Andrew Morton
  Cc: SJ Park, Liam R. Howlett, Brendan Higgins, David Gow,
	David Hildenbrand, Jonathan Corbet, Lorenzo Stoakes, Michal Hocko,
	Mike Rapoport, Randy Dunlap, Shuah Khan, Shuah Khan,
	Suren Baghdasaryan, Vlastimil Babka, damon, kunit-dev, linux-doc,
	linux-kernel, linux-kselftest, linux-mm

Misc cleanup, improvements and updates of code, test, and documents.

Patches 1-5 cleanup DAMON code.  Patches 6-10 adds kunit and selftest
test cases for recently fixed bugs and a new feature.  Patches 11 and 12
update guidelines for AI review and what document to read, on DAMON
documents.

Changes from RFC v1.2
- RFC v1.2: https://lore.kernel.org/20260729140253.87753-1-sj@kernel.org
- Drop RFC tag.
- Rebase to latest mm-new.
Changes from RFC v1.1
- RFC v1.1: https://lore.kernel.org/20260729033751.131213-1-sj@kernel.org
- Fix a typo: s/alingment/alignment/.
- Add damon probes parameter validation cleanup (patches 4 and 5).
Changes from RFC
- RFC: https://lore.kernel.org/20260728052811.192712-1-sj@kernel.org
- Remove ctx parameter of __damon_va_init_regions().
- Fix damon_nr_samples_per_aggr() overflow kunit test.
- Rebase to the latest mm-new.

SJ Park (12):
  mm/damon/core: use damon_nr_samples_per_aggr() for max merge threshold
  mm/damon/core: remove debug messages
  mm/damon/vaddr: remove a debug message
  mm/damon/core: validate number of probes in valid_probe_params()
  mm/damon/sysfs: remove probes number validation
  mm/damon/tests/core-kunit: extend set_regions() test for error case
  mm/damon/tests/core-kunit: test <=0 size damon_set_regions() inputs
  mm/damon/tests/core-kunit: test overlapping ranges for set_regions()
  mm/damon/tests/core-kunit: test damon_nr_samples_per_aggr()
  selftests/damon/sysfs.sh: test hugepage_mem_bp quota goal
  Docs/mm/damon/maintainer-profile: update AI review for Sashiko replies
  Docs/ABI/damon: recommend subsystem doc instead of admin-guide

 .../ABI/testing/sysfs-kernel-mm-damon         |  2 +-
 Documentation/mm/damon/maintainer-profile.rst | 19 ++----
 mm/damon/core.c                               | 19 +++---
 mm/damon/sysfs.c                              |  2 +-
 mm/damon/tests/core-kunit.h                   | 65 ++++++++++++++++---
 mm/damon/vaddr.c                              | 16 +----
 tools/testing/selftests/damon/sysfs.sh        |  1 +
 7 files changed, 76 insertions(+), 48 deletions(-)


base-commit: 52315e1a031f7370a286d6f6c805e2c8eab5abbc
-- 
2.47.3

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

* [PATCH 06/12] mm/damon/tests/core-kunit: extend set_regions() test for error case
  2026-09-02  5:47 [PATCH 00/12] mm/damon: cleanup code, add test cases, and update guidances in docs SJ Park
@ 2026-09-02  5:47 ` SJ Park
  2026-09-02  5:47 ` [PATCH 07/12] mm/damon/tests/core-kunit: test <=0 size damon_set_regions() inputs SJ Park
                   ` (5 subsequent siblings)
  6 siblings, 0 replies; 14+ messages in thread
From: SJ Park @ 2026-09-02  5:47 UTC (permalink / raw)
  To: Andrew Morton
  Cc: SJ Park, Brendan Higgins, David Gow, damon, kunit-dev,
	linux-kernel, linux-kselftest, linux-mm

damon_test_set_regions_for() is designed to test only success-expected
damon_set_regions() calls.  Extend it to cover error-expected calls,
too.

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

diff --git a/mm/damon/tests/core-kunit.h b/mm/damon/tests/core-kunit.h
index af26b3d60957b..2bcf3bafe2e29 100644
--- a/mm/damon/tests/core-kunit.h
+++ b/mm/damon/tests/core-kunit.h
@@ -469,11 +469,12 @@ static void damon_test_set_regions_for(struct kunit *test,
 		struct damon_addr_range *old_ranges, int sz_old_ranges,
 		struct damon_addr_range *new_ranges, int sz_new_ranges,
 		unsigned long min_region_sz,
-		struct damon_addr_range *expect_ranges, int sz_expect_ranges)
+		struct damon_addr_range *expect_ranges, int sz_expect_ranges,
+		int expect_err)
 {
 	struct damon_target *t;
 	struct damon_region *r;
-	int i;
+	int i, err;
 
 	t = damon_new_target();
 	if (!t)
@@ -487,7 +488,8 @@ static void damon_test_set_regions_for(struct kunit *test,
 		damon_add_region(r, t);
 	}
 
-	damon_set_regions(t, new_ranges, sz_new_ranges, min_region_sz);
+	err = damon_set_regions(t, new_ranges, sz_new_ranges, min_region_sz);
+	KUNIT_EXPECT_EQ(test, err, expect_err);
 
 	KUNIT_EXPECT_EQ(test, damon_nr_regions(t), sz_expect_ranges);
 	if (damon_nr_regions(t) != sz_expect_ranges) {
@@ -516,7 +518,7 @@ static void damon_test_set_regions(struct kunit *test)
 			(struct damon_addr_range[]){
 			{.start = 5, .end = 15},
 			{.start = 15, .end = 25},
-			}, 2);
+			}, 2, 0);
 	/* Un-intersecting regions should be removed. */
 	damon_test_set_regions_for(test,
 			(struct damon_addr_range[]){
@@ -529,7 +531,7 @@ static void damon_test_set_regions(struct kunit *test)
 			1,
 			(struct damon_addr_range[]){
 			{.start = 18, .end = 23},
-			}, 1);
+			}, 1, 0);
 	/*
 	 * Holes should be filled up with new regions.
 	 *
@@ -550,7 +552,7 @@ static void damon_test_set_regions(struct kunit *test)
 			{.start = 8, .end = 16},
 			{.start = 16, .end = 24},
 			{.start = 24, .end = 28},
-			}, 3);
+			}, 3, 0);
 	/*
 	 * New regions should be able to be appended.
 	 *
@@ -572,7 +574,7 @@ static void damon_test_set_regions(struct kunit *test)
 			{.start = 0, .end = 4},
 			{.start = 4, .end = 15},
 			{.start = 25, .end = 40},
-			}, 3);
+			}, 3, 0);
 	/*
 	 * New regions should be able to be inserted.
 	 *
@@ -595,7 +597,7 @@ static void damon_test_set_regions(struct kunit *test)
 			{.start = 0, .end = 15},
 			{.start = 25, .end = 40},
 			{.start = 44, .end = 50},
-			}, 3);
+			}, 3, 0);
 }
 
 static void damon_test_update_monitoring_result(struct kunit *test)
-- 
2.47.3

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

* [PATCH 07/12] mm/damon/tests/core-kunit: test <=0 size damon_set_regions() inputs
  2026-09-02  5:47 [PATCH 00/12] mm/damon: cleanup code, add test cases, and update guidances in docs SJ Park
  2026-09-02  5:47 ` [PATCH 06/12] mm/damon/tests/core-kunit: extend set_regions() test for error case SJ Park
@ 2026-09-02  5:47 ` SJ Park
  2026-09-02  5:47 ` [PATCH 08/12] mm/damon/tests/core-kunit: test overlapping ranges for set_regions() SJ Park
                   ` (4 subsequent siblings)
  6 siblings, 0 replies; 14+ messages in thread
From: SJ Park @ 2026-09-02  5:47 UTC (permalink / raw)
  To: Andrew Morton
  Cc: SJ Park, Brendan Higgins, David Gow, damon, kunit-dev,
	linux-kernel, linux-kselftest, linux-mm

Commit 1292c0ecb1ca ("mm/damon/core: validate ranges in
damon_set_regions()") disallowed passing zero or negative size input
ranges to damon_set_regions().  Add kunit test cases for those inputs.

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

diff --git a/mm/damon/tests/core-kunit.h b/mm/damon/tests/core-kunit.h
index 2bcf3bafe2e29..3cbbbcbfbef8f 100644
--- a/mm/damon/tests/core-kunit.h
+++ b/mm/damon/tests/core-kunit.h
@@ -598,6 +598,20 @@ static void damon_test_set_regions(struct kunit *test)
 			{.start = 25, .end = 40},
 			{.start = 44, .end = 50},
 			}, 3, 0);
+	/* Zero size regions should return -EINVAL. */
+	damon_test_set_regions_for(test,
+			(struct damon_addr_range[]){}, 0,
+			(struct damon_addr_range[]){
+			{.start = 42, .end = 42},
+			}, 1, 1,
+			(struct damon_addr_range[]){}, 0, -EINVAL);
+	/* Negative size regions should return -EINVAL. */
+	damon_test_set_regions_for(test,
+			(struct damon_addr_range[]){}, 0,
+			(struct damon_addr_range[]){
+			{.start = 42, .end = 21},
+			}, 1, 1,
+			(struct damon_addr_range[]){}, 0, -EINVAL);
 }
 
 static void damon_test_update_monitoring_result(struct kunit *test)
-- 
2.47.3

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

* [PATCH 08/12] mm/damon/tests/core-kunit: test overlapping ranges for set_regions()
  2026-09-02  5:47 [PATCH 00/12] mm/damon: cleanup code, add test cases, and update guidances in docs SJ Park
  2026-09-02  5:47 ` [PATCH 06/12] mm/damon/tests/core-kunit: extend set_regions() test for error case SJ Park
  2026-09-02  5:47 ` [PATCH 07/12] mm/damon/tests/core-kunit: test <=0 size damon_set_regions() inputs SJ Park
@ 2026-09-02  5:47 ` SJ Park
  2026-09-03  3:04   ` Kunwu Chan
  2026-09-02  5:47 ` [PATCH 09/12] mm/damon/tests/core-kunit: test damon_nr_samples_per_aggr() SJ Park
                   ` (3 subsequent siblings)
  6 siblings, 1 reply; 14+ messages in thread
From: SJ Park @ 2026-09-02  5:47 UTC (permalink / raw)
  To: Andrew Morton
  Cc: SJ Park, Brendan Higgins, David Gow, damon, kunit-dev,
	linux-kernel, linux-kselftest, linux-mm

Commit 954157679ec3 ("mm/damon/core: disallow overlapping input ranges
for damon_set_regions()") disallowed passing overlapping input ranges to
damon_set_regions().  Add a kunit test case for the overlapping input.

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

diff --git a/mm/damon/tests/core-kunit.h b/mm/damon/tests/core-kunit.h
index 3cbbbcbfbef8f..a4164ac489a61 100644
--- a/mm/damon/tests/core-kunit.h
+++ b/mm/damon/tests/core-kunit.h
@@ -612,6 +612,17 @@ static void damon_test_set_regions(struct kunit *test)
 			{.start = 42, .end = 21},
 			}, 1, 1,
 			(struct damon_addr_range[]){}, 0, -EINVAL);
+	/*
+	 * Regions resulting in same region after alignment should return
+	 * -EINVAL.
+	 */
+	damon_test_set_regions_for(test,
+			(struct damon_addr_range[]){}, 0,
+			(struct damon_addr_range[]){
+			{.start = 10, .end = 20},
+			{.start = 20, .end = 30},
+			}, 2, 4096,
+			(struct damon_addr_range[]){}, 0, -EINVAL);
 }
 
 static void damon_test_update_monitoring_result(struct kunit *test)
-- 
2.47.3

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

* [PATCH 09/12] mm/damon/tests/core-kunit: test damon_nr_samples_per_aggr()
  2026-09-02  5:47 [PATCH 00/12] mm/damon: cleanup code, add test cases, and update guidances in docs SJ Park
                   ` (2 preceding siblings ...)
  2026-09-02  5:47 ` [PATCH 08/12] mm/damon/tests/core-kunit: test overlapping ranges for set_regions() SJ Park
@ 2026-09-02  5:47 ` SJ Park
  2026-09-02 15:08   ` Kunwu Chan
  2026-09-02  5:47 ` [PATCH 10/12] selftests/damon/sysfs.sh: test hugepage_mem_bp quota goal SJ Park
                   ` (2 subsequent siblings)
  6 siblings, 1 reply; 14+ messages in thread
From: SJ Park @ 2026-09-02  5:47 UTC (permalink / raw)
  To: Andrew Morton
  Cc: SJ Park, Brendan Higgins, David Gow, damon, kunit-dev,
	linux-kernel, linux-kselftest, linux-mm

damon_max_nr_accesses(), which is a previous version of
damon_nr_samples_per_aggr() before the renaming, was wrongly returning
zero or random overflowed values for extreme intervals setup.  Commit
35d4a3cf70a8 ("mm/damon/ops-common: handle extreme intervals in
damon_hot_score()") updated the function to return correct or more valid
values.  Add a kunit test to ensure it is working as expected.

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

diff --git a/mm/damon/tests/core-kunit.h b/mm/damon/tests/core-kunit.h
index a4164ac489a61..d0bed01a5b7fe 100644
--- a/mm/damon/tests/core-kunit.h
+++ b/mm/damon/tests/core-kunit.h
@@ -625,6 +625,27 @@ static void damon_test_set_regions(struct kunit *test)
 			(struct damon_addr_range[]){}, 0, -EINVAL);
 }
 
+static void damon_test_nr_samples_per_aggr(struct kunit *test)
+{
+	struct damon_attrs attrs = {
+		.sample_interval = 0,
+		.aggr_interval = 0,
+	};
+
+	/* Zero aggregation interval doesn't cause division by zero */
+	KUNIT_EXPECT_EQ(test, damon_nr_samples_per_aggr(&attrs), 1);
+
+	/*
+	 * Too large aggregation interval on 64 bit system doesn't cause
+	 * overflow
+	 */
+	if (ULONG_MAX > UINT_MAX) {
+		attrs.aggr_interval = (unsigned long)UINT_MAX + 1;
+		KUNIT_EXPECT_EQ(test, damon_nr_samples_per_aggr(&attrs),
+				UINT_MAX);
+	}
+}
+
 static void damon_test_update_monitoring_result(struct kunit *test)
 {
 	struct damon_attrs old_attrs = {
@@ -1736,6 +1757,7 @@ static struct kunit_case damon_test_cases[] = {
 	KUNIT_CASE(damon_test_split_above_half_progresses),
 	KUNIT_CASE(damon_test_ops_registration),
 	KUNIT_CASE(damon_test_set_regions),
+	KUNIT_CASE(damon_test_nr_samples_per_aggr),
 	KUNIT_CASE(damon_test_update_monitoring_result),
 	KUNIT_CASE(damon_test_set_attrs),
 	KUNIT_CASE(damon_test_mvsum),
-- 
2.47.3

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

* [PATCH 10/12] selftests/damon/sysfs.sh: test hugepage_mem_bp quota goal
  2026-09-02  5:47 [PATCH 00/12] mm/damon: cleanup code, add test cases, and update guidances in docs SJ Park
                   ` (3 preceding siblings ...)
  2026-09-02  5:47 ` [PATCH 09/12] mm/damon/tests/core-kunit: test damon_nr_samples_per_aggr() SJ Park
@ 2026-09-02  5:47 ` SJ Park
  2026-09-03  3:06   ` Kunwu Chan
  2026-09-02  6:16 ` [PATCH 00/12] mm/damon: cleanup code, add test cases, and update guidances in docs SJ Park
  2026-09-02 22:42 ` Andrew Morton
  6 siblings, 1 reply; 14+ messages in thread
From: SJ Park @ 2026-09-02  5:47 UTC (permalink / raw)
  To: Andrew Morton
  Cc: SJ Park, Shuah Khan, damon, linux-kernel, linux-kselftest,
	linux-mm

DAMON sysfs quota goal target_metric file now accepts 'hugepage_mem_bp'
input.  Test it is accepted in fundamental DAMON sysfs file operation
selftest.

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

diff --git a/tools/testing/selftests/damon/sysfs.sh b/tools/testing/selftests/damon/sysfs.sh
index ddebde6edabe4..b66593c9ac471 100755
--- a/tools/testing/selftests/damon/sysfs.sh
+++ b/tools/testing/selftests/damon/sysfs.sh
@@ -210,6 +210,7 @@ test_goal()
 	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_succ "$fpath" "hugepage_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"
-- 
2.47.3

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

* Re: [PATCH 00/12] mm/damon: cleanup code, add test cases, and update guidances in docs
  2026-09-02  5:47 [PATCH 00/12] mm/damon: cleanup code, add test cases, and update guidances in docs SJ Park
                   ` (4 preceding siblings ...)
  2026-09-02  5:47 ` [PATCH 10/12] selftests/damon/sysfs.sh: test hugepage_mem_bp quota goal SJ Park
@ 2026-09-02  6:16 ` SJ Park
  2026-09-02 22:42 ` Andrew Morton
  6 siblings, 0 replies; 14+ messages in thread
From: SJ Park @ 2026-09-02  6:16 UTC (permalink / raw)
  To: SJ Park
  Cc: Andrew Morton, Liam R. Howlett, Brendan Higgins, David Gow,
	David Hildenbrand, Jonathan Corbet, Lorenzo Stoakes, Michal Hocko,
	Mike Rapoport, Randy Dunlap, Shuah Khan, Shuah Khan,
	Suren Baghdasaryan, Vlastimil Babka, damon, kunit-dev, linux-doc,
	linux-kernel, linux-kselftest, linux-mm

On Tue,  1 Sep 2026 22:47:33 -0700 SJ Park <sj@kernel.org> wrote:

> Misc cleanup, improvements and updates of code, test, and documents.

Sashiko found one better-to-do change for patch 2.  Since it is quite trivial
in my opinion, I asked Andrew to pick a fixup patch as a reply to the patch 2.
Andrew, please feel free to let me know if you prefer reposting.

Sashiko sent findings to damon@ mailing list [1], and I replied to all the
comments having some findings.  Please read those for details.

[1] https://lore.kernel.org/damon/


Thanks,
SJ

[...]

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

* Re: [PATCH 09/12] mm/damon/tests/core-kunit: test damon_nr_samples_per_aggr()
  2026-09-02  5:47 ` [PATCH 09/12] mm/damon/tests/core-kunit: test damon_nr_samples_per_aggr() SJ Park
@ 2026-09-02 15:08   ` Kunwu Chan
  2026-09-02 15:19     ` SJ Park
  0 siblings, 1 reply; 14+ messages in thread
From: Kunwu Chan @ 2026-09-02 15:08 UTC (permalink / raw)
  To: SJ Park
  Cc: Kunwu Chan, Andrew Morton, Brendan Higgins, David Gow, damon,
	kunit-dev, linux-kernel, linux-kselftest, linux-mm

On Tue,  1 Sep 2026 22:47:42 -0700 SJ Park <sj@kernel.org> wrote:

> damon_max_nr_accesses(), which is a previous version of
> damon_nr_samples_per_aggr() before the renaming, was wrongly returning
> zero or random overflowed values for extreme intervals setup.  Commit
> 35d4a3cf70a8 ("mm/damon/ops-common: handle extreme intervals in
> damon_hot_score()") updated the function to return correct or more valid
> values.  Add a kunit test to ensure it is working as expected.
> 
> Signed-off-by: SJ Park <sj@kernel.org>
> ---
>  mm/damon/tests/core-kunit.h | 22 ++++++++++++++++++++++
>  1 file changed, 22 insertions(+)
> 
> diff --git a/mm/damon/tests/core-kunit.h b/mm/damon/tests/core-kunit.h
> index a4164ac489a61..d0bed01a5b7fe 100644
> --- a/mm/damon/tests/core-kunit.h
> +++ b/mm/damon/tests/core-kunit.h
> @@ -625,6 +625,27 @@ static void damon_test_set_regions(struct kunit *test)
>  			(struct damon_addr_range[]){}, 0, -EINVAL);
>  }
>  
> +static void damon_test_nr_samples_per_aggr(struct kunit *test)
> +{
> +	struct damon_attrs attrs = {
> +		.sample_interval = 0,
> +		.aggr_interval = 0,
> +	};
> +

Hi SJ,

A small question about the first test case.

Both `sample_interval` and `aggr_interval` are zero here.  Since
`sample_interval` is the denominator in `damon_nr_samples_per_aggr()`,
would it be better to keep `aggr_interval` non-zero when testing the
zero `sample_interval` case?

This would make the test explicitly cover the divide-by-zero protection.
If the `aggr_interval == 0` behavior is also worth covering, perhaps it
could be tested separately.

Thanks,
Kunwu


> +	/* Zero aggregation interval doesn't cause division by zero */
> +	KUNIT_EXPECT_EQ(test, damon_nr_samples_per_aggr(&attrs), 1);
> +
> +	/*
> +	 * Too large aggregation interval on 64 bit system doesn't cause
> +	 * overflow
> +	 */
> +	if (ULONG_MAX > UINT_MAX) {
> +		attrs.aggr_interval = (unsigned long)UINT_MAX + 1;
> +		KUNIT_EXPECT_EQ(test, damon_nr_samples_per_aggr(&attrs),
> +				UINT_MAX);
> +	}
> +}
> +
>  static void damon_test_update_monitoring_result(struct kunit *test)
>  {
>  	struct damon_attrs old_attrs = {
> @@ -1736,6 +1757,7 @@ static struct kunit_case damon_test_cases[] = {
>  	KUNIT_CASE(damon_test_split_above_half_progresses),
>  	KUNIT_CASE(damon_test_ops_registration),
>  	KUNIT_CASE(damon_test_set_regions),
> +	KUNIT_CASE(damon_test_nr_samples_per_aggr),
>  	KUNIT_CASE(damon_test_update_monitoring_result),
>  	KUNIT_CASE(damon_test_set_attrs),
>  	KUNIT_CASE(damon_test_mvsum),
> -- 
> 2.47.3
> 

Sent using hkml (https://github.com/sjp38/hackermail)

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

* Re: [PATCH 09/12] mm/damon/tests/core-kunit: test damon_nr_samples_per_aggr()
  2026-09-02 15:08   ` Kunwu Chan
@ 2026-09-02 15:19     ` SJ Park
  2026-09-02 15:49       ` Kunwu Chan
  0 siblings, 1 reply; 14+ messages in thread
From: SJ Park @ 2026-09-02 15:19 UTC (permalink / raw)
  To: Kunwu Chan
  Cc: SJ Park, Kunwu Chan, Andrew Morton, Brendan Higgins, David Gow,
	damon, kunit-dev, linux-kernel, linux-kselftest, linux-mm

On Wed,  2 Sep 2026 23:08:41 +0800 Kunwu Chan <kunwu.chan@gmail.com> wrote:

> On Tue,  1 Sep 2026 22:47:42 -0700 SJ Park <sj@kernel.org> wrote:
[...]
> Both `sample_interval` and `aggr_interval` are zero here.  Since
> `sample_interval` is the denominator in `damon_nr_samples_per_aggr()`,
> would it be better to keep `aggr_interval` non-zero when testing the
> zero `sample_interval` case?
> 
> This would make the test explicitly cover the divide-by-zero protection.
> If the `aggr_interval == 0` behavior is also worth covering, perhaps it
> could be tested separately.

Thank you for your review and question, Kunwu!

Yes, that kind of additional test case would be nice.  Please feel free to post
a patch if you'd like to! :)  And no pressure, no rush.  I will also consider
doing it myself if it seems you are not interested.


Thanks,
SJ

[...]

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

* Re: [PATCH 09/12] mm/damon/tests/core-kunit: test damon_nr_samples_per_aggr()
  2026-09-02 15:19     ` SJ Park
@ 2026-09-02 15:49       ` Kunwu Chan
  2026-09-03  0:22         ` SJ Park
  0 siblings, 1 reply; 14+ messages in thread
From: Kunwu Chan @ 2026-09-02 15:49 UTC (permalink / raw)
  To: SJ Park
  Cc: Kunwu Chan, Kunwu Chan, Andrew Morton, Brendan Higgins, David Gow,
	damon, kunit-dev, linux-kernel, linux-kselftest, linux-mm

On Wed,  2 Sep 2026 08:19:54 -0700 SJ Park <sj@kernel.org> wrote:

> On Wed,  2 Sep 2026 23:08:41 +0800 Kunwu Chan <kunwu.chan@gmail.com> wrote:
> 
> > On Tue,  1 Sep 2026 22:47:42 -0700 SJ Park <sj@kernel.org> wrote:
> [...]
> > Both `sample_interval` and `aggr_interval` are zero here.  Since
> > `sample_interval` is the denominator in `damon_nr_samples_per_aggr()`,
> > would it be better to keep `aggr_interval` non-zero when testing the
> > zero `sample_interval` case?
> > 
> > This would make the test explicitly cover the divide-by-zero protection.
> > If the `aggr_interval == 0` behavior is also worth covering, perhaps it
> > could be tested separately.
> 
> Thank you for your review and question, Kunwu!
> 
> Yes, that kind of additional test case would be nice.  Please feel free to post
> a patch if you'd like to! :)  And no pressure, no rush.  I will also consider
> doing it myself if it seems you are not interested.

Thanks for the feedback, SJ!

I will prepare a small follow-up patch for this test
clarity improvement.

Reviewed-by: Kunwu Chan <kunwu.chan@gmail.com>

Thanks,
Kunwu

> 
> 
> Thanks,
> SJ
> 
> [...]
> 

Sent using hkml (https://github.com/sjp38/hackermail)

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

* Re: [PATCH 00/12] mm/damon: cleanup code, add test cases, and update guidances in docs
  2026-09-02  5:47 [PATCH 00/12] mm/damon: cleanup code, add test cases, and update guidances in docs SJ Park
                   ` (5 preceding siblings ...)
  2026-09-02  6:16 ` [PATCH 00/12] mm/damon: cleanup code, add test cases, and update guidances in docs SJ Park
@ 2026-09-02 22:42 ` Andrew Morton
  6 siblings, 0 replies; 14+ messages in thread
From: Andrew Morton @ 2026-09-02 22:42 UTC (permalink / raw)
  To: SJ Park
  Cc: Liam R. Howlett, Brendan Higgins, David Gow, David Hildenbrand,
	Jonathan Corbet, Lorenzo Stoakes, Michal Hocko, Mike Rapoport,
	Randy Dunlap, Shuah Khan, Shuah Khan, Suren Baghdasaryan,
	Vlastimil Babka, damon, kunit-dev, linux-doc, linux-kernel,
	linux-kselftest, linux-mm

On Tue,  1 Sep 2026 22:47:33 -0700 SJ Park <sj@kernel.org> wrote:

> Misc cleanup, improvements and updates of code, test, and documents.
> 
> Patches 1-5 cleanup DAMON code.  Patches 6-10 adds kunit and selftest
> test cases for recently fixed bugs and a new feature.  Patches 11 and 12
> update guidelines for AI review and what document to read, on DAMON
> documents.

Thanks, I added all this.  Along with the fixup for [02/12].

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

* Re: [PATCH 09/12] mm/damon/tests/core-kunit: test damon_nr_samples_per_aggr()
  2026-09-02 15:49       ` Kunwu Chan
@ 2026-09-03  0:22         ` SJ Park
  0 siblings, 0 replies; 14+ messages in thread
From: SJ Park @ 2026-09-03  0:22 UTC (permalink / raw)
  To: Kunwu Chan
  Cc: SJ Park, Kunwu Chan, Andrew Morton, Brendan Higgins, David Gow,
	damon, kunit-dev, linux-kernel, linux-kselftest, linux-mm

On Wed,  2 Sep 2026 23:49:42 +0800 Kunwu Chan <kunwu.chan@gmail.com> wrote:

> On Wed,  2 Sep 2026 08:19:54 -0700 SJ Park <sj@kernel.org> wrote:
> 
> > On Wed,  2 Sep 2026 23:08:41 +0800 Kunwu Chan <kunwu.chan@gmail.com> wrote:
> > 
> > > On Tue,  1 Sep 2026 22:47:42 -0700 SJ Park <sj@kernel.org> wrote:
> > [...]
> > > Both `sample_interval` and `aggr_interval` are zero here.  Since
> > > `sample_interval` is the denominator in `damon_nr_samples_per_aggr()`,
> > > would it be better to keep `aggr_interval` non-zero when testing the
> > > zero `sample_interval` case?
> > > 
> > > This would make the test explicitly cover the divide-by-zero protection.
> > > If the `aggr_interval == 0` behavior is also worth covering, perhaps it
> > > could be tested separately.
> > 
> > Thank you for your review and question, Kunwu!
> > 
> > Yes, that kind of additional test case would be nice.  Please feel free to post
> > a patch if you'd like to! :)  And no pressure, no rush.  I will also consider
> > doing it myself if it seems you are not interested.
> 
> Thanks for the feedback, SJ!
> 
> I will prepare a small follow-up patch for this test
> clarity improvement.

Looking forward to!

> 
> Reviewed-by: Kunwu Chan <kunwu.chan@gmail.com>

Thank you!  Also appreciate your R-b: for other patches!


Thanks,
SJ

[...]

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

* Re: [PATCH 08/12] mm/damon/tests/core-kunit: test overlapping ranges for set_regions()
  2026-09-02  5:47 ` [PATCH 08/12] mm/damon/tests/core-kunit: test overlapping ranges for set_regions() SJ Park
@ 2026-09-03  3:04   ` Kunwu Chan
  0 siblings, 0 replies; 14+ messages in thread
From: Kunwu Chan @ 2026-09-03  3:04 UTC (permalink / raw)
  To: SJ Park
  Cc: Kunwu Chan, Andrew Morton, Brendan Higgins, David Gow, damon,
	kunit-dev, linux-kernel, linux-kselftest, linux-mm, Kunwu Chan

On Tue,  1 Sep 2026 22:47:41 -0700 SJ Park <sj@kernel.org> wrote:

> Commit 954157679ec3 ("mm/damon/core: disallow overlapping input ranges
> for damon_set_regions()") disallowed passing overlapping input ranges to
> damon_set_regions().  Add a kunit test case for the overlapping input.
> 
> Signed-off-by: SJ Park <sj@kernel.org>
> ---
>  mm/damon/tests/core-kunit.h | 11 +++++++++++
>  1 file changed, 11 insertions(+)
> 
> diff --git a/mm/damon/tests/core-kunit.h b/mm/damon/tests/core-kunit.h
> index 3cbbbcbfbef8f..a4164ac489a61 100644
> --- a/mm/damon/tests/core-kunit.h
> +++ b/mm/damon/tests/core-kunit.h
> @@ -612,6 +612,17 @@ static void damon_test_set_regions(struct kunit *test)
>  			{.start = 42, .end = 21},
>  			}, 1, 1,
>  			(struct damon_addr_range[]){}, 0, -EINVAL);
> +	/*
> +	 * Regions resulting in same region after alignment should return
> +	 * -EINVAL.
> +	 */
> +	damon_test_set_regions_for(test,
> +			(struct damon_addr_range[]){}, 0,
> +			(struct damon_addr_range[]){
> +			{.start = 10, .end = 20},
> +			{.start = 20, .end = 30},
> +			}, 2, 4096,
> +			(struct damon_addr_range[]){}, 0, -EINVAL);
>  }
>  
>  static void damon_test_update_monitoring_result(struct kunit *test)
> -- 
> 2.47.3
> 

Hi SJ,

I reviewed patches 6-8. The test helper extension and the added
error cases look correct to me, including the overlap case after
range alignment.

Reviewed-by: Kunwu Chan <kunwu.chan@gmail.com>

Thanks,
Kunwu


Sent using hkml (https://github.com/sjp38/hackermail)

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

* Re: [PATCH 10/12] selftests/damon/sysfs.sh: test hugepage_mem_bp quota goal
  2026-09-02  5:47 ` [PATCH 10/12] selftests/damon/sysfs.sh: test hugepage_mem_bp quota goal SJ Park
@ 2026-09-03  3:06   ` Kunwu Chan
  0 siblings, 0 replies; 14+ messages in thread
From: Kunwu Chan @ 2026-09-03  3:06 UTC (permalink / raw)
  To: SJ Park
  Cc: Kunwu Chan, Andrew Morton, Shuah Khan, damon, linux-kernel,
	linux-kselftest, linux-mm, Kunwu Chan

On Tue,  1 Sep 2026 22:47:43 -0700 SJ Park <sj@kernel.org> wrote:

> DAMON sysfs quota goal target_metric file now accepts 'hugepage_mem_bp'
> input.  Test it is accepted in fundamental DAMON sysfs file operation
> selftest.
> 
> Signed-off-by: SJ Park <sj@kernel.org>
> ---
>  tools/testing/selftests/damon/sysfs.sh | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/tools/testing/selftests/damon/sysfs.sh b/tools/testing/selftests/damon/sysfs.sh
> index ddebde6edabe4..b66593c9ac471 100755
> --- a/tools/testing/selftests/damon/sysfs.sh
> +++ b/tools/testing/selftests/damon/sysfs.sh
> @@ -210,6 +210,7 @@ test_goal()
>  	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_succ "$fpath" "hugepage_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"
> -- 
> 2.47.3
> 

The added test correctly covers the
hugepage_mem_bp quota goal.

Reviewed-by: Kunwu Chan <kunwu.chan@gmail.com>

Thanks,
Kunwu

Sent using hkml (https://github.com/sjp38/hackermail)

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

end of thread, other threads:[~2026-09-03  3:06 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-09-02  5:47 [PATCH 00/12] mm/damon: cleanup code, add test cases, and update guidances in docs SJ Park
2026-09-02  5:47 ` [PATCH 06/12] mm/damon/tests/core-kunit: extend set_regions() test for error case SJ Park
2026-09-02  5:47 ` [PATCH 07/12] mm/damon/tests/core-kunit: test <=0 size damon_set_regions() inputs SJ Park
2026-09-02  5:47 ` [PATCH 08/12] mm/damon/tests/core-kunit: test overlapping ranges for set_regions() SJ Park
2026-09-03  3:04   ` Kunwu Chan
2026-09-02  5:47 ` [PATCH 09/12] mm/damon/tests/core-kunit: test damon_nr_samples_per_aggr() SJ Park
2026-09-02 15:08   ` Kunwu Chan
2026-09-02 15:19     ` SJ Park
2026-09-02 15:49       ` Kunwu Chan
2026-09-03  0:22         ` SJ Park
2026-09-02  5:47 ` [PATCH 10/12] selftests/damon/sysfs.sh: test hugepage_mem_bp quota goal SJ Park
2026-09-03  3:06   ` Kunwu Chan
2026-09-02  6:16 ` [PATCH 00/12] mm/damon: cleanup code, add test cases, and update guidances in docs SJ Park
2026-09-02 22:42 ` Andrew Morton

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox