kthread_run_on_cpu(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

πŸ’… kthread_run_on_cpu(9) πŸ’…

okay so this is a page from the Kernel API Manual, and it’s lowkey iconic: kthread_run_on_cpu(9). We’re talking about creating and waking a cpu bound thread, and the vibes are very β€œkernel thread main character energy.” ✨

πŸŽ€ NAME πŸŽ€

kthread_run_on_cpu β€” create and wake a cpu bound thread. periodt. That’s the whole name-section mood, fr fr. 🫢

🌸 SYNOPSIS 🌸

no cap, here’s the exact signature β€” keep it cute and keep it literal:

struct task_struct * kthread_run_on_cpu (int (*threadfn)(void *data) ,
void *data , unsigned int cpu , const char *namefmt );

πŸ’– ARGUMENTS πŸ’–

  • threadfn β€” the function to run until signal_pending(current). like, it keeps doing its thing until that signal situation shows up. ⭐
  • data β€” data ptr for threadfn. simple, clean, a little pointer bestie. πŸ“
  • cpu β€” The cpu on which the thread should be bound, πŸ’…
  • namefmt β€” printf-style name for the thread. Format is restricted to "name.*u". Code fills in cpu number. iykyk β€” the format is not freestyle, bestie. 🌈

πŸ”₯ DESCRIPTION πŸ”₯

Convenient wrapper for kthread_create_on_cpu followed by wake_up_process. that’s it, that’s the function, and it ate. πŸ’…

Returns the kthread or ERR_PTR(-ENOMEM). so the return vibe check is: kthread on the happy path, ERR_PTR(-ENOMEM) when memory says no. 😭

bestie reminder: those literal names and tokens are not decorative β€” they’re the actual API. no cap. πŸŽ€

πŸ¦‹ SEE ALSO πŸ¦‹


okay bye bestie, mwah πŸ’‹ β€” this page’s source/version is ./include/linux, dated October 2026. πŸ’–βœ¨πŸ«Ά

πŸ“¦ where this page comes from