cpu_util(9)
π
cpu_util(9) β the cpu_util page, bestie edition β¨
okay so real talk: this is a page from the Kernel API Manual, and it's all about cpu_util β the little function that estimates how much CPU capacity your CFS tasks are eating. ngl it's lowkey iconic. let's get into it π«Ά
πΈ NAME πΈ
cpu_util β Estimates the amount of CPU capacity used by CFS tasks.
β¨ SYNOPSIS β¨
unsigned long cpu_util (int cpu , struct task_struct *p , int dst_cpu ,
int boost );
like. look at that signature. four args. no notes. π
π ARGUMENTS π
cpuβ the CPU you want the utilization for β¨pβ the task whose CPU utilization should be predicted, orNULL(yes,NULLis allowed, she's flexible)dst_cpuβ the CPU thatpmigrates to; pass-1ifpmoves fromcpu, or ifp == NULLboostβ1to enable boosting, otherwise0. that's it. binary queen π
π¦ DESCRIPTION π¦
first thing first, the vibe check: the unit of the return value must be the same as the one of CPU capacity, so that CPU utilization can be compared with CPU capacity. no mixing units, we don't do that here π
CPU utilization is the sum of running time of runnable tasks plus the recent utilization of currently non-runnable tasks on that CPU. it represents the amount of CPU capacity currently used by CFS tasks in the range [0..max CPU capacity], with max CPU capacity being the CPU capacity at f_max. periodt. π
the estimated CPU utilization is defined as the maximum between CPU utilization and the sum of the estimated utilization of the currently runnable tasks on that CPU. the way it preserves a utilization "snapshot" of previously-executed tasks?? so good. it helps better deduce how busy a CPU will be when a long-sleeping task wakes up β because the contribution to CPU utilization of such a task would be significantly decayed at this point of time. π
Boosted CPU utilization is defined as max(CPU runnable, CPU utilization). CPU contention for CFS tasks can be detected by CPU runnable > CPU utilization. Boosting is implemented in cpu_util so that internal users (e.g. EAS) can use it next to external users (e.g. schedutil) β the latter via cpu_util_cfs_boost. teamwork makes the dream work fr fr π
β οΈ okay bestie, warning time: CPU utilization can be higher than the current CPU capacity (f_curr/f_max * max CPU capacity) or even the max CPU capacity, because of rounding errors as well as task migrations or wakeups of new tasks. π
and because of that, CPU utilization has to be capped to fit into the [0..max CPU capacity] range. otherwise a group of CPUs (CPU0 util = 121% + CPU1 util = 80%) could be seen as over-utilized even though CPU1 has 20% of spare CPU capacity. like?? that's giving math crime. π¨
but β CPU utilization is allowed to overshoot current CPU capacity, since this is useful for predicting the CPU capacity required after task migrations (scheduler-driven DVFS). so overshoot is fine, capping is mandatory, know the difference bestie π
β RETURN β
(Boosted) (estimated) utilization for the specified CPU. that's the whole thing. slay. β¨
π SEE ALSO π
- Kernel file
./kernel/sched/fair.cβ go read it, iykyk π update_tg_load_avg(9)update_cfs_rq_load_avg(9)attach_entity_load_avg(9)detach_entity_load_avg(9)sched_use_asym_prio(9)sched_group_asym(9)update_sg_lb_stats(9)update_sd_pick_busiest(9)idle_cpu_without(9)update_sd_lb_stats(9)calculate_imbalance(9)sched_balance_find_src_group(9)
π ok that's the page!! this one comes from ./kernel/sched and it's dated October 2026 β screenshot it, cite it, love it. bye bestie, go cap that utilization ππ§ββοΈπ₯
π¦ where this page comes from
- nixpkgs unstable: linux-manual 7.3.1
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms