__devm_alloc_percpu(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

✨ __devm_alloc_percpu(9) ✨

okay so bestie, welcome to the kernel API manual page for __devm_alloc_percpu πŸ’… this one lives in the Linux kernel docs and honestly? it's giving "tiny function, huge glow-up energy" πŸŽ€


🌸 NAME 🌸

__devm_alloc_percpu β€” resource-managed alloc_percpu 🫢

like, the alloc_percpu you already know and love, but with the devres babysitter attached ✨


πŸ¦‹ SYNOPSIS πŸ¦‹

void __percpu * __devm_alloc_percpu (struct device *dev , size_t size ,
       size_t align );

πŸ’– ARGUMENTS πŸ’–

  • dev β€” the device you're allocating this per-cpu memory for πŸ‘‘ like, whose devres list is this gonna live on? that one.
  • size β€” the size of the per-cpu memory you wanna allocate πŸ“
  • align β€” the alignment of the per-cpu memory you wanna allocate πŸ“ yes bestie, alignment matters, don't skip it

⭐ DESCRIPTION ⭐

so it's a managed alloc_percpu πŸ’« and the whole slay of it is this: per-cpu memory allocated with this function is automatically freed on driver detach πŸ”₯ no manual cleanup, no "oops I forgot to free it", no leak drama. the devres machinery handles it for you, periodt.

lowkey the most iconic thing about the devm family: you allocate, the driver detaches, it's gone. no cap πŸ™ˆ


🌈 RETURN 🌈

  • pointer to the allocated memory on success πŸŽ‰
  • NULL on failure 😭 (check it, bestie, always check it)

🧚 SEE ALSO 🧚

kernel file ./drivers/base/devres.c β€” and the whole devres friend group, fr fr:


okay but seriously bestie, if you're poking around in ./drivers/base then that list above is your reading list πŸ’€ go be nosy, it's all connected iykyk

and that's the whole page, mwah πŸ’‹ this lil guy is courtesy of the ./drivers/base section of the kernel docs, dated October 2026, and the page is literally titled __devm_alloc_percpu(9) β€” so next time you see that header floating around, you'll know exactly whose vibe it is πŸ‘‘βœ¨πŸ’œ

πŸ“¦ where this page comes from