FDD-book/examples/appendices/appendix-f-benchmarks/dtrace/run_overhead_suite.sh
Edson Brandi 6e6dac94fe Add book companion files under examples/
Organize companion code and materials by book part:

  part-01/      Foundations
  part-02/      Kernel & driver fundamentals
  part-03/      Character & block devices
  part-04/      Networking & storage
  part-05/      Buses & advanced topics
  part-06/      Debugging & performance
  part-07/      Real-world drivers
  appendices/   Supplementary material
  README.md     Overview and build instructions
2026-04-25 16:51:00 +00:00

42 lines
1.2 KiB
Bash
Executable file

#!/bin/sh
#
# run_overhead_suite.sh - run the workload programs and print
# their reports, tagged with the current uname and kernel config.
#
# Intended to be run four times: once on a base kernel, once on an
# INVARIANTS kernel, once on a WITNESS kernel, and once on any of
# them with dtrace_overhead.d attached. Compare the result files
# afterward.
#
# Companion to Appendix F of "FreeBSD Device Drivers: From First
# Steps to Kernel Mastery".
set -eu
if [ ! -x ./workload_syscalls ] || [ ! -x ./workload_locks ]; then
echo "error: build the workloads first (run 'make')" >&2
exit 1
fi
# Capture as much of the kernel context as is easy to grab.
echo "# host: $(hostname)"
echo "# uname: $(uname -rmp)"
if sysctl kern.conftxt >/dev/null 2>&1; then
invariants=$(sysctl -n kern.conftxt 2>/dev/null | \
grep -c '^options.*INVARIANTS$' || true)
witness=$(sysctl -n kern.conftxt 2>/dev/null | \
grep -c '^options.*WITNESS$' || true)
echo "# kernel_has_INVARIANTS=${invariants}"
echo "# kernel_has_WITNESS=${witness}"
fi
echo ""
echo "=== syscalls workload ==="
./workload_syscalls
echo ""
echo "=== locks workload ==="
./workload_locks
echo ""
echo "# done"