All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2 0/5] mm/damon/tests/core-kunit: extend existing test scenarios
@ 2025-12-24  4:21 Shu Anzai
  2025-12-24  4:21 ` [PATCH v2 1/5] mm/damon/tests/core-kunit: verify the 'age' field in damon_test_split_at() Shu Anzai
                   ` (5 more replies)
  0 siblings, 6 replies; 13+ messages in thread
From: Shu Anzai @ 2025-12-24  4:21 UTC (permalink / raw)
  To: SeongJae Park; +Cc: Andrew Morton, damon, linux-mm, linux-kernel, Shu Anzai

Improve the KUnit test coverage for DAMON. 

The five patches in this series respectively extend damon_test_split_at(), 
damon_test_merge_two(), damon_test_merge_regions_of(), 
damon_test_split_regions_of(), and damos_test_commit_quota_goal().

Changes from v1:
- Split the original patch into five smaller patches.
- Remove a newly added region from damon_test_merge_regions_of() 
  to avoid an obvious test case.
- Restore the test case in damon_test_split_regions_of() 
  that was previously removed.

Shu Anzai (5):
  mm/damon/tests/core-kunit: verify the 'age' field in
    damon_test_split_at()
  mm/damon/tests/core-kunit: verify the 'age' and 'nr_accesses_bp'
    fields in damon_test_merge_two()
  mm/damon/tests/core-kunit: add a test case for region merge size limit
    in damon_test_merge_regions_of()
  mm/damon/tests/core-kunit: add test cases for multiple regions in
    damon_test_split_regions_of()
  mm/damon/tests/core-kunit: remove a redundant test case and add a new
    test case in damos_test_commit_quota_goal()

 mm/damon/tests/core-kunit.h | 50 +++++++++++++++++++++++++++++--------
 1 file changed, 39 insertions(+), 11 deletions(-)

-- 
2.43.0


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

* [PATCH v2 1/5] mm/damon/tests/core-kunit: verify the 'age' field in damon_test_split_at()
  2025-12-24  4:21 [PATCH v2 0/5] mm/damon/tests/core-kunit: extend existing test scenarios Shu Anzai
@ 2025-12-24  4:21 ` Shu Anzai
  2025-12-24  5:26   ` SeongJae Park
  2025-12-24  4:21 ` [PATCH v2 2/5] mm/damon/tests/core-kunit: verify the 'age' and 'nr_accesses_bp' fields in damon_test_merge_two() Shu Anzai
                   ` (4 subsequent siblings)
  5 siblings, 1 reply; 13+ messages in thread
From: Shu Anzai @ 2025-12-24  4:21 UTC (permalink / raw)
  To: SeongJae Park; +Cc: Andrew Morton, damon, linux-mm, linux-kernel, Shu Anzai

Extend damon_test_split_at() to verify the 'age' field.

Signed-off-by: Shu Anzai <shu17az@gmail.com>
---
 mm/damon/tests/core-kunit.h | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/mm/damon/tests/core-kunit.h b/mm/damon/tests/core-kunit.h
index f59ae7ee19a0..88ec046f4942 100644
--- a/mm/damon/tests/core-kunit.h
+++ b/mm/damon/tests/core-kunit.h
@@ -158,6 +158,7 @@ static void damon_test_split_at(struct kunit *test)
 	r->nr_accesses_bp = 420000;
 	r->nr_accesses = 42;
 	r->last_nr_accesses = 15;
+	r->age = 10;
 	damon_add_region(r, t);
 	damon_split_region_at(t, r, 25);
 	KUNIT_EXPECT_EQ(test, r->ar.start, 0ul);
@@ -170,6 +171,7 @@ static void damon_test_split_at(struct kunit *test)
 	KUNIT_EXPECT_EQ(test, r->nr_accesses_bp, r_new->nr_accesses_bp);
 	KUNIT_EXPECT_EQ(test, r->nr_accesses, r_new->nr_accesses);
 	KUNIT_EXPECT_EQ(test, r->last_nr_accesses, r_new->last_nr_accesses);
+	KUNIT_EXPECT_EQ(test, r->age, r_new->age);
 
 	damon_free_target(t);
 }
-- 
2.43.0


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

