blob: fa3b0e36d4dd861dbbd4a5ef4eb591f6cb3adea9 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
|
#!/bin/bash
#
# Mount a loopback filesystem somewhere on /tmp, then run an
# infinite loop inside that does the following:
# 1) Extract linux-3.0.tar.gz
# 2) Delete
# 3) Get memory profile
#
# This test is good at discovering inode-related memory leaks because it creates
# huge numbers of files.
set -eu
# Setup dirs
cd /tmp
wget -nv --show-progress -c https://www.kernel.org/pub/linux/kernel/v3.0/linux-3.0.tar.gz
DIR1=$(mktemp -d /tmp/loopback-mem.XXX)
DIR2=$DIR1.mnt
mkdir $DIR2
# Mount
loopback -l -memprofile /tmp/lmem $DIR2 $DIR1 &
LOOPBACKPID=$(jobs -p)
sleep 1
cd $DIR2
# Cleanup trap
trap "cd /; fusermount -u -z $DIR2; rm -rf $DIR1 $DIR2" EXIT
echo "Starting loop"
N=1
while true; do
t1=$SECONDS
tar xf /tmp/linux-3.0.tar.gz
rm -Rf linux-3.0
t2=$SECONDS
delta=$((t2-t1))
rss=$(grep VmRSS /proc/$LOOPBACKPID/status)
echo "Iteration $N done, $delta seconds, $rss"
let N=$N+1
sleep 1
kill -USR1 $LOOPBACKPID
done
|