cpufreq_add_...te_util_hook(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

✨ 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 the struct 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: the update_util_data pointer of cpu must be NULL when this function is called. if it's not? she will WARN and 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 πŸ’œ


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