Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

selftests/damon: add a test for update_schemes_tried_regions hang bug

Add a test for reproducing the update_schemes_tried_{regions,bytes}
command-causing indefinite hang bug that fixed by commit 7d6fa31a2fd7
("mm/damon/sysfs-schemes: add timeout for update_schemes_tried_regions"),
to avoid mistakenly re-introducing the bug. Refer to the fix commit for
more details of the bug.

Link: https://lkml.kernel.org/r/20231212194810.54457-6-sj@kernel.org
Signed-off-by: SeongJae Park <sj@kernel.org>
Cc: Shuah Khan <shuah@kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>

authored by

SeongJae Park and committed by
Andrew Morton
e3898efa b5906f5f

+34
+1
tools/testing/selftests/damon/Makefile
··· 10 10 TEST_PROGS += debugfs_duplicate_context_creation.sh 11 11 TEST_PROGS += debugfs_rm_non_contexts.sh 12 12 TEST_PROGS += sysfs.sh sysfs_update_removed_scheme_dir.sh 13 + TEST_PROGS += sysfs_update_schemes_tried_regions_hang.py 13 14 TEST_PROGS += sysfs_update_schemes_tried_regions_wss_estimation.py 14 15 TEST_PROGS += reclaim.sh lru_sort.sh 15 16
+33
tools/testing/selftests/damon/sysfs_update_schemes_tried_regions_hang.py
··· 1 + #!/usr/bin/env python3 2 + # SPDX-License-Identifier: GPL-2.0 3 + 4 + import subprocess 5 + import time 6 + 7 + import _damon_sysfs 8 + 9 + def main(): 10 + proc = subprocess.Popen(['sleep', '2']) 11 + kdamonds = _damon_sysfs.Kdamonds([_damon_sysfs.Kdamond( 12 + contexts=[_damon_sysfs.DamonCtx( 13 + ops='vaddr', 14 + targets=[_damon_sysfs.DamonTarget(pid=proc.pid)], 15 + schemes=[_damon_sysfs.Damos( 16 + access_pattern=_damon_sysfs.DamosAccessPattern( 17 + nr_accesses=[200, 200]))] # schemes 18 + )] # contexts 19 + )]) # kdamonds 20 + 21 + err = kdamonds.start() 22 + if err != None: 23 + print('kdmaond start failed: %s' % err) 24 + exit(1) 25 + 26 + while proc.poll() == None: 27 + err = kdamonds.kdamonds[0].update_schemes_tried_bytes() 28 + if err != None: 29 + print('tried bytes update failed: %s' % err) 30 + exit(1) 31 + 32 + if __name__ == '__main__': 33 + main()