cpuunclaimed(8)
β¨ NAME β¨
bestie, this is the System Manager's Manual page for cpuunclaimed(8) π It's a tool that samples CPU run queues and works out unclaimed idle CPU. It uses Linux eBPF/bcc, so it's giving low-level Linux tracing energy π
π¦ SYNOPSIS π¦
cpuunclaimed [-T] [-j] [-J] [interval [count]]
π DESCRIPTION π
okay so this tool samples the length of the run queues and figures out when there are idle CPUs π but there are also threads queued up waiting for their turn. That's the real tea β It reports the leftover idle CPU (the stuff that isn't being claimed by waiting threads) as a system-wide percentage.
This can happen for a few reasons, and they're kinda iconic π
- An application got bound to some CPUs but not all of them, so its runnable threads can't hop over to the other CPUs because of that setup π
- CPU affinity π§ This is an optimization that keeps threads on the CPUs where the caches are still warm, even if that means a short wait while other CPUs sit idle. The wait period is tunable (see sysctl, kernel.sched*) β¨
- Scheduler bugs π
Here's the vibe check: an unclaimed idle below 1% is probably CPU affinity, and honestly not usually something to stress about π Leaving the CPU idle can even improve overall system throughput. This tool is best at spotting the bigger issues, like anything above 2%, because its samples only fire at 99 Hertz so it's kinda coarse πΈ
This tool is experimental π§ͺ It works by sampling to keep overhead low, and it leans on a few assumptions:
- CPU samples consistently fire around the same offset π°οΈ Sometimes there's a lag because higher-priority interrupts delay a sample, but the later samples are expected to catch back up to the expected offsets (and that's what happens in practice). You can use
-Jto inspect sample offsets. Some systems power down CPUs when idle, and when those CPUs wake up they may start firing at a skewed offset. When that happens this tool detects the skew, prints an error, and exits π - All CPUs are online (see ncpu) π
If it flags unclaimed CPU, you can double-check by dumping the raw samples with -j, and you can also use other tracing tools to instrument scheduler events. Heads up though, that second approach has way higher overhead π
Since this uses BPF, only the root user can run this tool. No exceptions, bestie π₯
π REQUIREMENTS π
You'll need CONFIG_BPF and bcc π
π EXAMPLES π
Sample and calculate unclaimed idle CPUs, output every 1 second (default:
# cpuunclaimed
Print 5 second summaries, 10 times:
# cpuunclaimed 5 10
Print 1 second summaries with timestamps:
# cpuunclaimed -T 1
Raw dump of all samples (verbose), as comma-separated values:
# cpuunclaimed -j
π· FIELDS π·
%CPUβ CPU utilization as a system-wide percentage β¨- unclaimed idle β the percentage of CPU resources that were idle while work was queued up on other CPUs, as a system-wide percentage π
TIMEβ the time, formatted as HH:MM:SS β°TIMESTAMP_nsβ the timestamp, in nanoseconds π«CPU#β the CPU ID π¦OFFSET_ns_CPU#β the time offset at which a sample fired within a sample group for this CPU π§
π«Ά OVERHEAD π«Ά
The overhead is expected to be low, basically negligible π₯Ή This tool samples at 99 Hertz on all CPUs, which has a fixed and small cost. Other approaches sample every scheduler event instead, and that can mean instrumenting millions of events per second, which is a whole mood π Sampled CPUs, run queue lengths, and timestamps get written to ring buffers, and user space reads them periodically for reporting. Still, measure the overhead in a test environment first, no shortcuts π
π SOURCE π
This comes from bcc π
There's also a companion _examples.txt file in the bcc distribution with example usage, output, and commentary for this tool, so go check that out too π
π OS π
Linux π§
π§ͺ STABILITY π§ͺ
Unstable, it's still in development π§
π AUTHOR π
Brendan Gregg, the legend himself β¨
π SEE ALSO π
runqlen(8)πΈ
Till next time, bestie π¦ That's the USER COMMANDS manual, dated 2016-12-21, for cpuunclaimed(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