mirror of
https://github.com/torvalds/linux.git
synced 2026-04-24 17:42:27 -04:00
Patch series "selftests/damon: improve leak detection and wss estimation reliability". Two DAMON selftets, namely 'sysfs_memcg_leak' and 'sysfs_update_schemes_tried_regions_wss_estimation' frequently show intermittent failures due to their unreliable leak detection and working set size estimation. Make those more reliable. This patch (of 5): sysfs_memcg_path_leak.sh determines if the memory leak has happened by seeing if Slab size on /proc/meminfo increases more than expected after an action. Depending on the system and background workloads, the reasonable expectation varies. For the reason, the test frequently shows intermittent failures. Use kmemleak, which is much more reliable and correct, instead. Link: https://lkml.kernel.org/r/20260117020731.226785-1-sj@kernel.org Link: https://lkml.kernel.org/r/20260117020731.226785-2-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>
46 lines
945 B
Bash
Executable File
46 lines
945 B
Bash
Executable File
#!/bin/bash
|
|
# SPDX-License-Identifier: GPL-2.0
|
|
|
|
if [ $EUID -ne 0 ]
|
|
then
|
|
echo "Run as root"
|
|
exit $ksft_skip
|
|
fi
|
|
|
|
damon_sysfs="/sys/kernel/mm/damon/admin"
|
|
if [ ! -d "$damon_sysfs" ]
|
|
then
|
|
echo "damon sysfs not found"
|
|
exit $ksft_skip
|
|
fi
|
|
|
|
kmemleak="/sys/kernel/debug/kmemleak"
|
|
if [ ! -f "$kmemleak" ]
|
|
then
|
|
echo "$kmemleak not found"
|
|
exit $ksft_skip
|
|
fi
|
|
|
|
# ensure filter directory
|
|
echo 1 > "$damon_sysfs/kdamonds/nr_kdamonds"
|
|
echo 1 > "$damon_sysfs/kdamonds/0/contexts/nr_contexts"
|
|
echo 1 > "$damon_sysfs/kdamonds/0/contexts/0/schemes/nr_schemes"
|
|
echo 1 > "$damon_sysfs/kdamonds/0/contexts/0/schemes/0/filters/nr_filters"
|
|
|
|
filter_dir="$damon_sysfs/kdamonds/0/contexts/0/schemes/0/filters/0"
|
|
|
|
# try to leak 128 times
|
|
for i in {1..128};
|
|
do
|
|
echo "012345678901234567890123456789" > "$filter_dir/memcg_path"
|
|
done
|
|
|
|
echo scan > "$kmemleak"
|
|
kmemleak_report=$(cat "$kmemleak")
|
|
if [ "$kmemleak_report" = "" ]
|
|
then
|
|
exit 0
|
|
fi
|
|
echo "$kmemleak_report"
|
|
exit 1
|