mirror of
https://github.com/torvalds/linux.git
synced 2024-12-06 11:01:43 +00:00
f08db42b1c
Commit ebb3f994dd
("mm/damon/dbgfs: fix 'struct pid' leaks in
'dbgfs_target_ids_write()'") fixes a pid leak bug in DAMON debugfs
interface, namely dbgfs_target_ids_write() function. Add a selftest for
the issue to prevent the problem from mistakenly recurring.
Link: https://lkml.kernel.org/r/20240207203134.69976-8-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>
23 lines
527 B
Bash
23 lines
527 B
Bash
#!/bin/bash
|
|
# SPDX-License-Identifier: GPL-2.0
|
|
|
|
before=$(grep "^pid " /proc/slabinfo | awk '{print $2}')
|
|
|
|
nr_leaks=$(./debugfs_target_ids_pid_leak 1000)
|
|
expected_after_max=$((before + nr_leaks / 2))
|
|
|
|
after=$(grep "^pid " /proc/slabinfo | awk '{print $2}')
|
|
|
|
echo > /sys/kernel/debug/damon/target_ids
|
|
|
|
echo "tried $nr_leaks pid leak"
|
|
echo "number of active pid slabs: $before -> $after"
|
|
echo "(up to $expected_after_max expected)"
|
|
if [ $after -gt $expected_after_max ]
|
|
then
|
|
echo "maybe pids are leaking"
|
|
exit 1
|
|
else
|
|
exit 0
|
|
fi
|