cpuhp_setup_...e_cpuslocked(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

πŸ’… 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, not x or test123 😭
  • startup β€” the startup callback function, or NULL if you don't need one. no pressure, it's optional πŸ’–
  • teardown β€” the teardown callback function, or NULL if 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 plain cpuhp_setup_state from inside a region where cpus_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:

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