#!/bin/sh
# DF-3184 forced-reclaim driver (in-guest, ROOT side; harness acceleration:
# forces the reclaim burst that production gets from vnlru under pressure).
# Cycles a scratch procfs mount so that umount -f's vflush reclaims the
# pfs vnodes the unpriv racer children just created, while those children
# exit (at_exit procfs_exit walk) inside the burst.
# usage: mountloop.sh SECONDS MOUNTPOINT [CYCLE_SECONDS_FRAC]
S=${1:-300}
MP=${2:-/procN}
CYC=${3:-0.2}
mkdir -p "$MP"
end=$(( $(date +%s) + S ))
n=0
while [ $(date +%s) -lt $end ]; do
	mount -t procfs procfs "$MP" 2>/dev/null
	sleep "$CYC" 2>/dev/null || sleep 1
	umount -f "$MP" 2>/dev/null
	n=$((n + 1))
done
echo "mountloop: $n cycles"
