killall --wait checks only once a second whether the processes are gone, so each cleanup of a write_to_hugetlbfs process costs about a second, although it exits right away on SIGINT. Poll with pgrep every 0.1 seconds instead. With all test cases enabled, this cuts charge_reserved_hugetlb.sh -cgroup-v2 from 144 to 62 seconds in a virtme-ng guest. Signed-off-by: Kurt Lin --- tools/testing/selftests/mm/charge_reserved_hugetlb.sh | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/tools/testing/selftests/mm/charge_reserved_hugetlb.sh b/tools/testing/selftests/mm/charge_reserved_hugetlb.sh index 043cc1b1eb5f..92d6a66e6a84 100755 --- a/tools/testing/selftests/mm/charge_reserved_hugetlb.sh +++ b/tools/testing/selftests/mm/charge_reserved_hugetlb.sh @@ -286,7 +286,10 @@ function cleanup_hugetlb_memory() { local cgroup="$1" if [[ "$(pgrep -f write_to_hugetlbfs)" != "" ]]; then echo killing write_to_hugetlbfs - killall -2 --wait write_to_hugetlbfs + killall -2 write_to_hugetlbfs + while pgrep -f write_to_hugetlbfs > /dev/null; do + sleep 0.1 + done wait_for_hugetlb_memory_to_get_depleted $cgroup fi set -e -- 2.56.1