cpuhp_setup_...e_cpuslocked(9)
π
cpuhp_setup_state_cpuslocked β from the Kernel API Manual, section 9 π
okay so bestie, welcome to the Kernel API Manual, section 9, and honestly this one is a little niche but it's lowkey iconic once you get it. it's called cpuhp_setup_state_cpuslocked and yes the manpage title is literally cpuhp_setup_...e_cpuslocked(9) because someone in kernel-land was too iconic to spell it out fully. we move π
β¨ NAME β¨
cpuhp_setup_state_cpuslocked β Setup hotplug state callbacks with calling @startup callback from a cpus_read_lock() held region π¦
πΈ SYNOPSIS πΈ
int cpuhp_setup_state_cpuslocked (enum cpuhp_state state , const char *name , int (*startup)(unsigned int cpu) , int (*teardown)(unsigned int cpu) );
that's the whole signature, no cap. four things go in, one int comes out π
π ARGUMENTS π
stateβ the state for which the calls are installed. this is like... the vibe check for where in the hotplug lifecycle your callbacks get to hang out β¨nameβ name of the callback, and heads up, it will be used in debug output. so pick something cute and readable, notxortest123πstartupβ the startup callback function, orNULLif you don't need one. no pressure, it's optional πteardownβ the teardown callback function, orNULLif you don't need one. also optional, also valid π«Ά
every callback takes an unsigned int cpu and hands back an int, in case you were wondering what the types are doing in there π§
π DESCRIPTION π
okay so here's the tea: this is the same as cpuhp_setup_state, literally identical energy, except β and this is the main character detail β it must be invoked from within a cpus_read_lock() held region.
like, that's the entire bit. you're already holding the read lock, you're already locked in, so this variant is the one that's safe to call right there without unlocking and relocking and making a whole thing of it. slay.
β οΈ for real though, don't call the plaincpuhp_setup_statefrom inside a region wherecpus_read_lock()is already held β that's exactly the situation this function exists for. this version assumes you're already locked and doesn't want you doing any extra setup around it π₯
π SEE ALSO π
the source of truth, the kernel file itself: ./include/linux/cpuhotplug.h π and honestly the whole hotplug family, all of it, no skips:
cpuhp_setup_state(9)cpuhp_setup_state_nocalls(9)cpuhp_setup_state_nocalls_cpuslocked(9)cpuhp_setup_state_multi(9)cpuhp_state_add_instance(9)cpuhp_state_add_instance_nocalls(9)cpuhp_state_add_instance_nocalls_cpuslocked(9)cpuhp_remove_state(9)cpuhp_remove_state_nocalls(9)cpuhp_remove_state_nocalls_cpuslocked(9)cpuhp_remove_multi_state(9)cpuhp_state_remove_instance(9)cpuhp_state_remove_instance_nocalls(9)
that's the full roster, the whole friend group ππ
and that's the page, bestie β brought to you from ./include/linux, dated October 2026, filed under cpuhp_setup_...e_cpuslocked(9). go forth and hold that read lock responsibly π§β¨
π¦ 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