Linux-mm Archive on lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/2] selftests/damon: handle early access_memory exit
@ 2026-12-06  9:52 Enze Li
  2026-12-06  9:52 ` [PATCH 1/2] selftests/damon/wss_estimation: " Enze Li
  2026-12-06  9:52 ` [PATCH 2/2] selftests/damon/damos_apply_interval: " Enze Li
  0 siblings, 2 replies; 5+ messages in thread
From: Enze Li @ 2026-12-06  9:52 UTC (permalink / raw)
  To: sj, shuah; +Cc: damon, linux-mm, linux-kselftest, Enze Li

Hi,

Both tests start access_memory and read DAMON data while it runs.  If
the child exits early, they end up reading data that was never filled
in and die with a Python exception.

Make them fail with the child's return code instead.  Two patches, one
per test, since the checks differ: wss_estimation runs access_memory
with 'repeat', so proc.poll() is enough there; damos_apply_interval
expects the child to finish, so it checks whether the scheme stats
were filled instead.

Thanks,
Enze

Enze Li (2):
  selftests/damon/wss_estimation: handle early access_memory exit
  selftests/damon/damos_apply_interval: handle early access_memory exit

 tools/testing/selftests/damon/damos_apply_interval.py     | 7 +++++++
 .../sysfs_update_schemes_tried_regions_wss_estimation.py  | 8 ++++++++
 2 files changed, 15 insertions(+)


base-commit: 6855c02e7d65a8539dc3f8a24946c1ff9bd81361
-- 
2.53.0



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

* [PATCH 1/2] selftests/damon/wss_estimation: handle early access_memory exit
  2026-12-06  9:52 [PATCH 0/2] selftests/damon: handle early access_memory exit Enze Li
@ 2026-12-06  9:52 ` Enze Li
  2026-12-06 10:05   ` sashiko-bot
  2026-12-06  9:52 ` [PATCH 2/2] selftests/damon/damos_apply_interval: " Enze Li
  1 sibling, 1 reply; 5+ messages in thread
From: Enze Li @ 2026-12-06  9:52 UTC (permalink / raw)
  To: sj, shuah; +Cc: damon, linux-mm, linux-kselftest, Enze Li

If access_memory exits immediately, wss_collected is empty and the
percentile check at the end crashes with:

    IndexError: list index out of range

Check proc.poll() after the loop and fail with the child's return code
instead.

Signed-off-by: Enze Li <lienze@kylinos.cn>
---
 .../sysfs_update_schemes_tried_regions_wss_estimation.py  | 8 ++++++++
 1 file changed, 8 insertions(+)

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 36e7ae5f826d..4d81d4245b0c 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
@@ -39,6 +39,14 @@ def pass_wss_estimation(sz_region):
 
         wss_collected.append(
                 kdamonds.kdamonds[0].contexts[0].schemes[0].tried_bytes)
+
+    if proc.poll() is not None:
+        print('access_memory terminated early: %d' % proc.returncode)
+        err = kdamonds.kdamonds[0].stop()
+        if err is not None:
+            print('kdamond stop failed: %s' % err)
+        exit(1)
+
     proc.terminate()
     err = kdamonds.stop()
     if err is not None:
-- 
2.53.0



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

* [PATCH 2/2] selftests/damon/damos_apply_interval: handle early access_memory exit
  2026-12-06  9:52 [PATCH 0/2] selftests/damon: handle early access_memory exit Enze Li
  2026-12-06  9:52 ` [PATCH 1/2] selftests/damon/wss_estimation: " Enze Li
@ 2026-12-06  9:52 ` Enze Li
  2026-12-06 10:03   ` sashiko-bot
  1 sibling, 1 reply; 5+ messages in thread
From: Enze Li @ 2026-12-06  9:52 UTC (permalink / raw)
  To: sj, shuah; +Cc: damon, linux-mm, linux-kselftest, Enze Li

If access_memory exits before the first update_schemes_stats(), the
schemes' stats stay None and reading nr_tried at the end crashes with:

    AttributeError: 'NoneType' object has no attribute 'nr_tried'

Check for that and fail with the child's return code instead.

Signed-off-by: Enze Li <lienze@kylinos.cn>
---
 tools/testing/selftests/damon/damos_apply_interval.py | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/tools/testing/selftests/damon/damos_apply_interval.py b/tools/testing/selftests/damon/damos_apply_interval.py
