simplify; comments

This commit is contained in:
Kaiwan N Billimoria
2023-09-03 16:49:13 +05:30
parent e36132daa8
commit 590a69dd27
2 changed files with 15 additions and 22 deletions

View File

@@ -1,22 +1,22 @@
#!/bin/bash
# latency_test.sh
# Originally sourced from OSADL:
# Originally sourced from OSADL [1]:
# https://www.osadl.org/uploads/media/mklatencyplot.bash
# Lightly modified for our purposes.. this script is to be run via it's
# wrapper script runtest.
#----------------------------------------------------------------------
# This program is part of the source code released for the book
# "Linux Kernel Programming"
# "Linux Kernel Programming" 2E
# (c) Author: Kaiwan N Billimoria
# Publisher: Packt
# GitHub repository:
# https://github.com/PacktPublishing/Linux-Kernel-Programming
# https://github.com/PacktPublishing/Linux-Kernel-Programming_2E
#
# For details, refer the book, Ch 11.
#----------------------------------------------------------------------
# Notes/Ref:
# a) http://www.osadl.org/Create-a-latency-plot-from-cyclictest-hi.bash-script-for-latency-plot.0.html
# b) Detailed slides on cyclictest, good for understanding latency and it's
# [1] http://www.osadl.org/Create-a-latency-plot-from-cyclictest-hi.bash-script-for-latency-plot.0.html
# [2] Detailed slides on cyclictest, good for understanding latency and it's
# measurement: 'Using and Understanding the Real-Time Cyclictest Benchmark',
# Rowand, Oct 2013: https://events.static.linuxfound.org/sites/events/files/slides/cyclictest.pdf
name=$(basename $0)
@@ -31,14 +31,6 @@ title="$1"
exit 1
}
which cyclictest >/dev/null && pfx="" || {
pfx=~/rtl_llkd/rt-tests/ # adjust as required !
[ ! -x ${pfx}/cyclictest ] && {
echo "${name}: cyclictest not located, aborting..."
exit 1
}
}
echo "--------------------------"
echo "Test Title :: \"${title}\""
echo "--------------------------"
@@ -54,9 +46,8 @@ loops=100000000
# alternatively: run cyclictest by duration
#duration=12h
duration=1h
duration=1m
echo "sudo ${pfx}cyclictest --duration=${duration} -m -Sp90 -i200 -h400 -q >output"
sudo ${pfx}cyclictest --duration=${duration} -m -Sp90 -i200 -h400 -q >output
echo "sudo cyclictest --duration=${duration} -m -S -p90 -i200 -h400 -q >output"
sudo cyclictest --duration=${duration} -m -S -p90 -i200 -h400 -q >output
# 2. Get maximum latency
min=$(grep "Min Latencies" output | tr " " "\n" | grep "^[0-9]" | sort -n | head -1 | sed s/^0*//)
@@ -83,6 +74,7 @@ done
# 6. Create plot command header
title="${title}: ${latstr} ; kernel: $(uname -r)"
rm -f plotcmd plot_$(uname -r).png 2>/dev/null
echo -n -e "set title \"${title}\"\n\
set terminal png size 800,480\n\
set xlabel \"Latency (us): min $min us, avg $avg us, max $max us\"\n\

View File

@@ -1,19 +1,19 @@
#!/bin/bash
#----------------------------------------------------------------------
# This program is part of the source code released for the book
# "Linux Kernel Programming"
# "Linux Kernel Programming" 2E
# (c) Author: Kaiwan N Billimoria
# Publisher: Packt
# GitHub repository:
# https://github.com/PacktPublishing/Linux-Kernel-Programming
# https://github.com/PacktPublishing/Linux-Kernel-Programming_2E
#
# Wrapper over the cyclictest latency measurement script latency_test.sh.
# For details, refer the book, Ch 11.
#----------------------------------------------------------------------
name=$(basename $0)
LAT=. #~/booksrc/ch11/latency_tests
TIMEOUT_HOURS=1
[ ! -f ${LAT}/latency_test.sh ] && {
[[ ! -f latency_test.sh ]] && {
echo "${name}: latency_test.sh script not present? aborting..."
exit 1
}
@@ -27,9 +27,10 @@ which stress >/dev/null 2>&1 || {
}
echo "================================================================="
${LAT}/latency_test.sh "running 'stress'" &
./latency_test.sh "running 'stress'" &
CMD="stress --cpu 6 --io 2 --hdd 4 --hdd-bytes 1MB --vm 2 --vm-bytes 128M --timeout ${TIMEOUT_HOURS}h"
(cd ${KSRC}
(#cd ${KSRC}
sync ; date
echo "${CMD}"
eval "${CMD}"