* [PATCH v2 2/5] mm/damon/tests/core-kunit: verify the 'age' and 'nr_accesses_bp' fields in damon_test_merge_two()
  2025-12-24  4:21 [PATCH v2 0/5] mm/damon/tests/core-kunit: extend existing test scenarios Shu Anzai
  2025-12-24  4:21 ` [PATCH v2 1/5] mm/damon/tests/core-kunit: verify the 'age' field in damon_test_split_at() Shu Anzai
@ 2025-12-24  4:21 ` Shu Anzai
  2025-12-24  5:27   ` SeongJae Park
  2025-12-24  4:21 ` [PATCH v2 3/5] mm/damon/tests/core-kunit: add a test case for region merge size limit in damon_test_merge_regions_of() Shu Anzai
                   ` (3 subsequent siblings)
  5 siblings, 1 reply; 13+ messages in thread
From: Shu Anzai @ 2025-12-24  4:21 UTC (permalink / raw)
  To: SeongJae Park; +Cc: Andrew Morton, damon, linux-mm, linux-kernel, Shu Anzai

Extend damon_test_merge_two() to verify the 'age' and 
'nr_accesses_bp' fields.

Signed-off-by: Shu Anzai <shu17az@gmail.com>
---
 mm/damon/tests/core-kunit.h | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/mm/damon/tests/core-kunit.h b/mm/damon/tests/core-kunit.h
index 88ec046f4942..6e301113e103 100644
--- a/mm/damon/tests/core-kunit.h
+++ b/mm/damon/tests/core-kunit.h
@@ -192,6 +192,7 @@ static void damon_test_merge_two(struct kunit *test)
 	}
 	r->nr_accesses = 10;
 	r->nr_accesses_bp = 100000;
+	r->age = 9;
 	damon_add_region(r, t);
 	r2 = damon_new_region(100, 300);
 	if (!r2) {
@@ -200,12 +201,15 @@ static void damon_test_merge_two(struct kunit *test)
 	}
 	r2->nr_accesses = 20;
 	r2->nr_accesses_bp = 200000;
+	r2->age = 21;
 	damon_add_region(r2, t);
 
 	damon_merge_two_regions(t, r, r2);
 	KUNIT_EXPECT_EQ(test, r->ar.start, 0ul);
 	KUNIT_EXPECT_EQ(test, r->ar.end, 300ul);
 	KUNIT_EXPECT_EQ(test, r->nr_accesses, 16u);
+	KUNIT_EXPECT_EQ(test, r->nr_accesses_bp, 160000u);
+	KUNIT_EXPECT_EQ(test, r->age, 17u);
 
 	i = 0;
 	damon_for_each_region(r3, t) {
-- 
2.43.0


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

* [PATCH v2 3/5] mm/damon/tests/core-kunit: add a test case for region merge size limit in damon_test_merge_regions_of()
  2025-12-24  4:21 [PATCH v2 0/5] mm/damon/tests/core-kunit: extend existing test scenarios Shu Anzai
  2025-12-24  4:21 ` [PATCH v2 1/5] mm/damon/tests/core-kunit: verify the 'age' field in damon_test_split_at() Shu Anzai
  2025-12-24  4:21 ` [PATCH v2 2/5] mm/damon/tests/core-kunit: verify the 'age' and 'nr_accesses_bp' fields in damon_test_merge_two() Shu Anzai
@ 2025-12-24  4:21 ` Shu Anzai
  2025-12-24  5:29   ` SeongJae Park
  2025-12-24  4:21 ` [PATCH v2 4/5] mm/damon/tests/core-kunit: add test cases for multiple regions in damon_test_split_regions_of() Shu Anzai
                   ` (2 subsequent siblings)
  5 siblings, 1 reply; 13+ messages in thread
From: Shu Anzai @ 2025-12-24  4:21 UTC (permalink / raw)
  To: SeongJae Park; +Cc: Andrew Morton, damon, linux-mm, linux-kernel, Shu Anzai

Add a test case in damon_test_merge_regions_of() to verify that 
two adjacent regions are not merged if the resulting region would 
exceed the specified size limit.

Signed-off-by: Shu Anzai <shu17az@gmail.com>
---
 mm/damon/tests/core-kunit.h | 16 ++++++++--------
 1 file changed, 8 insertions(+), 8 deletions(-)

diff --git a/mm/damon/tests/core-kunit.h b/mm/damon/tests/core-kunit.h
index 6e301113e103..2eb6f41635a8 100644
--- a/mm/damon/tests/core-kunit.h
+++ b/mm/damon/tests/core-kunit.h
@@ -238,12 +238,12 @@ static void damon_test_merge_regions_of(struct kunit *test)
 {
 	struct damon_target *t;
 	struct damon_region *r;
-	unsigned long sa[] = {0, 100, 114, 122, 130, 156, 170, 184};
-	unsigned long ea[] = {100, 112, 122, 130, 156, 170, 184, 230};
-	unsigned int nrs[] = {0, 0, 10, 10, 20, 30, 1, 2};
+	unsigned long sa[] = {0, 100, 114, 122, 130, 156, 170, 184, 230};
+	unsigned long ea[] = {100, 112, 122, 130, 156, 170, 184, 230, 10170};
+	unsigned int nrs[] = {0, 0, 10, 10, 20, 30, 1, 2, 5};
 
-	unsigned long saddrs[] = {0, 114, 130, 156, 170};
-	unsigned long eaddrs[] = {112, 130, 156, 170, 230};
+	unsigned long saddrs[] = {0, 114, 130, 156, 170, 230};
+	unsigned long eaddrs[] = {112, 130, 156, 170, 230, 10170};
 	int i;
 
 	t = damon_new_target();
@@ -261,9 +261,9 @@ static void damon_test_merge_regions_of(struct kunit *test)
 	}
 
 	damon_merge_regions_of(t, 9, 9999);
-	/* 0-112, 114-130, 130-156, 156-170 */
-	KUNIT_EXPECT_EQ(test, damon_nr_regions(t), 5u);
-	for (i = 0; i < 5; i++) {
+	/* 0-112, 114-130, 130-156, 156-170, 170-230, 230-10170 */
+	KUNIT_EXPECT_EQ(test, damon_nr_regions(t), 6u);
+	for (i = 0; i < 6; i++) {
 		r = __nth_region_of(t, i);
 		KUNIT_EXPECT_EQ(test, r->ar.start, saddrs[i]);
 		KUNIT_EXPECT_EQ(test, r->ar.end, eaddrs[i]);
-- 
2.43.0


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

* [PATCH v2 4/5] mm/damon/tests/core-kunit: add test cases for multiple regions in damon_test_split_regions_of()
  2025-12-24  4:21 [PATCH v2 0/5] mm/damon/tests/core-kunit: extend existing test scenarios Shu Anzai
                   ` (2 preceding siblings ...)
  2025-12-24  4:21 ` [PATCH v2 3/5] mm/damon/tests/core-kunit: add a test case for region merge size limit in damon_test_merge_regions_of() Shu Anzai
@ 2025-12-24  4:21 ` Shu Anzai
  2025-12-24  5:34   ` SeongJae Park
  2025-12-24  4:22 ` [PATCH v2 5/5] mm/damon/tests/core-kunit: remove a redundant test case and add a new test case in damos_test_commit_quota_goal() Shu Anzai
  2025-12-24  5:38 ` [PATCH v2 0/5] mm/damon/tests/core-kunit: extend existing test scenarios SeongJae Park
  5 siblings, 1 reply; 13+ messages in thread
From: Shu Anzai @ 2025-12-24  4:21 UTC (permalink / raw)
  To: SeongJae Park; +Cc: Andrew Morton, damon, linux-mm, linux-kernel, Shu Anzai

Extend damon_test_split_regions_of() to verify that it correctly handles 
multiple regions with various 'min_sz_region'.

Signed-off-by: Shu Anzai <shu17az@gmail.com>
---
 mm/damon/tests/core-kunit.h | 21 +++++++++++++++++++++
 1 file changed, 21 insertions(+)

diff --git a/mm/damon/tests/core-kunit.h b/mm/damon/tests/core-kunit.h
index 2eb6f41635a8..36622a2c11f1 100644
--- a/mm/damon/tests/core-kunit.h
+++ b/mm/damon/tests/core-kunit.h
@@ -275,6 +275,9 @@ static void damon_test_split_regions_of(struct kunit *test)
 {
 	struct damon_target *t;
 	struct damon_region *r;
+	unsigned long sa[] = {0, 300, 500};
+	unsigned long ea[] = {220, 400, 700};
+	int i;
 
 	t = damon_new_target();
 	if (!t)
@@ -301,6 +304,24 @@ static void damon_test_split_regions_of(struct kunit *test)
 	damon_split_regions_of(t, 4, 1);
 	KUNIT_EXPECT_LE(test, damon_nr_regions(t), 4u);
 	damon_free_target(t);
+
+	t = damon_new_target();
+	if (!t)
+		kunit_skip(test, "third target alloc fail");
+	for (i = 0; i < ARRAY_SIZE(sa); i++) {
+		r = damon_new_region(sa[i], ea[i]);
+		if (!r) {
+			damon_free_target(t);
+			kunit_skip(test, "region alloc fail");
+		}
+		damon_add_region(r, t);
+	}
+	damon_split_regions_of(t, 4, 5);
+	KUNIT_EXPECT_LE(test, damon_nr_regions(t), 12u);
+	damon_for_each_region(r, t) {
+		KUNIT_EXPECT_GE(test, damon_sz_region(r) % 5ul, 0ul);
+	}
+	damon_free_target(t);
 }
 
 static void damon_test_ops_registration(struct kunit *test)
-- 
2.43.0


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

* [PATCH v2 5/5] mm/damon/tests/core-kunit: remove a redundant test case and add a new test case in damos_test_commit_quota_goal()
  2025-12-24  4:21 [PATCH v2 0/5] mm/damon/tests/core-kunit: extend existing test scenarios Shu Anzai
                   ` (3 preceding siblings ...)
  2025-12-24  4:21 ` [PATCH v2 4/5] mm/damon/tests/core-kunit: add test cases for multiple regions in damon_test_split_regions_of() Shu Anzai
@ 2025-12-24  4:22 ` Shu Anzai
  2025-12-24  5:35   ` SeongJae Park
  2025-12-24  5:38 ` [PATCH v2 0/5] mm/damon/tests/core-kunit: extend existing test scenarios SeongJae Park
  5 siblings, 1 reply; 13+ messages in thread
