Permalink
Switch branches/tags
Nothing to show
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
executable file 54 lines (48 sloc) 1.39 KB
#!/usr/bin/stap
#
# read_latencyhistogram_filterPID.stp
#
# This is a SystemTap script to gather I/O latency from the Linux kernel syscall read
# and print I/O latency histograms
# Add a filter on the traced process with the -x <PID> option
#
# By Luca.Canali@cern.ch, September 2017
# Based, with minor modifications, on pread_latencyhistogram.stp (March 2015)
#
# This script is based on original ideas of biolatency-nd.stp of systemtap-lwtools
# by Brendan Gregg
#
# Note: this probe does not need to have kernel debuginfo installed
#
# Usage: stap -v read_latencyhistogram_filterPID.stp -x <PID> <interval>
#
# Example: stap -v read_latencyhistogram_filterPID.stp -x 1234 3
#
global LatencyTimes, RequestTime, TotalLatency
probe nd_syscall.read {
if (pid() == target()) {
RequestTime[tid()] = gettimeofday_us()
}
}
probe nd_syscall.read.return {
if (pid() == target()) {
t = gettimeofday_us()
s = RequestTime[tid()]
if (s > 0) {
deltaT = t-s
TotalLatency += deltaT
LatencyTimes <<< deltaT
delete RequestTime[tid()]
}
}
}
probe timer.sec($1) {
if (@count(LatencyTimes) > 0) {
println("Latency histogram of read calls in the interval")
println(@hist_log(LatencyTimes))
print("Summed latency in the interval (microseconds): ")
println(TotalLatency)
}
delete(LatencyTimes)
TotalLatency = 0
}