get_next_freq(9)
β¨ get_next_freq β Kernel API Manual β¨
okay bestie, so this one's a little function living in the Kernel API Manual and it's literally the vibe-checker for CPU frequencies π
π NAME π
get_next_freq β compute a new frequency for a given cpufreq policy. that's it, that's the whole job π«Ά
πΈ SYNOPSIS πΈ
unsigned int get_next_freq (struct sugov_policy *sg_policy , unsigned long util , unsigned long max );
π¦ ARGUMENTS π¦
sg_policyβ the schedutil policy object we're computing the new frequency for. it's giving "the main character of this whole calculation" πutilβ the current CPU utilization. yes, right now, in real time, no cap πmaxβ the CPU capacity. the ceiling, the limit, the "you shall not pass" of this whole thing β
π DESCRIPTION π
so here's the tea, bestie. if the utilization is frequency-invariant (iykyk), we pick the new frequency so it's proportional to that utilization, like:
next_freq = C * max_freq * util / max
but if it's not frequency-invariant, we approximate the would-be frequency-invariant utilization using util_raw * (curr_freq / max_freq), which lowkey leads us to:
next_freq = C * curr_freq * util_raw / max
and we take C = 1.25 so the frequency tipping point lands right at (util / max) = 0.8. iconic constant, honestly π
anyway, the function returns the lowest driver-supported frequency that is equal to or greater than the raw next_freq (as calculated above), and it's subject to policy min/max and cpufreq driver limitations. so like, no, you can't just manifest any frequency you want, bestie π the hardware has opinions π
π₯ SEE ALSO π₯
- Kernel file
./kernel/sched/cpufreq_schedutil.c get_capacity_ref_freq(9)sugov_iowait_reset(9)sugov_iowait_boost(9)sugov_iowait_apply(9)
okay that's the whole page, go off π fr fr, this one's from the ./kernel/sched files, October 2026, filed under get_next_freq(9) β mwah, slay, periodt πβ¨π
π¦ 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