Linux-mm Archive on lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/5] selftests/damon: misc fixes for test bugs
@ 2026-05-31  8:56 Kunwu Chan
  2026-05-31  9:17 ` [PATCH 1/5] selftests/damon: prevent cross-context state pollution in DamonCtx Kunwu Chan
  2026-05-31 17:08 ` [PATCH 0/5] selftests/damon: misc fixes for test bugs SeongJae Park
  0 siblings, 2 replies; 12+ messages in thread
From: Kunwu Chan @ 2026-05-31  8:56 UTC (permalink / raw)
  To: sj, shuah; +Cc: damon, linux-kselftest, linux-kernel, linux-mm, Kunwu Chan

From: Kunwu Chan <kunwu.chan@gmail.com>

This series fixes several bugs in the DAMON selftests.  Most are
trivial but cause tests to silently pass when they shouldn't, or
fail prematurely on slow machines.

Patch 1 fixes mutable default arguments in DamonCtx.__init__()
that cause state to leak between test instances.

Patch 2 fixes a trailing comma in DamosFilter that turns
memcg_path from a string into a tuple, silently breaking memcg
filter setup.

Patch 3-4 fix bugs in damos_tried_regions.py: wrong operator
precedence drops the "not met" prefix from failure output, and
empty early aggregation cycles cause premature test failure.

Patch 5 fixes several wrong strings that produce dead elif
branches, skipped file existence checks, and broken dict key
lookups.

Based on next-20260529.
base-commit: 7da7f07112610a520567421dd2ffcb51beaefbcc

Kunwu Chan (5):
  selftests/damon: prevent cross-context state pollution in DamonCtx
  selftests/damon: fix memcg filter path handling
  selftests/damon/damos_tried_regions: fix expectation output and join
    TypeError
  selftests/damon/damos_tried_regions: handle empty tried regions in
    early cycles
  selftests/damon: fix dead code, skipped checks, and broken lookups

 tools/testing/selftests/damon/_damon_sysfs.py | 14 +++++++++----
 .../selftests/damon/damos_apply_interval.py   |  2 +-
 .../selftests/damon/damos_quota_goal.py       |  2 +-
 .../selftests/damon/damos_tried_regions.py    | 20 ++++++++++---------
 .../selftests/damon/drgn_dump_damon_status.py |  2 +-
 tools/testing/selftests/damon/sysfs.py        |  4 ++--
 tools/testing/selftests/damon/sysfs.sh        |  6 +++---
 ...te_schemes_tried_regions_wss_estimation.py |  2 +-
 8 files changed, 30 insertions(+), 22 deletions(-)

-- 
2.43.0



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

* [PATCH 1/5] selftests/damon: prevent cross-context state pollution in DamonCtx
  2026-05-31  8:56 [PATCH 0/5] selftests/damon: misc fixes for test bugs Kunwu Chan
@ 2026-05-31  9:17 ` Kunwu Chan
  2026-05-31  9:17   ` [PATCH 2/5] selftests/damon: fix memcg filter path handling Kunwu Chan
                     ` (4 more replies)
  2026-05-31 17:08 ` [PATCH 0/5] selftests/damon: misc fixes for test bugs SeongJae Park
  1 sibling, 5 replies; 12+ messages in thread
From: Kunwu Chan @ 2026-05-31  9:17 UTC (permalink / raw)
  To: sj, shuah
  Cc: damon, linux-kselftest, linux-kernel, linux-mm, Kunwu Chan,
	Wang Lian, Kunwu Chan

From: Kunwu Chan <kunwu.chan@gmail.com>

DamonCtx.__init__() uses mutable default values for
monitoring_attrs, targets, and schemes.  In Python these are
evaluated once at function definition time, so multiple
DamonCtx instances can unintentionally share the same lists
and DamonAttrs instance.

Replace the mutable defaults with None sentinels and
initialize the objects when needed.

Co-developed-by: Wang Lian <lianux.mm@gmail.com>
Signed-off-by: Wang Lian <lianux.mm@gmail.com>
Signed-off-by: Kunwu Chan <chentao@kylinos.cn>
---
 tools/testing/selftests/damon/_damon_sysfs.py | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/tools/testing/selftests/damon/_damon_sysfs.py b/tools/testing/selftests/damon/_damon_sysfs.py
