FDD-book/examples/part-03/ch14-taskqueues-and-deferred-work/labs/coalesce-stress.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

34 lines
980 B
Bash
Executable file

#!/bin/sh
#
# coalesce-stress.sh: Lab 2 companion script.
#
# Drives the Stage 4 driver hard enough to trigger task coalescing,
# then reports the selwake_pending_drops counter. Assumes the driver
# is loaded and instance 0 exists.
set -u
DEV=dev.myfirst.0
echo "Baseline selwake_pending_drops: $(sysctl -n $DEV.stats.selwake_pending_drops 2>/dev/null || echo 0)"
echo "Enabling tick_source at 1 ms..."
sysctl $DEV.tick_source_interval_ms=1 >/dev/null
echo "Running 20 bulk_writer floods of 1000 enqueues each..."
sysctl $DEV.bulk_writer_batch=32 >/dev/null
for i in $(jot 20 1); do
sysctl $DEV.bulk_writer_flood=1000 >/dev/null
done
sleep 2
echo "Final selwake_pending_drops: $(sysctl -n $DEV.stats.selwake_pending_drops)"
echo "Stopping tick_source..."
sysctl $DEV.tick_source_interval_ms=0 >/dev/null
sysctl $DEV.bulk_writer_batch=0 >/dev/null
echo
echo "bytes_read: $(sysctl -n $DEV.stats.bytes_read)"
echo "bytes_written: $(sysctl -n $DEV.stats.bytes_written)"