offwaketime(8)
π offwaketime(8) π
System Manager's Manual π
β¨ NAME β¨
okay so offwaketime is the tool that summarizes blocked time by off-CPU stack + waker stack π§. It uses Linux eBPF/bcc, so it's giving low-level and I'm obsessed π.
πΈ SYNOPSIS πΈ
offwaketime [-h] [-p PID | -t TID | -u | -k] [-U | -K] [-d] [-f]
[--stack-storage-size STACK_STORAGE_SIZE] [-m MIN_BLOCK_TIME] [-M
MAX_BLOCK_TIME] [--state STATE] [duration]
π DESCRIPTION π
bestie, this program shows kernel stack traces and task names for threads that got blocked and went "off-CPU" π. It also shows the stack traces and task names of the threads that woke them up, plus the total elapsed time from when they blocked to when they got woken up β¨. It's basically the offcputime and wakeuptime tools having a baby πΆπ. The time measurement will 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 combined stacks, task names, and total time get summarized in kernel context for efficiency, using an eBPF map. Main character energy π.
The output summary helps you figure out why threads were blocking, and lets you measure the time from when they were blocked to when they were woken up π₯. It covers every type of blocking activity: disk I/O, network I/O, locks, page faults, swapping, sleeping, involuntary context switches, and more π¦.
This is the bestie of CPU profiling (like CPU flame graphs), which shows time spent on-CPU π. This one shows time spent blocked off-CPU instead. The output, especially the -f format, can be used to generate an "off-wake time flame graph" π.
For more, check out http://www.brendangregg.com/FlameGraphs/offcpuflamegraphs.html β¨
π REQUIREMENTS π
You need CONFIG_BPF and bcc. No cap, these are non-negotiable π.
π OPTIONS π
-hβ slay, this prints the usage message π-fβ prints the output in folded stack format π¦-p PIDβ traces only this process ID (filtered in-kernel) π―. It can also be a comma separated list of PIDS π.-t TIDβ traces only this thread ID (filtered in-kernel) π§΅. It can also be a comma separated list of TIDS π«Ά.-uβ only traces user threads, no kernel threads πββοΈ-kβ only traces kernel threads, no user threads π€-Uβ shows stacks from user space only, no kernel space stacks π-Kβ shows stacks from kernel space only, no user space stacks βοΈ-d,--delimitedβ inserts a delimiter between the kernel and user stacks β¨--stack-storage-size STACK_STORAGE_SIZEβ changes how many unique stack traces 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) π·--stateβ filters on this thread state bitmask (eg,2==TASK_UNINTERRUPTIBLE). Checkinclude/linux/sched.hfor the states π§
π§ EXAMPLES π§
Trace all thread blocking events, then summarize (in-kernel) by user and kernel off-CPU stack trace, waker stack traces, task names, and total blocked time. Iconic π₯:
# offwaketime
Trace for only 5 seconds β±οΈ:
# offwaketime 5
Trace for 5 seconds and emit output in folded stack format (perfect for flame graphs), user-mode threads only π:
# offwaketime -fu 5
Trace PID 185 only π―:
# offwaketime -p 185
π OVERHEAD π
Okay so this summarizes unique stack trace pairs in-kernel, which is super efficient π. That 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 β¨. Even with these techniques lowering overhead, scheduler events are still a high frequency event π. They can exceed 1 million events per second, so caution is still needed. Test before production use, periodt π.
If the overhead is still a problem, take a look at the min block option π¨. If you're chasing longer blocking events, you can increase it to filter out shorter blocking events, which lowers overhead even more π .
π¦ SOURCE π¦
This is from bcc π§. You can find it at https://github.com/iovisor/bcc π.
Also look in the bcc distribution for a companion _examples.txt file with example usage, output, and commentary for this tool π.
π OS π
Linux π§
π«§ STABILITY π«§
Unstable, it's still in development π§.
π AUTHOR π
Brendan Gregg π
β SEE ALSO β
offcputime(8), wakeuptime(8) π«Ά
Bye bestie, you're officially a USER COMMANDS legend π β¨ (2016-01-30, offwaketime(8)) ππ
π¦ where this page comes from
- centos-stream 10: bcc-tools 0.36.1-1.el10 Β· Apache-2.0
- centos-stream 9: bcc-tools 0.36.1-1.el9 Β· ASL 2.0
- fedora 43: bcc-tools 0.35.0-2.fc43 Β· Apache-2.0
- fedora 44: bcc-tools 0.35.0-5.fc44 Β· Apache-2.0
- π girlified by anthropic/claude-haiku-5.5 on : a language model's rewrite of the original, under its terms