index 8b12cc048440..2f6f2699db25 100644
--- a/tools/testing/selftests/damon/_damon_sysfs.py
+++ b/tools/testing/selftests/damon/_damon_sysfs.py
@@ -624,17 +624,23 @@ class DamonCtx:
     pause = None
     idx = None
 
-    def __init__(self, ops='paddr', monitoring_attrs=DamonAttrs(), targets=[],
-            schemes=[], pause=False):
+    def __init__(self, ops='paddr', monitoring_attrs=None, targets=None,
+            schemes=None, pause=False):
         self.ops = ops
+        if monitoring_attrs is None:
+            monitoring_attrs = DamonAttrs()
         self.monitoring_attrs = monitoring_attrs
         self.monitoring_attrs.context = self
 
+        if targets is None:
+            targets = []
         self.targets = targets
         for idx, target in enumerate(self.targets):
             target.idx = idx
             target.context = self
 
+        if schemes is None:
+            schemes = []
         self.schemes = schemes
         for idx, scheme in enumerate(self.schemes):
             scheme.idx = idx
-- 
2.43.0



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

* [PATCH 2/5] selftests/damon: fix memcg filter path handling
  2026-05-31  9:17 ` [PATCH 1/5] selftests/damon: prevent cross-context state pollution in DamonCtx Kunwu Chan
@ 2026-05-31  9:17   ` Kunwu Chan
  2026-05-31 16:36     ` SeongJae Park
  2026-05-31  9:17   ` [PATCH 3/5] selftests/damon/damos_tried_regions: fix expectation output and join TypeError Kunwu Chan
                     ` (3 subsequent siblings)
  4 siblings, 1 reply; 12+ messages in thread
From: Kunwu Chan @ 2026-05-31  9:17 UTC (permalink / raw)
  To: sj, shuah
  Cc: damon, linux-kselftest, linux-kernel, linux-mm, Kunwu Chan,
	Wang Lian, Kunwu Chan

From: Kunwu Chan <kunwu.chan@gmail.com>

A trailing comma in the memcg_path assignment makes
memcg_path a single-element tuple instead of a string.

As a result, an invalid value is written to sysfs and memcg
filter configuration fails.

Remove the comma.

Co-developed-by: Wang Lian <lianux.mm@gmail.com>
Signed-off-by: Wang Lian <lianux.mm@gmail.com>
Signed-off-by: Kunwu Chan <chentao@kylinos.cn>
---
 tools/testing/selftests/damon/_damon_sysfs.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tools/testing/selftests/damon/_damon_sysfs.py b/tools/testing/selftests/damon/_damon_sysfs.py
index 2f6f2699db25..006c92a76ebe 100644
--- a/tools/testing/selftests/damon/_damon_sysfs.py
+++ b/tools/testing/selftests/damon/_damon_sysfs.py
@@ -271,7 +271,7 @@ class DamosFilter:
         self.type_ = type_
         self.matching = matching
         self.allow = allow
-        self.memcg_path = memcg_path,
+        self.memcg_path = memcg_path
         self.addr_start = addr_start
         self.addr_end = addr_end
         self.target_idx = target_idx
-- 
2.43.0



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

* [PATCH 3/5] selftests/damon/damos_tried_regions: fix expectation output and join TypeError
  2026-05-31  9:17 ` [PATCH 1/5] selftests/damon: prevent cross-context state pollution in DamonCtx Kunwu Chan
  2026-05-31  9:17   ` [PATCH 2/5] selftests/damon: fix memcg filter path handling Kunwu Chan
@ 2026-05-31  9:17   ` Kunwu Chan
  2026-05-31 16:39     ` SeongJae Park
  2026-05-31  9:17   ` [PATCH 4/5] selftests/damon/damos_tried_regions: handle empty tried regions in early cycles Kunwu Chan
                     ` (2 subsequent siblings)
  4 siblings, 1 reply; 12+ messages in thread
From: Kunwu Chan @ 2026-05-31  9:17 UTC (permalink / raw)
  To: sj, shuah
  Cc: damon, linux-kselftest, linux-kernel, linux-mm, Kunwu Chan,
	Wang Lian, Kunwu Chan

From: Kunwu Chan <kunwu.chan@gmail.com>

The expectation print has wrong operator precedence: '%' binds
before the conditional expression, so the else branch prints
'not met' without the prefix 'expectation (>= 14) is'.  Add
parentheses to fix it.

Also, '\n'.join() on the list of ints raises TypeError;
convert to str in the list comprehension.

Co-developed-by: Wang Lian <lianux.mm@gmail.com>
Signed-off-by: Wang Lian <lianux.mm@gmail.com>
Signed-off-by: Kunwu Chan <chentao@kylinos.cn>
---
 tools/testing/selftests/damon/damos_tried_regions.py | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/tools/testing/selftests/damon/damos_tried_regions.py b/tools/testing/selftests/damon/damos_tried_regions.py
index 3b347eb28bd2..d6472e6a6e08 100755
--- a/tools/testing/selftests/damon/damos_tried_regions.py
+++ b/tools/testing/selftests/damon/damos_tried_regions.py
@@ -55,10 +55,10 @@ def main():
     collected_nr_regions.sort()
     sample = collected_nr_regions[4]
     print('50-th percentile nr_regions: %d' % sample)
-    print('expectation (>= 14) is %s' % 'met' if sample >= 14 else 'not met')
+    print('expectation (>= 14) is %s' % ('met' if sample >= 14 else 'not met'))
     if collected_nr_regions[4] < 14:
         print('full nr_regions:')
-        print('\n'.join(collected_nr_regions))
+        print('\n'.join(['%d' % x for x in collected_nr_regions]))
         exit(1)
 
 if __name__ == '__main__':
-- 
2.43.0



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

* [PATCH 4/5] selftests/damon/damos_tried_regions: handle empty tried regions in early cycles
  2026-05-31  9:17 ` [PATCH 1/5] selftests/damon: prevent cross-context state pollution in DamonCtx Kunwu Chan
  2026-05-31  9:17   ` [PATCH 2/5] selftests/damon: fix memcg filter path handling Kunwu Chan
  2026-05-31  9:17   ` [PATCH 3/5] selftests/damon/damos_tried_regions: fix expectation output and join TypeError Kunwu Chan