From: Shu Anzai @ 2025-12-24  4:22 UTC (permalink / raw)
  To: SeongJae Park; +Cc: Andrew Morton, damon, linux-mm, linux-kernel, Shu Anzai

Remove a redundant test case from damos_test_commit_quota_goal() 
as it is already covered. Instead, add a new test for 
DAMOS_QUOTA_SOME_MEM_PSI_US, which was previously not tested.

Signed-off-by: Shu Anzai <shu17az@gmail.com>
---
 mm/damon/tests/core-kunit.h | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/mm/damon/tests/core-kunit.h b/mm/damon/tests/core-kunit.h
index 36622a2c11f1..4bf1d172436b 100644
--- a/mm/damon/tests/core-kunit.h
+++ b/mm/damon/tests/core-kunit.h
@@ -601,9 +601,10 @@ static void damos_test_commit_quota_goal(struct kunit *test)
 			});
 	damos_test_commit_quota_goal_for(test, &dst,
 			&(struct damos_quota_goal) {
-			.metric = DAMOS_QUOTA_USER_INPUT,
-			.target_value = 789,
-			.current_value = 12,
+			.metric = DAMOS_QUOTA_SOME_MEM_PSI_US,
+			.target_value = 234,
+			.current_value = 345,
+			.last_psi_total = 567,
 			});
 }
 
