get_cpu_idle_time_us(9)
β¨ get_cpu_idle_time_us(9) β¨
okay so bestie, this is a page from the Kernel API Manual (yes, the kernel has a manual, and yes it's kinda iconic) β it's all about get_cpu_idle_time_us, and honestly? It does exactly what it says on the tin. Let's get into it π«Ά
πΈ NAME πΈ
get_cpu_idle_time_us β get the total idle time of a CPU
β SYNOPSIS β
u64 get_cpu_idle_time_us (int cpu , u64 *last_update_time );
π ARGUMENTS π
cpuβ the CPU number you wanna query, like "which core are we talking about here" πlast_update_timeβ a variable where the update time gets stored. Lowkey important caveat: do not update counters if this isNULL.
π¦ DESCRIPTION π¦
So what it does is return the cumulative idle time for a given CPU β that's since boot, babe β in microseconds. β±οΈ
β οΈ But listen: this is partially broken because of the counter of iowait tasks, which can be remotely updated without any synchronization. Translation? You might literally observe backward values within two consecutive reads. Not a vibe, but it's the truth π
The time is measured via accounting rather than sampling, and it's as accurate as ktime_get is. No cap. β¨
π RETURN π
The total idle time of the cpu. That's it, that's the tea. π
π SEE ALSO π
- Kernel file
./kernel/sched/cputime.c get_cpu_iowait_time_us(9)
and that's the whole page, bestie π it's from ./kernel/sched, dated October 2026, and it lives in the Kernel API Manual β go forth and query your idle times, you absolute main character π§ββοΈπ
π¦ 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