index 0ad110be0fb9..127253f29c9f 100755
--- a/tools/testing/selftests/damon/damos_apply_interval.py
+++ b/tools/testing/selftests/damon/damos_apply_interval.py
@@ -49,6 +49,12 @@ def main():
             print('stats update failed: %s' % err)
             exit(1)
     schemes = kdamonds.kdamonds[0].contexts[0].schemes
+    if schemes[0].stats is None:
+        print('access_memory terminated early: %d' % proc.returncode)
+        err = kdamonds.kdamonds[0].stop()
+        if err is not None:
+            print('kdamond stop failed: %s' % err)
+        exit(1)
     nr_tried_stats = [s.stats.nr_tried for s in schemes]
     if nr_tried_stats[0] == 0 or nr_tried_stats[1] == 0:
         print('scheme(s) are not tried')
-- 
2.53.0



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

* Re: [PATCH 2/2] selftests/damon/damos_apply_interval: handle early access_memory exit
  2026-12-06  9:52 ` [PATCH 2/2] selftests/damon/damos_apply_interval: " Enze Li
@ 2026-12-06 10:03   ` sashiko-bot
  0 siblings, 0 replies; 5+ messages in thread
From: sashiko-bot @ 2026-12-06 10:03 UTC (permalink / raw)
  To: Enze Li, sj, shuah; +Cc: damon, linux-mm

Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [Low] selftests/damon: missing Fixes trailer for
  damos_apply_interval.py bug fix
--

commit ba843c5ead980821fa4662a5fea5fce0c04f903e
Author: Enze Li <lienze@kylinos.cn>

> selftests/damon/damos_apply_interval: handle early access_memory exit
>
> If access_memory exits before the first update_schemes_stats(), the
> schemes' stats stay None and reading nr_tried at the end crashes with:
>
>     AttributeError: 'NoneType' object has no attribute 'nr_tried'
>
> Check for that and fail with the child's return code instead.
>
> Signed-off-by: Enze Li <lienze@kylinos.cn>

[Severity: Low]
This fixes a crash in damos_apply_interval.py when access_memory exits
before the first stats update.  Should this include:

  Fixes: ce7a2834659f ("selftests/damon: add a test for DAMOS apply intervals")

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261206095226.310682-1-lienze@kylinos.cn?part=2


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

* Re: [PATCH 1/2] selftests/damon/wss_estimation: handle early access_memory exit
  2026-12-06  9:52 ` [PATCH 1/2] selftests/damon/wss_estimation: " Enze Li
@ 2026-12-06 10:05   ` sashiko-bot
  0 siblings, 0 replies; 5+ messages in thread
From: sashiko-bot @ 2026-12-06 10:05 UTC (permalink / raw)
  To: Enze Li, sj, shuah; +Cc: damon, linux-mm

Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [Low] selftests/damon: missing Fixes trailer for wss_estimation
  IndexError fix
--

commit d0d0ca2f5a38e98b65191a5b74fe1f5bad4f5ff2
Author: Enze Li <lienze@kylinos.cn>

> selftests/damon/wss_estimation: handle early access_memory exit
>
> If access_memory exits immediately, wss_collected is empty and the
> percentile check at the end crashes with:
>
>     IndexError: list index out of range
>
> Check proc.poll() after the loop and fail with the child's return code
> instead.
>
> Signed-off-by: Enze Li <lienze@kylinos.cn>

[Severity: Low]
This fixes an IndexError when access_memory exits before any samples are
collected.  Should this include a Fixes tag for the commit that added
the test?

  Fixes: b5906f5f7359 ("selftests/damon: add a test for update_schemes_tried_regions sysfs command")

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261206095226.310682-1-lienze@kylinos.cn?part=1


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

end of thread, other threads:[~2026-12-06 10:05 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-12-06  9:52 [PATCH 0/2] selftests/damon: handle early access_memory exit Enze Li
2026-12-06  9:52 ` [PATCH 1/2] selftests/damon/wss_estimation: " Enze Li
2026-12-06 10:05   ` sashiko-bot
2026-12-06  9:52 ` [PATCH 2/2] selftests/damon/damos_apply_interval: " Enze Li
2026-12-06 10:03   ` sashiko-bot

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