You are here: Home / Support / HOWTOs / 
2021-11-28 - 01:14

Dates and Events:

OSADL Articles:

2021-09-06 12:00

"OSADL Track" at EWC 2022: Call for Papers

All about legal and technical issues and solutions when using Open Source software in industry


2021-02-09 12:00

Open Source OPC UA PubSub over TSN project phase #3 launched

Letter of Intent with call for participation is now available


2016-11-12 12:00

Raspberry Pi and real-time Linux

Let's have a look at the OSADL QA Farm data


2016-09-17 12:00

Preemption latency of real-time Linux systems

How to measure it – and how to fix it, if it's too high?



OSADL HOWTOs

HOWTO: Create a frequency plot from hardware latency detector tracer hwlat

Quick description with inlined code

1. Run the hwlat tracer for 30 minutes and store the result in a temporary file

cd /sys/kernel/debug/tracing
echo hwlat >current_tracer
sleep 1800
cat trace >/tmp/hwlatresult
echo nop >current_tracer
echo -n >trace
cd /tmp

2a. Extract the SMI latency values and store inner and outer data in separate files

grep -v -e "^#" -e nmi- hwlatresult | grep -o " [0-9]*/[0-9]* " | cut -d/ -f1 | tr -d " " | grep -v "^0$" | sort -n >inner
grep -v -e "^#" -e nmi- hwlatresult | grep -o " [0-9]*/[0-9]* " | cut -d/ -f2 | tr -d " " | grep -v "^0$" | sort -n >outer

2b. Alternatively, extract the NMI latency values and store inner and outer data in separate files

grep -v -e "^#" hwlatresult | grep nmi- | grep -o " [0-9]*/[0-9]* " | cut -d/ -f1 | tr -d " " | grep -v "^0$" | sort -n >inner
grep -v -e "^#" hwlatresult | grep nmi- | grep -o " [0-9]*/[0-9]* " | cut -d/ -f2 | tr -d " " | grep -v "^0$" | sort -n >outer

3. Calculate maximum value

maxinner=`tail -1 inner | tee maxinner`
maxouter=`tail -1 outer | tee maxouter`if test $maxinner -gt $maxouter
then
max=$maxinner
else
max=$maxouter
fi

4. Create two-column frequency data

echo -n >innerdata
echo -n >outerdata
for i in `seq 0 $max`
do
echo $i `grep "^$i$" inner | wc -l` >>innerdata
echo $i `grep "^$i$" outer | wc -l` >>outerdata
done

5. Create plot command header

echo -n -e "set title \"Latency\"\n\
set terminal png\n\
set xlabel \"Latency (us) - Maximum inner $maxinner/outer $maxouter us\"\n\
set logscale y\n\
set xrange [0:400]\n\
set yrange [0.8:*]\n\
set ylabel \"Number of SMI latency samples\"\n\
set output \"plot.png\"\n\
plot " >plotcmd

6. Append plot command data references

for i in inner outer
do
if test $i != inner
then
echo -n ", " >>plotcmd
fi
title=$i
echo -n "\"${i}data\" using 1:2 title \"$title\" with histeps" >>plotcmd
done

7. Execute plot command

gnuplot -persist <plotcmd

8. Enjoy

firefox plot.png

Download the script

mkhwlatplot.bash

Bash script (must be run as root)

1.5 K

Example plot

And this is how the resulting image may look like.

Example latency plot (click to enlarge)