xref: /linux/tools/testing/selftests/damon/debugfs_target_ids_pid_leak.sh (revision 2573c25e2c482b53b6e1142ff3cd28f6de13e659)
1#!/bin/bash
2# SPDX-License-Identifier: GPL-2.0
3
4before=$(grep "^pid " /proc/slabinfo | awk '{print $2}')
5
6nr_leaks=$(./debugfs_target_ids_pid_leak 1000)
7expected_after_max=$((before + nr_leaks / 2))
8
9after=$(grep "^pid " /proc/slabinfo | awk '{print $2}')
10
11echo > /sys/kernel/debug/damon/target_ids
12
13echo "tried $nr_leaks pid leak"
14echo "number of active pid slabs: $before -> $after"
15echo "(up to $expected_after_max expected)"
16if [ $after -gt $expected_after_max ]
17then
18	echo "maybe pids are leaking"
19	exit 1
20else
21	exit 0
22fi
23