-- 
2.43.0


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

* Re: [PATCH v2 1/5] mm/damon/tests/core-kunit: verify the 'age' field in damon_test_split_at()
  2025-12-24  4:21 ` [PATCH v2 1/5] mm/damon/tests/core-kunit: verify the 'age' field in damon_test_split_at() Shu Anzai
@ 2025-12-24  5:26   ` SeongJae Park
  0 siblings, 0 replies; 13+ messages in thread
From: SeongJae Park @ 2025-12-24  5:26 UTC (permalink / raw)
  To: Shu Anzai; +Cc: SeongJae Park, Andrew Morton, damon, linux-mm, linux-kernel

On Wed, 24 Dec 2025 04:21:56 +0000 Shu Anzai <shu17az@gmail.com> wrote:

> Extend damon_test_split_at() to verify the 'age' field.
> 
> Signed-off-by: Shu Anzai <shu17az@gmail.com>

Reviewed-by: SeongJae Park <sj@kernel.org>

> ---
>  mm/damon/tests/core-kunit.h | 2 ++
>  1 file changed, 2 insertions(+)
> 
> diff --git a/mm/damon/tests/core-kunit.h b/mm/damon/tests/core-kunit.h
> index f59ae7ee19a0..88ec046f4942 100644
> --- a/mm/damon/tests/core-kunit.h
> +++ b/mm/damon/tests/core-kunit.h
> @@ -158,6 +158,7 @@ static void damon_test_split_at(struct kunit *test)
>  	r->nr_accesses_bp = 420000;
>  	r->nr_accesses = 42;
>  	r->last_nr_accesses = 15;
> +	r->age = 10;
>  	damon_add_region(r, t);
>  	damon_split_region_at(t, r, 25);
>  	KUNIT_EXPECT_EQ(test, r->ar.start, 0ul);
> @@ -170,6 +171,7 @@ static void damon_test_split_at(struct kunit *test)
>  	KUNIT_EXPECT_EQ(test, r->nr_accesses_bp, r_new->nr_accesses_bp);
>  	KUNIT_EXPECT_EQ(test, r->nr_accesses, r_new->nr_accesses);
>  	KUNIT_EXPECT_EQ(test, r->last_nr_accesses, r_new->last_nr_accesses);
> +	KUNIT_EXPECT_EQ(test, r->age, r_new->age);
>  
>  	damon_free_target(t);
>  }
> -- 
> 2.43.0