@ 2026-05-31  9:17   ` Kunwu Chan
  2026-05-31 16:54     ` SeongJae Park
  2026-05-31  9:17   ` [PATCH 5/5] selftests/damon: fix dead code, skipped checks, and broken lookups Kunwu Chan
  2026-05-31 16:30   ` [PATCH 1/5] selftests/damon: prevent cross-context state pollution in DamonCtx SeongJae Park
  4 siblings, 1 reply; 12+ messages in thread
From: Kunwu Chan @ 2026-05-31  9:17 UTC (permalink / raw)
  To: sj, shuah
  Cc: damon, linux-kselftest, linux-kernel, linux-mm, Kunwu Chan,
	Wang Lian, Kunwu Chan

From: Kunwu Chan <kunwu.chan@gmail.com>

The test aborts if the initial aggregation cycles produce zero
tried regions.  This can happen on slow machines, causing false
failures.  Skip empty cycles and retry up to 200 times before
giving up.  Also check that enough samples were collected before
computing the 50th percentile.

Co-developed-by: Wang Lian <lianux.mm@gmail.com>
Signed-off-by: Wang Lian <lianux.mm@gmail.com>
Signed-off-by: Kunwu Chan <chentao@kylinos.cn>
---
 .../selftests/damon/damos_tried_regions.py       | 16 +++++++++-------
 1 file changed, 9 insertions(+), 7 deletions(-)

diff --git a/tools/testing/selftests/damon/damos_tried_regions.py b/tools/testing/selftests/damon/damos_tried_regions.py
index d6472e6a6e08..cc6895c56820 100755
--- a/tools/testing/selftests/damon/damos_tried_regions.py
+++ b/tools/testing/selftests/damon/damos_tried_regions.py
@@ -28,7 +28,9 @@ def main():
         exit(1)
 
     collected_nr_regions = []
-    while proc.poll() is None:
+    nr_retries = 0
+    while proc.poll() is None and nr_retries < 200:
+        nr_retries += 1
         time.sleep(0.1)
         err = kdamonds.kdamonds[0].update_schemes_tried_regions()
         if err is not None:
@@ -38,20 +40,20 @@ def main():
 
         scheme = kdamonds.kdamonds[0].contexts[0].schemes[0]
         if scheme.tried_regions is None:
-            proc.terminate()
-            print('tried regions is not collected')
-            exit(1)
+            continue
 
         nr_tried_regions = len(scheme.tried_regions)
         if nr_tried_regions <= 0:
