2 # SPDX-License-Identifier: GPL-2.0
4 # Kselftest framework requirement - SKIP code is 4.
13 damon_sysfs
="/sys/kernel/mm/damon/admin"
14 if [ ! -d "$damon_sysfs" ]
16 echo "damon sysfs not found"
23 # start DAMON with a scheme
24 echo 1 > "$damon_sysfs/kdamonds/nr_kdamonds"
25 echo 1 > "$damon_sysfs/kdamonds/0/contexts/nr_contexts"
26 echo "vaddr" > "$damon_sysfs/kdamonds/0/contexts/0/operations"
27 echo 1 > "$damon_sysfs/kdamonds/0/contexts/0/targets/nr_targets"
28 echo $$
> "$damon_sysfs/kdamonds/0/contexts/0/targets/0/pid_target"
29 echo 1 > "$damon_sysfs/kdamonds/0/contexts/0/schemes/nr_schemes"
30 scheme_dir
="$damon_sysfs/kdamonds/0/contexts/0/schemes/0"
31 echo 4096000 > "$scheme_dir/access_pattern/sz/max"
32 echo 20 > "$scheme_dir/access_pattern/nr_accesses/max"
33 echo 1024 > "$scheme_dir/access_pattern/age/max"
34 echo "on" > "$damon_sysfs/kdamonds/0/state"
37 # remove scheme sysfs dir
38 echo 0 > "$damon_sysfs/kdamonds/0/contexts/0/schemes/nr_schemes"
40 # try to update stat of already removed scheme sysfs dir
41 echo "update_schemes_stats" > "$damon_sysfs/kdamonds/0/state"
42 if dmesg |
grep -q BUG
44 echo "update_schemes_stats triggers a kernel bug"
49 # try to update tried regions of already removed scheme sysfs dir
50 echo "update_schemes_tried_regions" > "$damon_sysfs/kdamonds/0/state"
51 if dmesg |
grep -q BUG
53 echo "update_schemes_tried_regions triggers a kernel bug"
58 echo "off" > "$damon_sysfs/kdamonds/0/state"