Thanks,
SJ

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

* Re: [PATCH v2 2/5] mm/damon/tests/core-kunit: verify the 'age' and 'nr_accesses_bp' fields in damon_test_merge_two()
  2025-12-24  4:21 ` [PATCH v2 2/5] mm/damon/tests/core-kunit: verify the 'age' and 'nr_accesses_bp' fields in damon_test_merge_two() Shu Anzai
@ 2025-12-24  5:27   ` SeongJae Park
  0 siblings, 0 replies; 13+ messages in thread
From: SeongJae Park @ 2025-12-24  5:27 UTC (permalink / raw)
  To: Shu Anzai; +Cc: SeongJae Park, Andrew Morton, damon, linux-mm, linux-kernel

On Wed, 24 Dec 2025 04:21:57 +0000 Shu Anzai <shu17az@gmail.com> wrote:

> Extend damon_test_merge_two() to verify the 'age' and 
> 'nr_accesses_bp' fields.
> 
> Signed-off-by: Shu Anzai <shu17az@gmail.com>

Reviewed-by: SeongJae Park <sj@kernel.org>


Thanks,
SJ

[...]

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

* Re: [PATCH v2 3/5] mm/damon/tests/core-kunit: add a test case for region merge size limit in damon_test_merge_regions_of()
  2025-12-24  4:21 ` [PATCH v2 3/5] mm/damon/tests/core-kunit: add a test case for region merge size limit in damon_test_merge_regions_of() Shu Anzai
@ 2025-12-24  5:29   ` SeongJae Park
  0 siblings, 0 replies; 13+ messages in thread
From: SeongJae Park @ 2025-12-24  5:29 UTC (permalink / raw)
  To: Shu Anzai; +Cc: SeongJae Park, Andrew Morton, damon, linux-mm, linux-kernel

On Wed, 24 Dec 2025 04:21:58 +0000 Shu Anzai <shu17az@gmail.com> wrote:

> Add a test case in damon_test_merge_regions_of() to verify that 
> two adjacent regions are not merged if the resulting region would 
> exceed the specified size limit.
> 
> Signed-off-by: Shu Anzai <shu17az@gmail.com>

Reviewed-by: SeongJae Park <sj@kernel.org>


Thanks,
SJ

[...]

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