-            proc.terminate()
-            print('tried regions is not created')
-            exit(1)
+            continue
         collected_nr_regions.append(nr_tried_regions)
         if len(collected_nr_regions) > 10:
             break
     proc.terminate()
 
+    if len(collected_nr_regions) <= 4:
+        print('too few tried regions samples collected')
+        exit(1)
+
     collected_nr_regions.sort()
     sample = collected_nr_regions[4]
     print('50-th percentile nr_regions: %d' % sample)
-- 
2.43.0



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

* [PATCH 5/5] selftests/damon: fix dead code, skipped checks, and broken lookups
  2026-05-31  9:17 ` [PATCH 1/5] selftests/damon: prevent cross-context state pollution in DamonCtx Kunwu Chan
                     ` (2 preceding siblings ...)
  2026-05-31  9:17   ` [PATCH 4/5] selftests/damon/damos_tried_regions: handle empty tried regions in early cycles Kunwu Chan
@ 2026-05-31  9:17   ` Kunwu Chan
  2026-05-31 16:59     ` SeongJae Park
  2026-05-31 16:30   ` [PATCH 1/5] selftests/damon: prevent cross-context state pollution in DamonCtx SeongJae Park
  4 siblings, 1 reply; 12+ messages in thread
From: Kunwu Chan @ 2026-05-31  9:17 UTC (permalink / raw)
  To: sj, shuah
  Cc: damon, linux-kselftest, linux-kernel, linux-mm, Kunwu Chan,
	Wang Lian, Kunwu Chan

From: Kunwu Chan <kunwu.chan@gmail.com>

'hugeapge_size' in drgn_dump_damon_status.py was a dead elif branch.
$fail_reason in sysfs.sh was undefined, silently emptying the error
message.  'exit' instead of 'exist' in sysfs.sh skipped a file
existence check.  'nohugeapge' in sysfs.py broke an action dict
lookup.

Fix other wrong strings in the same files.

Co-developed-by: Wang Lian <lianux.mm@gmail.com>
Signed-off-by: Wang Lian <lianux.mm@gmail.com>
Signed-off-by: Kunwu Chan <chentao@kylinos.cn>
---
 tools/testing/selftests/damon/_damon_sysfs.py               | 2 +-
 tools/testing/selftests/damon/damos_apply_interval.py       | 2 +-
 tools/testing/selftests/damon/damos_quota_goal.py           | 2 +-
 tools/testing/selftests/damon/drgn_dump_damon_status.py     | 2 +-
 tools/testing/selftests/damon/sysfs.py                      | 4 ++--
 tools/testing/selftests/damon/sysfs.sh                      | 6 +++---
 .../sysfs_update_schemes_tried_regions_wss_estimation.py    | 2 +-
 7 files changed, 10 insertions(+), 10 deletions(-)

diff --git a/tools/testing/selftests/damon/_damon_sysfs.py b/tools/testing/selftests/damon/_damon_sysfs.py
index 006c92a76ebe..c197ab99bcc0 100644
--- a/tools/testing/selftests/damon/_damon_sysfs.py
+++ b/tools/testing/selftests/damon/_damon_sysfs.py
@@ -837,7 +837,7 @@ class Kdamond:
                 for goal in scheme.quota.goals:
                     err = goal.stage()
                     if err is not None:
-                        print('commit_schemes_quota_goals failed stagign: %s'%
+                        print('commit_schemes_quota_goals failed staging: %s'%
                               err)
                         exit(1)
         return write_file(os.path.join(self.sysfs_dir(), 'state'),
diff --git a/tools/testing/selftests/damon/damos_apply_interval.py b/tools/testing/selftests/damon/damos_apply_interval.py
index f04d43702481..0f2f36584e48 100755
--- a/tools/testing/selftests/damon/damos_apply_interval.py
+++ b/tools/testing/selftests/damon/damos_apply_interval.py
@@ -56,7 +56,7 @@ def main():
     # Because the second scheme was having the apply interval that is ten times
     # lower than that of the first scheme, the second scheme should be tried
     # about ten times more frequently than the first scheme.  For possible
-    # timing errors, check if it was at least nine times more freuqnetly tried.
+    # timing errors, check if it was at least nine times more frequently tried.
     ratio = nr_tried_stats[1] / nr_tried_stats[0]
     if ratio < 9:
         print('%d / %d = %f (< 9)' %
diff --git a/tools/testing/selftests/damon/damos_quota_goal.py b/tools/testing/selftests/damon/damos_quota_goal.py
index f76e0412b564..661e4ba4765a 100755
--- a/tools/testing/selftests/damon/damos_quota_goal.py
+++ b/tools/testing/selftests/damon/damos_quota_goal.py
@@ -66,7 +66,7 @@ def main():
             # effective quota was already minimum that cannot be more reduced
             if expect_increase is False and last_effective_bytes == 1:
                 continue
-            print('efective bytes not changed: %d' % goal.effective_bytes)
+            print('effective bytes not changed: %d' % goal.effective_bytes)
             exit(1)
 
         increased = last_effective_bytes < goal.effective_bytes
diff --git a/tools/testing/selftests/damon/drgn_dump_damon_status.py b/tools/testing/selftests/damon/drgn_dump_damon_status.py
index 972948e6215f..26b207e44268 100755
--- a/tools/testing/selftests/damon/drgn_dump_damon_status.py
+++ b/tools/testing/selftests/damon/drgn_dump_damon_status.py
@@ -163,7 +163,7 @@ def damos_filter_to_dict(damos_filter):
                                int(damos_filter.addr_range.end)]
     elif type_ == 'target':
         dict_['target_idx'] = int(damos_filter.target_idx)
-    elif type_ == 'hugeapge_size':
+    elif type_ == 'hugepage_size':
         dict_['sz_range'] = [int(damos_filter.sz_range.min),
                              int(damos_filter.sz_range.max)]
     return dict_
diff --git a/tools/testing/selftests/damon/sysfs.py b/tools/testing/selftests/damon/sysfs.py
index aa03a1187489..99412f0d31f3 100755
--- a/tools/testing/selftests/damon/sysfs.py
+++ b/tools/testing/selftests/damon/sysfs.py
@@ -119,7 +119,7 @@ def assert_access_pattern_committed(pattern, dump):
                 'max_nr_accesses', dump)
     assert_true(dump['min_age_region'] == pattern.age[0], 'min_age_region',
                 dump)
-    assert_true(dump['max_age_region'] == pattern.age[1], 'miaxage_region',
+    assert_true(dump['max_age_region'] == pattern.age[1], 'max_age_region',
                 dump)
 
 def assert_scheme_committed(scheme, dump):
@@ -129,7 +129,7 @@ def assert_scheme_committed(scheme, dump):
             'cold': 1,
             'pageout': 2,
             'hugepage': 3,
-            'nohugeapge': 4,
+            'nohugepage': 4,
             'collapse': 5,
             'lru_prio': 6,
             'lru_deprio': 7,
diff --git a/tools/testing/selftests/damon/sysfs.sh b/tools/testing/selftests/damon/sysfs.sh
index 78f4badb5beb..2eaaa5ae3c5e 100755
--- a/tools/testing/selftests/damon/sysfs.sh
+++ b/tools/testing/selftests/damon/sysfs.sh
@@ -3,7 +3,7 @@
 
 source _common.sh
 
-# Kselftest frmework requirement - SKIP code is 4.
+# Kselftest framework requirement - SKIP code is 4.
 ksft_skip=4
 
 ensure_write_succ()
@@ -28,7 +28,7 @@ ensure_write_fail()
 
 	if (echo "$content" > "$file") 2> /dev/null
 	then
-		echo "writing $content to $file succeed ($fail_reason)"
+		echo "writing $content to $file succeeded ($reason)"
 		echo "expected failure because $reason"
 		exit 1
 	fi
@@ -363,7 +363,7 @@ test_context()
 {
 	context_dir=$1
 	ensure_dir "$context_dir" "exist"
-	ensure_file "$context_dir/avail_operations" "exit" 400
+	ensure_file "$context_dir/avail_operations" "exist" 400
 	ensure_file "$context_dir/operations" "exist" 600
 	ensure_file "$context_dir/addr_unit" "exist" 600
 	ensure_file "$context_dir/pause" "exist" 600
diff --git a/tools/testing/selftests/damon/sysfs_update_schemes_tried_regions_wss_estimation.py b/tools/testing/selftests/damon/sysfs_update_schemes_tried_regions_wss_estimation.py
index 35c724a63f6c..16fdc6e7fc56 100755
--- a/tools/testing/selftests/damon/sysfs_update_schemes_tried_regions_wss_estimation.py
+++ b/tools/testing/selftests/damon/sysfs_update_schemes_tried_regions_wss_estimation.py
@@ -7,7 +7,7 @@ import time
 import _damon_sysfs
 
 def pass_wss_estimation(sz_region):
-    # access two regions of given size, 2 seocnds per each region
+    # access two regions of given size, 2 seconds per each region
     proc = subprocess.Popen(
             ['./access_memory', '2', '%d' % sz_region, '2000', 'repeat'])
     kdamonds = _damon_sysfs.Kdamonds([_damon_sysfs.Kdamond(
-- 
2.43.0



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

* Re: [PATCH 1/5] selftests/damon: prevent cross-context state pollution in DamonCtx
  2026-05-31  9:17 ` [PATCH 1/5] selftests/damon: prevent cross-context state pollution in DamonCtx Kunwu Chan
                     ` (3 preceding siblings ...)
  2026-05-31  9:17   ` [PATCH 5/5] selftests/damon: fix dead code, skipped checks, and broken lookups Kunwu Chan
@ 2026-05-31 16:30   ` SeongJae Park
  4 siblings, 0 replies; 12+ messages in thread
From: SeongJae Park @ 2026-05-31 16:30 UTC (permalink / raw)
  To: Kunwu Chan
  Cc: SeongJae Park, shuah, damon, linux-kselftest, linux-kernel,
	linux-mm, Kunwu Chan, Wang Lian, Kunwu Chan

On Sun, 31 May 2026 17:17:20 +0800 Kunwu Chan <kunwu.chan@linux.dev> wrote:

> From: Kunwu Chan <kunwu.chan@gmail.com>
> 
> DamonCtx.__init__() uses mutable default values for
> monitoring_attrs, targets, and schemes.  In Python these are
> evaluated once at function definition time, so multiple
> DamonCtx instances can unintentionally share the same lists
> and DamonAttrs instance.
> 
> Replace the mutable defaults with None sentinels and
> initialize the objects when needed.

Nice change, thank you!

> 
> Co-developed-by: Wang Lian <lianux.mm@gmail.com>
> Signed-off-by: Wang Lian <lianux.mm@gmail.com>
> Signed-off-by: Kunwu Chan <chentao@kylinos.cn>

checkpatch.pl complains as below:

WARNING: From:/Signed-off-by: email address mismatch: 'From: Kunwu Chan <kunwu.chan@gmail.com>' != 'Signed-off-by: Kunwu Chan <chentao@kylinos.cn>'

Other than that,

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


Thanks,
SJ

[...]


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

* Re: [PATCH 2/5] selftests/damon: fix memcg filter path handling
  2026-05-31  9:17   ` [PATCH 2/5] selftests/damon: fix memcg filter path handling Kunwu Chan
@ 2026-05-31 16:36     ` SeongJae Park
  0 siblings, 0 replies; 12+ messages in thread
From: SeongJae Park @ 2026-05-31 16:36 UTC (permalink / raw)
  To: Kunwu Chan
  Cc: SeongJae Park, shuah, damon, linux-kselftest, linux-kernel,
	linux-mm, Kunwu Chan, Wang Lian, Kunwu Chan, Cheng Nie

Conventionally, this mail should be sent as a direct reply to the coverletter.
But somehow this was sent as a reply to the first patch of the series.  Please
send all patches of a series as a direct reply to the coverletter from the next
time.

On Sun, 31 May 2026 17:17:21 +0800 Kunwu Chan <kunwu.chan@linux.dev> wrote:

> From: Kunwu Chan <kunwu.chan@gmail.com>
> 
> A trailing comma in the memcg_path assignment makes
> memcg_path a single-element tuple instead of a string.
> 
> As a result, an invalid value is written to sysfs and memcg
> filter configuration fails.
> 
> Remove the comma.

Good findinng!  But, Cheng sent [1] a same patch earlier.  I believe Cheng is
working on revisioning it.  I think we should give Cheng more time for that.

[1] https://lore.kernel.org/20260529145248.84593-1-sj@kernel.org


Thanks,
SJ

[...]


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

* Re: [PATCH 3/5] selftests/damon/damos_tried_regions: fix expectation output and join TypeError
  2026-05-31  9:17   ` [PATCH 3/5] selftests/damon/damos_tried_regions: fix expectation output and join TypeError Kunwu Chan
@ 2026-05-31 16:39     ` SeongJae Park
  0 siblings, 0 replies; 12+ messages in thread
From: SeongJae Park @ 2026-05-31 16:39 UTC (permalink / raw)
  To: Kunwu Chan
  Cc: SeongJae Park, shuah, damon, linux-kselftest, linux-kernel,
	linux-mm, Kunwu Chan, Wang Lian, Kunwu Chan

On Sun, 31 May 2026 17:17:22 +0800 Kunwu Chan <kunwu.chan@linux.dev> wrote:

> From: Kunwu Chan <kunwu.chan@gmail.com>
> 
> The expectation print has wrong operator precedence: '%' binds
> before the conditional expression, so the else branch prints
> 'not met' without the prefix 'expectation (>= 14) is'.  Add
> parentheses to fix it.
> 
> Also, '\n'.join() on the list of ints raises TypeError;
> convert to str in the list comprehension.

Nice findings and fixes, thank you!

> 
> Co-developed-by: Wang Lian <lianux.mm@gmail.com>
> Signed-off-by: Wang Lian <lianux.mm@gmail.com>
> Signed-off-by: Kunwu Chan <chentao@kylinos.cn>

checkpatch.pl may warn here like below, and it should be fixed.

WARNING: From:/Signed-off-by: email address mismatch: 'From: Kunwu Chan <kunwu.chan@gmail.com>' != 'Signed-off-by: Kunwu Chan <chentao@kylinos.cn>'

Other than that,

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


Thanks,
SJ

[...]


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

* Re: [PATCH 4/5] selftests/damon/damos_tried_regions: handle empty tried regions in early cycles
  2026-05-31  9:17   ` [PATCH 4/5] selftests/damon/damos_tried_regions: handle empty tried regions in early cycles Kunwu Chan
@ 2026-05-31 16:54     ` SeongJae Park
  0 siblings, 0 replies; 12+ messages in thread
From: SeongJae Park @ 2026-05-31 16:54 UTC (permalink / raw)
  To: Kunwu Chan
  Cc: SeongJae Park, shuah, damon, linux-kselftest, linux-kernel,
	linux-mm, Kunwu Chan, Wang Lian, Kunwu Chan

On Sun, 31 May 2026 17:17:23 +0800 Kunwu Chan <kunwu.chan@linux.dev> wrote:

> From: Kunwu Chan <kunwu.chan@gmail.com>
> 
> The test aborts if the initial aggregation cycles produce zero
> tried regions.  This can happen on slow machines, causing false
> failures.  Skip empty cycles and retry up to 200 times before
> giving up.  Also check that enough samples were collected before
> computing the 50th percentile.

I agree this will make the test be more reliable.  I'm bit concerned if 200
times retry can make the test run too long, though.

Also, could you further elaborate why this can fail on slow machines?  That is,
DAMON will check the access of 'access_memory_even' process every 5ms.  Are you
thinking the 5ms is too short for 'access_memory_event' to make the expected
access (accessing the 7 regins of 10 MiB size) within?  If so, should we
increase the sampling interval before retrying?

I also suspect if the unreliable results you seen is due to the fact that DAMON
is not flushing TLB, like we discussed before.  If that's the case, could we
increase the working set size of this test, similar to the wss_estimation test?

[1] https://lore.kernel.org/20260525144846.604907-1-kunwu.chan@linux.dev


Thanks,
SJ

[...]


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

* Re: [PATCH 5/5] selftests/damon: fix dead code, skipped checks, and broken lookups
  2026-05-31  9:17   ` [PATCH 5/5] selftests/damon: fix dead code, skipped checks, and broken lookups Kunwu Chan
@ 2026-05-31 16:59     ` SeongJae Park
  0 siblings, 0 replies; 12+ messages in thread
From: SeongJae Park @ 2026-05-31 16:59 UTC (permalink / raw)
  To: Kunwu Chan
  Cc: SeongJae Park, shuah, damon, linux-kselftest, linux-kernel,
	linux-mm, Kunwu Chan, Wang Lian, Kunwu Chan

On Sun, 31 May 2026 17:17:24 +0800 Kunwu Chan <kunwu.chan@linux.dev> wrote:

> From: Kunwu Chan <kunwu.chan@gmail.com>
> 
> 'hugeapge_size' in drgn_dump_damon_status.py was a dead elif branch.
> $fail_reason in sysfs.sh was undefined, silently emptying the error
> message.  'exit' instead of 'exist' in sysfs.sh skipped a file
> existence check.  'nohugeapge' in sysfs.py broke an action dict
> lookup.
> 
> Fix other wrong strings in the same files.

Good eyes!  Thank you for fixing these!

> 
> Co-developed-by: Wang Lian <lianux.mm@gmail.com>
> Signed-off-by: Wang Lian <lianux.mm@gmail.com>
> Signed-off-by: Kunwu Chan <chentao@kylinos.cn>

Checkpatch.pl will warn as below, and it should be fixed.

WARNING: From:/Signed-off-by: email address mismatch: 'From: Kunwu Chan <kunwu.chan@gmail.com>' != 'Signed-off-by: Kunwu Chan <chentao@kylinos.cn>'

Other than that,

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


Thanks,
SJ

[...]


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

* Re: [PATCH 0/5] selftests/damon: misc fixes for test bugs
  2026-05-31  8:56 [PATCH 0/5] selftests/damon: misc fixes for test bugs Kunwu Chan
  2026-05-31  9:17 ` [PATCH 1/5] selftests/damon: prevent cross-context state pollution in DamonCtx Kunwu Chan
@ 2026-05-31 17:08 ` SeongJae Park
  1 sibling, 0 replies; 12+ messages in thread
From: SeongJae Park @ 2026-05-31 17:08 UTC (permalink / raw)
  To: Kunwu Chan
  Cc: SeongJae Park, shuah, damon, linux-kselftest, linux-kernel,
	linux-mm, Kunwu Chan

On Sun, 31 May 2026 16:56:28 +0800 Kunwu Chan <kunwu.chan@linux.dev> wrote:

> From: Kunwu Chan <kunwu.chan@gmail.com>
> 
> This series fixes several bugs in the DAMON selftests.  Most are
> trivial but cause tests to silently pass when they shouldn't, or
> fail prematurely on slow machines.

Thank you for sharing these great changes, Kunwu and Lian!

> 
> Patch 1 fixes mutable default arguments in DamonCtx.__init__()
> that cause state to leak between test instances.
> 
> Patch 2 fixes a trailing comma in DamosFilter that turns
> memcg_path from a string into a tuple, silently breaking memcg
> filter setup.
> 
> Patch 3-4 fix bugs in damos_tried_regions.py: wrong operator
> precedence drops the "not met" prefix from failure output, and
> empty early aggregation cycles cause premature test failure.
> 
> Patch 5 fixes several wrong strings that produce dead elif
> branches, skipped file existence checks, and broken dict key
> lookups.

I left comments to each patch.  To summarize,

Patches 1, 3 and 5 look good except signer/author info mismatch.

For patches 2 and 4, I think we need more discussions.


Thanks,
SJ

[...]


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

end of thread, other threads:[~2026-05-31 17:08 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-05-31  8:56 [PATCH 0/5] selftests/damon: misc fixes for test bugs Kunwu Chan
2026-05-31  9:17 ` [PATCH 1/5] selftests/damon: prevent cross-context state pollution in DamonCtx Kunwu Chan
2026-05-31  9:17   ` [PATCH 2/5] selftests/damon: fix memcg filter path handling Kunwu Chan
2026-05-31 16:36     ` SeongJae Park
2026-05-31  9:17   ` [PATCH 3/5] selftests/damon/damos_tried_regions: fix expectation output and join TypeError Kunwu Chan
2026-05-31 16:39     ` SeongJae Park
2026-05-31  9:17   ` [PATCH 4/5] selftests/damon/damos_tried_regions: handle empty tried regions in early cycles Kunwu Chan
2026-05-31 16:54     ` SeongJae Park
2026-05-31  9:17   ` [PATCH 5/5] selftests/damon: fix dead code, skipped checks, and broken lookups Kunwu Chan
2026-05-31 16:59     ` SeongJae Park
2026-05-31 16:30   ` [PATCH 1/5] selftests/damon: prevent cross-context state pollution in DamonCtx SeongJae Park
2026-05-31 17:08 ` [PATCH 0/5] selftests/damon: misc fixes for test bugs SeongJae Park

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