STRUCT SMP_HOTPLUG_THREAD(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

✨ NAME ✨

struct smp_hotplug_thread β€” the descriptor for a CPU-hotplug-related thread, straight out of the Kernel API Manual, bestie πŸ’–

Like, it's literally the little info packet that tells the kernel everything it needs to know about a per-CPU thread: where to stash the task pointers, what to run, and what to do when a CPU ghosts you (goes offline) or comes back online. Iconic behavior tbh.


🌸 SYNOPSIS 🌸

struct smp_hotplug_thread {
    struct task_struct              * __percpu *store;
    struct list_head                list;
    int (*thread_should_run)(unsigned int cpu);
    void (*thread_fn)(unsigned int cpu);
    void (*create)(unsigned int cpu);
    void (*setup)(unsigned int cpu);
    void (*cleanup)(unsigned int cpu, bool online);
    void (*park)(unsigned int cpu);
    void (*unpark)(unsigned int cpu);
    bool selfparking;
    const char                      *thread_comm;
};

πŸŽ€ Members πŸŽ€

Okay so here's the whole cast of characters, no skips, no cap πŸ‘‘

  • store β€” pointer to the per-CPU storage for the task pointers. It's giving "where did I put my keys" but for task structs πŸ”‘
  • list β€” the list head for core management. Lowkey just the plumbing that keeps everything organized 🧡
  • thread_should_run β€” the vibe check function: it checks whether the thread should run or not. Heads up though β€” it gets called with preemption disabled, so no funny business 😀
  • thread_fn β€” the associated thread function. This is the main character, the actual work πŸ’…
  • create β€” optional setup function, called when the thread gets created. Important: it is not called from the thread context, so don't get it twisted πŸ™ˆ
  • setup β€” optional setup function, called when the thread gets operational for the first time. First-day-of-school energy πŸŽ’
  • cleanup β€” optional cleanup function, called when the thread should stop (i.e. on module exit). Say bye bestie 😭
  • park β€” optional park function, called when the thread is parked (CPU offline). Nap time πŸ›Œ
  • unpark β€” optional unpark function, called when the thread is unparked (CPU online). Wakey wakey ✨
  • selfparking β€” a bool; means the thread is not parked by the park function. It handles its own parking, independent queen πŸ‘‘
  • thread_comm β€” the base name of the thread. That's its government name on the process list πŸͺͺ

πŸ¦‹ SEE ALSO πŸ¦‹

Kernel file ./include/linux/smpboot.h β€” go read it, iykyk 🫢


And that's the whole page bb! Straight from ./include/linux, dated October 2026, and filed under struct smp_hotplug_thread(9). Slay, go write some hotplug threads πŸ’œπŸ”₯

πŸ“¦ where this page comes from