* Re: [PATCH v2 4/5] mm/damon/tests/core-kunit: add test cases for multiple regions in damon_test_split_regions_of()
  2025-12-24  4:21 ` [PATCH v2 4/5] mm/damon/tests/core-kunit: add test cases for multiple regions in damon_test_split_regions_of() Shu Anzai
@ 2025-12-24  5:34   ` SeongJae Park
  2025-12-24 15:31     ` SeongJae Park
  0 siblings, 1 reply; 13+ messages in thread
From: SeongJae Park @ 2025-12-24  5:34 UTC (permalink / raw)
  To: Shu Anzai; +Cc: SeongJae Park, Andrew Morton, damon, linux-mm, linux-kernel

On Wed, 24 Dec 2025 04:21:59 +0000 Shu Anzai <shu17az@gmail.com> wrote:

> Extend damon_test_split_regions_of() to verify that it correctly handles 
> multiple regions with various 'min_sz_region'.
> 
> Signed-off-by: Shu Anzai <shu17az@gmail.com>
> ---
>  mm/damon/tests/core-kunit.h | 21 +++++++++++++++++++++
>  1 file changed, 21 insertions(+)
> 
> diff --git a/mm/damon/tests/core-kunit.h b/mm/damon/tests/core-kunit.h
> index 2eb6f41635a8..36622a2c11f1 100644
> --- a/mm/damon/tests/core-kunit.h
> +++ b/mm/damon/tests/core-kunit.h
> @@ -275,6 +275,9 @@ static void damon_test_split_regions_of(struct kunit *test)
>  {
>  	struct damon_target *t;
>  	struct damon_region *r;
> +	unsigned long sa[] = {0, 300, 500};
> +	unsigned long ea[] = {220, 400, 700};
> +	int i;
>  
>  	t = damon_new_target();
>  	if (!t)
> @@ -301,6 +304,24 @@ static void damon_test_split_regions_of(struct kunit *test)
>  	damon_split_regions_of(t, 4, 1);
>  	KUNIT_EXPECT_LE(test, damon_nr_regions(t), 4u);
>  	damon_free_target(t);
> +
> +	t = damon_new_target();
> +	if (!t)
> +		kunit_skip(test, "third target alloc fail");
> +	for (i = 0; i < ARRAY_SIZE(sa); i++) {
> +		r = damon_new_region(sa[i], ea[i]);
> +		if (!r) {
> +			damon_free_target(t);
> +			kunit_skip(test, "region alloc fail");
> +		}
> +		damon_add_region(r, t);
> +	}
> +	damon_split_regions_of(t, 4, 5);
> +	KUNIT_EXPECT_LE(test, damon_nr_regions(t), 12u);
> +	damon_for_each_region(r, t) {
> +		KUNIT_EXPECT_GE(test, damon_sz_region(r) % 5ul, 0ul);
> +	}

Nit.  The above braces for single statement is unnecessary.

> +	damon_free_target(t);
>  }
>  
>  static void damon_test_ops_registration(struct kunit *test)
> -- 
> 2.43.0

Other than the above trivial nit for the unnecessary braces,

Reviewed-by: SeongJae Park <sj@kernel.org>


Thanks,
SJ

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

* Re: [PATCH v2 5/5] mm/damon/tests/core-kunit: remove a redundant test case and add a new test case in damos_test_commit_quota_goal()
  2025-12-24  4:22 ` [PATCH v2 5/5] mm/damon/tests/core-kunit: remove a redundant test case and add a new test case in damos_test_commit_quota_goal() Shu Anzai
@ 2025-12-24  5:35   ` SeongJae Park
  0 siblings, 0 replies; 13+ messages in thread
From: SeongJae Park @ 2025-12-24  5:35 UTC (permalink / raw)
  To: Shu Anzai; +Cc: SeongJae Park, Andrew Morton, damon, linux-mm, linux-kernel

On Wed, 24 Dec 2025 04:22:00 +0000 Shu Anzai <shu17az@gmail.com> wrote:

> Remove a redundant test case from damos_test_commit_quota_goal() 
> as it is already covered. Instead, add a new test for 
> DAMOS_QUOTA_SOME_MEM_PSI_US, which was previously not tested.
> 
> Signed-off-by: Shu Anzai <shu17az@gmail.com>
> ---
>  mm/damon/tests/core-kunit.h | 7 ++++---
>  1 file changed, 4 insertions(+), 3 deletions(-)
> 
> diff --git a/mm/damon/tests/core-kunit.h b/mm/damon/tests/core-kunit.h
> index 36622a2c11f1..4bf1d172436b 100644
> --- a/mm/damon/tests/core-kunit.h
> +++ b/mm/damon/tests/core-kunit.h
> @@ -601,9 +601,10 @@ static void damos_test_commit_quota_goal(struct kunit *test)
>  			});
>  	damos_test_commit_quota_goal_for(test, &dst,
>  			&(struct damos_quota_goal) {
> -			.metric = DAMOS_QUOTA_USER_INPUT,
> -			.target_value = 789,
> -			.current_value = 12,
> +			.metric = DAMOS_QUOTA_SOME_MEM_PSI_US,
> +			.target_value = 234,
> +			.current_value = 345,
> +			.last_psi_total = 567,
>  			});
>  }
>  
> -- 
> 2.43.0

Reviewed-by: SeongJae Park <sj@kernel.org>


Thanks,
SJ

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

* Re: [PATCH v2 0/5] mm/damon/tests/core-kunit: extend existing test scenarios
  2025-12-24  4:21 [PATCH v2 0/5] mm/damon/tests/core-kunit: extend existing test scenarios Shu Anzai
                   ` (4 preceding siblings ...)
  2025-12-24  4:22 ` [PATCH v2 5/5] mm/damon/tests/core-kunit: remove a redundant test case and add a new test case in damos_test_commit_quota_goal() Shu Anzai
@ 2025-12-24  5:38 ` SeongJae Park
  5 siblings, 0 replies; 13+ messages in thread
