[RFC,5/5] selftests/damon: add a test for update_schemes_tried_regions hang bug
Commit Message
The update_schemees_tried_{regions,bytes} command was able to be
indefinitely hang in some corner cases. It has fixed by introducing a
timeout for the command[1]. Add a test for the corner case to not
introduce the problem again.
[1] https://lore.kernel.org/damon/20231124213840.39157-1-sj@kernel.org/
Signed-off-by: SeongJae Park <sj@kernel.org>
---
tools/testing/selftests/damon/Makefile | 1 +
...sysfs_update_schemes_tried_regions_hang.py | 33 +++++++++++++++++++
2 files changed, 34 insertions(+)
create mode 100755 tools/testing/selftests/damon/sysfs_update_schemes_tried_regions_hang.py
@@ -12,6 +12,7 @@ TEST_PROGS += debugfs_empty_targets.sh debugfs_huge_count_read_write.sh
TEST_PROGS += debugfs_duplicate_context_creation.sh
TEST_PROGS += debugfs_rm_non_contexts.sh
TEST_PROGS += sysfs.sh sysfs_update_removed_scheme_dir.sh
+TEST_PROGS += sysfs_update_schemes_tried_regions_hang.py
TEST_PROGS += sysfs_update_schemes_tried_regions_wss_estimation.py
TEST_PROGS += reclaim.sh lru_sort.sh
TEST_PROGS += dbgfs_target_ids_read_before_terminate_race.sh
new file mode 100755
@@ -0,0 +1,33 @@
+#!/usr/bin/env python3
+# SPDX-License-Identifier: GPL-2.0
+
+import subprocess
+import time
+
+import _damon
+
+def main():
+ proc = subprocess.Popen(['sleep', '2'])
+ kdamonds = _damon.Kdamonds([_damon.Kdamond(
+ contexts=[_damon.DamonCtx(
+ ops='vaddr',
+ targets=[_damon.DamonTarget(pid=proc.pid)],
+ schemes=[_damon.Damos(
+ access_pattern=_damon.DamosAccessPattern(
+ nr_accesses=[200, 200]))] # schemes
+ )] # contexts
+ )]) # kdamonds
+
+ err = kdamonds.start()
+ if err != None:
+ print('kdmaond start failed: %s' % err)
+ exit(1)
+
+ while proc.poll() == None:
+ err = kdamonds.kdamonds[0].update_schemes_tried_bytes()
+ if err != None:
+ print('tried bytes update failed: %s' % err)
+ exit(1)
+
+if __name__ == '__main__':
+ main()