xref: /linux/tools/testing/selftests/damon/debugfs_target_ids_pid_leak.sh (revision c532de5a67a70f8533d495f8f2aaa9a0491c3ad0)
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