From: SeongJae Park @ 2025-12-24  5:38 UTC (permalink / raw)
  To: Shu Anzai; +Cc: SeongJae Park, Andrew Morton, damon, linux-mm, linux-kernel

On Wed, 24 Dec 2025 04:21:55 +0000 Shu Anzai <shu17az@gmail.com> wrote:

> Improve the KUnit test coverage for DAMON. 
> 
> The five patches in this series respectively extend damon_test_split_at(), 
> damon_test_merge_two(), damon_test_merge_regions_of(), 
> damon_test_split_regions_of(), and damos_test_commit_quota_goal().
> 
> Changes from v1:
> - Split the original patch into five smaller patches.
> - Remove a newly added region from damon_test_merge_regions_of() 
>   to avoid an obvious test case.
> - Restore the test case in damon_test_split_regions_of() 
>   that was previously removed.

Thank you for revisioning, Shu!

> 
> Shu Anzai (5):
>   mm/damon/tests/core-kunit: verify the 'age' field in
>     damon_test_split_at()
>   mm/damon/tests/core-kunit: verify the 'age' and 'nr_accesses_bp'
>     fields in damon_test_merge_two()
>   mm/damon/tests/core-kunit: add a test case for region merge size limit
>     in damon_test_merge_regions_of()
>   mm/damon/tests/core-kunit: add test cases for multiple regions in
>     damon_test_split_regions_of()

I left a trivial comment on this fourth patch for unnecessary braces enclosing
a single statement.  Other than that, all look good to me.

>   mm/damon/tests/core-kunit: remove a redundant test case and add a new
>     test case in damos_test_commit_quota_goal()
> 
>  mm/damon/tests/core-kunit.h | 50 +++++++++++++++++++++++++++++--------
>  1 file changed, 39 insertions(+), 11 deletions(-)
> 
> -- 
> 2.43.0


Thanks,
SJ

[...]

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

* Re: [PATCH v2 4/5] mm/damon/tests/core-kunit: add test cases for multiple regions in damon_test_split_regions_of()
  2025-12-24  5:34   ` SeongJae Park
@ 2025-12-24 15:31     ` SeongJae Park
  0 siblings, 0 replies; 13+ messages in thread
From: SeongJae Park @ 2025-12-24 15:31 UTC (permalink / raw)
  To: SeongJae Park; +Cc: Shu Anzai, Andrew Morton, damon, linux-mm, linux-kernel

On Tue, 23 Dec 2025 21:34:06 -0800 SeongJae Park <sj@kernel.org> wrote:

