| 1 |
#! /usr/bin/env stap |
| 2 |
|
| 3 |
# inspired by Tom Zanussi's example from https://lkml.org/lkml/2017/2/8/996 |
| 4 |
|
| 5 |
global ts0%, latency% |
| 6 |
|
| 7 |
function now() { return gettimeofday_us() } |
| 8 |
|
| 9 |
probe kernel.trace("sched_wakeup") { ts0[$p->pid] = now() } |
| 10 |
probe kernel.trace("sched_switch") { |
| 11 |
if (ts0[$next->pid]) latency[$next->pid,$next->prio] <<< now() - ts0[$next->pid]; |
| 12 |
} |
| 13 |
probe timer.s(5) { |
| 14 |
foreach ([pid+,x] in latency) { |
| 15 |
println("pid:", pid, " prio:", x) print(@hist_log(latency[pid,x])) |
| 16 |
} |
| 17 |
delete latency |
| 18 |
} |