cpufreq_add_...te_util_hook(9)
β¨ cpufreq_add_update_util_hook(9) β¨
okay so bestie, we're in the Kernel API Manual today and this one is genuinely a little baddie π
it lives in cpufreq_add_...te_util_hook(9) land (yes the name is abridged in the header, that's just how the page rolls, the real name is cpufreq_add_update_util_hook β iykyk π¦)
πΈ NAME πΈ
cpufreq_add_update_util_hook β populate the CPU's update_util_data pointer. that's it. that's the whole job. she's a setter and she's iconic for it π
π SYNOPSIS π
void cpufreq_add_update_util_hook (int cpu , struct update_util_data *data , void (*func)(struct update_util_data *data, u64 time, unsigned int flags) );
likeβ¦ look at that signature. three args, one callback, zero chill π₯
π ARGUMENTS π
cpuβ the CPU you're setting the pointer for, bestie. which one? that one. the one you name. π«Άdataβ the new pointer value. this is thestruct update_util_data *she's getting hitched to.funcβ the callback function to set for the CPU. the main character of this whole operation β¨
π¦ DESCRIPTION π¦
so what she does is set and publish the update_util_data pointer for the given CPU. set and publish. both. she doesn't just set it, she puts it out into the world, she makes it known π
the update_util_data pointer of cpu gets set to data, and the callback function pointer inside the target struct update_util_data gets set to func. two pointers, one motion, slay.
now here's the part you actually need to remember, no cap: that function is gonna be called by cpufreq_update_util from RCU-sched read-side critical sections, so it must not sleep π΄π« like genuinely, do not let it sleep, that's not a vibe, that's a bug.
and data will always be passed to it as the first argument β which is the whole reason the callback can get back to the target update_util_data structure and its container. it's giving "here's your own house key, come find your house" ππ
β οΈ okay so the vibe check that actually matters: theupdate_util_datapointer ofcpumust be NULL when this function is called. if it's not? she willWARNand return with no effect. nothing happens. no set, no publish, just a warning and a shrug π so likeβ¦ check your NULLs first, bestie, fr fr.
π SEE ALSO π
- Kernel file
./kernel/sched/cpufreq.cπ cpufreq_remove_update_util_hook(9)β the breakup counterpart, she undoes the thing π₯cpufreq_this_cpu_can_update(9)β the "can I even do this on this CPU" check π
and that's the page, bestie!! π written down for ./kernel/sched and dated October 2026 β so like, go forth, set your pointers, keep your callbacks non-sleeping, and remember: NULL first, WARN later never. mwah πππ§
π¦ 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