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 (default 1) ๐Ÿ“
  • -M MAX_BLOCK_TIME โ€” The amount of time in microseconds under which we store traces (default U64_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 ๐Ÿงšโœจ