wakeuptime(8)
โจ wakeuptime(8) โจ
System Manager's Manual, so yes, this one's official ๐
๐ NAME ๐
wakeuptime is your go-to for summarizing sleep-to-wakeup time by waker kernel stack! It uses Linux eBPF/bcc ๐ง
๐ SYNOPSIS ๐
wakeuptime [-h] [-u] [-p PID] [-v] [-f] [--stack-storage-size STACK_STORAGE_SIZE] [-m MIN_BLOCK_TIME] [-M MAX_BLOCK_TIME] [duration]
๐ DESCRIPTION ๐
okay so this program shows the kernel stack traces for threads that woke up other blocked threads ๐ญ It also gives you the process names of the waker and the target, plus a sum of how long the target was blocked, which is called the "blocked time". It works by tracing when threads block and when they get woken up, then measuring the time delta between those two moments. This time measurement is going to be very similar to off-CPU time, but off-CPU time might include a little extra time spent waiting on a run queue to be scheduled. The stack traces, process names, and blocked time all get summarized in the kernel using an eBPF map, which is how it stays efficient ๐ฅ
The output summary helps you figure out why threads were blocking by showing who woke them up and how long they were stuck. It spans all types of blocking activity: disk I/O, network I/O, locks, page faults, involuntary context switches, etc. literally everything that makes a thread wait ๐
This can be used together with offcputime, which shows the stack trace of the blocked thread. wakeuptime shows the stack trace of the waker thread, so you get both sides of the story โจ
Check out http://www.brendangregg.com/FlameGraphs/offcpuflamegraphs.html for more on this.
โ ๏ธ This tool only works on Linux 4.6+. It uses the new BPF_STACK_TRACE table APIs to generate the in-kernel stack traces, so make sure your kernel is up to date bestie ๐
๐ฎ REQUIREMENTS ๐ฎ
You need CONFIG_BPF and bcc. No cap, that's the whole list ๐ซถ
๐ธ OPTIONS ๐ธ
-hโ Print the usage message ๐โโ๏ธ-fโ Print the output in folded stack format ๐ฆ-uโ Only trace user threads, so kernel threads are left out ๐-vโ Show raw addresses (for the non-folded format) ๐ง-p PIDโ Trace this process ID only (filtered in-kernel) ๐ฏ--stack-storage-size STACK_STORAGE_SIZEโ Change the number of unique stack traces that can be stored and displayed ๐durationโ How long to trace, in seconds โฑ๏ธ-m MIN_BLOCK_TIMEโ The amount of time in microseconds over which we store traces (default1) ๐-M MAX_BLOCK_TIMEโ The amount of time in microseconds under which we store traces (defaultU64_MAX) ๐
โจ EXAMPLES โจ
Trace all thread blocking events, and summarize (in-kernel) by kernel stack trace and total blocked time. Main character energy ๐
# wakeuptime
Trace user-mode target threads only ๐ซง
# wakeuptime -u
Trace for 5 seconds only โณ
# wakeuptime 5
Trace for 5 seconds and emit output in folded stack format, which is perfect for flame graphs ๐ฅ
# wakeuptime -f 5
Trace PID 185 only ๐
# wakeuptime -p 185
๐ข OVERHEAD ๐ข
This summarizes unique stack traces in-kernel, which is super efficient and lets it trace a higher rate of events than methods that post-process in user space. The stack trace and time data only gets copied to user space once, when the output is printed. Those techniques lower overhead a ton, but scheduler events are still high frequency, since they can exceed 1 million events per second, so be careful ๐ญ Test before production use.
If the overhead is still a problem, take a look at the min block option. If you're chasing down longer blocking events, you can increase it to filter out shorter blocking events, which lowers overhead even more ๐ซถ
๐ SOURCE ๐
This is from bcc. Slay ๐
https://github.com/iovisor/bcc
Also look in the bcc distribution for a companion _examples.txt file containing example usage, output, and commentary for this tool. It's giving helpful ๐
๐ง OS ๐ง
Linux ๐ง
๐งช STABILITY ๐งช
Unstable, since it's still in development ๐
๐ฉโ๐ป AUTHOR ๐ฉโ๐ป
Brendan Gregg ๐
๐ SEE ALSO ๐
offcputime(8), stackcount(8) ๐ฆ
Bestie, that's the whole page! ๐ Section USER COMMANDS, dated 2016-01-27, wakeuptime(8) ๐ ttyl ๐งโจ
๐ฆ where this page comes from
- debian bookworm: bpfcc-tools 0.26.0+ds-1 ยท Apache-2.0
- debian trixie: bpfcc-tools 0.31.0+ds-7 ยท Apache-2.0
- ubuntu jammy: bpfcc-tools 0.18.0+ds-2 ยท Apache-2.0
- ubuntu noble: bpfcc-tools 0.29.1+ds-1ubuntu7 ยท Apache-2.0
- ubuntu questing: bpfcc-tools 0.31.0+ds-7ubuntu2 ยท Apache-2.0
- ubuntu resolute: bpfcc-tools 0.35.0+ds-1ubuntu2 ยท Apache-2.0
- ubuntu stonking: bpfcc-tools 0.35.0+ds-1ubuntu4 ยท Apache-2.0
- ๐ girlified by anthropic/claude-haiku-5.5 on : a language model's rewrite of the original, under its terms