> On Wed, 24 Dec 2025 04:21:59 +0000 Shu Anzai <shu17az@gmail.com> wrote:
> 
> > Extend damon_test_split_regions_of() to verify that it correctly handles 
> > multiple regions with various 'min_sz_region'.
> > 
> > Signed-off-by: Shu Anzai <shu17az@gmail.com>
> > ---
> >  mm/damon/tests/core-kunit.h | 21 +++++++++++++++++++++
> >  1 file changed, 21 insertions(+)
> > 
> > diff --git a/mm/damon/tests/core-kunit.h b/mm/damon/tests/core-kunit.h
> > index 2eb6f41635a8..36622a2c11f1 100644
> > --- a/mm/damon/tests/core-kunit.h
> > +++ b/mm/damon/tests/core-kunit.h
> > @@ -275,6 +275,9 @@ static void damon_test_split_regions_of(struct kunit *test)
> >  {
> >  	struct damon_target *t;
> >  	struct damon_region *r;
> > +	unsigned long sa[] = {0, 300, 500};
> > +	unsigned long ea[] = {220, 400, 700};
> > +	int i;
> >  
> >  	t = damon_new_target();
> >  	if (!t)
> > @@ -301,6 +304,24 @@ static void damon_test_split_regions_of(struct kunit *test)
> >  	damon_split_regions_of(t, 4, 1);
> >  	KUNIT_EXPECT_LE(test, damon_nr_regions(t), 4u);
> >  	damon_free_target(t);
> > +
> > +	t = damon_new_target();
> > +	if (!t)
> > +		kunit_skip(test, "third target alloc fail");
> > +	for (i = 0; i < ARRAY_SIZE(sa); i++) {
> > +		r = damon_new_region(sa[i], ea[i]);
> > +		if (!r) {
> > +			damon_free_target(t);
> > +			kunit_skip(test, "region alloc fail");
> > +		}
> > +		damon_add_region(r, t);
> > +	}
> > +	damon_split_regions_of(t, 4, 5);
> > +	KUNIT_EXPECT_LE(test, damon_nr_regions(t), 12u);
> > +	damon_for_each_region(r, t) {
> > +		KUNIT_EXPECT_GE(test, damon_sz_region(r) % 5ul, 0ul);
> > +	}
> 
> Nit.  The above braces for single statement is unnecessary.

Andrew, could you please pick this series with below attaching fixup for this
one?

> 
> > +	damon_free_target(t);
> >  }
> >  
> >  static void damon_test_ops_registration(struct kunit *test)
> > -- 
> > 2.43.0
> 
> Other than the above trivial nit for the unnecessary braces,
> 
> Reviewed-by: SeongJae Park <sj@kernel.org>
> 
> 
> Thanks,
> SJ


Thanks,
SJ

==== >8 ====
From dde3e0e84056f85cd5cbface38c1f617bfbd0bd4 Mon Sep 17 00:00:00 2001
From: SeongJae Park <sj@kernel.org>
Date: Wed, 24 Dec 2025 07:27:04 -0800
Subject: [PATCH] mm/damon/tests/core-kunit: remove braces for a single
 statement

damon_test_split_regions_of() has braces for a single statement, which
is unnecessary.  Remove it.

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

diff --git a/mm/damon/tests/core-kunit.h b/mm/damon/tests/core-kunit.h
index 36622a2c11f1..252ce3e001c8 100644
--- a/mm/damon/tests/core-kunit.h
+++ b/mm/damon/tests/core-kunit.h
@@ -318,9 +318,8 @@ static void damon_test_split_regions_of(struct kunit *test)
 	}
 	damon_split_regions_of(t, 4, 5);
 	KUNIT_EXPECT_LE(test, damon_nr_regions(t), 12u);
-	damon_for_each_region(r, t) {
+	damon_for_each_region(r, t)
 		KUNIT_EXPECT_GE(test, damon_sz_region(r) % 5ul, 0ul);
-	}
 	damon_free_target(t);
 }
 
-- 
2.47.3


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

end of thread, other threads:[~2025-12-24 15:31 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-12-24  4:21 [PATCH v2 0/5] mm/damon/tests/core-kunit: extend existing test scenarios Shu Anzai
2025-12-24  4:21 ` [PATCH v2 1/5] mm/damon/tests/core-kunit: verify the 'age' field in damon_test_split_at() Shu Anzai
2025-12-24  5:26   ` SeongJae Park
2025-12-24  4:21 ` [PATCH v2 2/5] mm/damon/tests/core-kunit: verify the 'age' and 'nr_accesses_bp' fields in damon_test_merge_two() Shu Anzai
2025-12-24  5:27   ` SeongJae Park
2025-12-24  4:21 ` [PATCH v2 3/5] mm/damon/tests/core-kunit: add a test case for region merge size limit in damon_test_merge_regions_of() Shu Anzai
2025-12-24  5:29   ` SeongJae Park
2025-12-24  4:21 ` [PATCH v2 4/5] mm/damon/tests/core-kunit: add test cases for multiple regions in damon_test_split_regions_of() Shu Anzai
2025-12-24  5:34   ` SeongJae Park
2025-12-24 15:31     ` SeongJae Park
2025-12-24  4:22 ` [PATCH v2 5/5] mm/damon/tests/core-kunit: remove a redundant test case and add a new test case in damos_test_commit_quota_goal() Shu Anzai
2025-12-24  5:35   ` SeongJae Park
2025-12-24  5:38 ` [PATCH v2 0/5] mm/damon/tests/core-kunit: extend existing test scenarios 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.