#!/bin/sh
# DF-2865 - run the pbufres harness: 10 s of ncpu-thread getpbuf_kva/relpbuf
# hammering with reservation cap = 1, then read the stats and unload.
set -e
cd "$(dirname "$0")"
CFG=../../../dfbsd-qemu/config
SSH="ssh -F $CFG -o ConnectTimeout=8 -o BatchMode=yes dfbsd"

echo "== load module (threads spin 10 s) =="
$SSH 'kldload /root/pbufres/pbufres.ko'
sleep 13
echo "== stats =="
$SSH 'sysctl vm.pbres_neg vm.pbres_min vm.pbres_maxinflight vm.pbres_alive vm.pbres_inflight vm.pbuf_kva_count'
echo "== rescue sleepers (DF-0953 wake-threshold leaves them gated) =="
$SSH 'sysctl vm.pbres_bump=100'
sleep 3
echo "== console messages =="
$SSH 'dmesg | tail -8'
echo "== unload =="
$SSH 'kldunload pbufres' || true
