kfifo_alloc(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

πŸ’« kfifo_alloc β€” the Kernel API Manual ✨

okay so bestie, we're in the Kernel API Manual today and the main character is kfifo_alloc. it's giving "let there be fifo" energy and honestly? iconic. πŸŽ€


🌸 NAME 🌸

kfifo_alloc β€” dynamically allocates a new fifo buffer πŸ’–


✨ SYNOPSIS ✨

kfifo_alloc (fifo , size , gfp_mask );

that's the whole vibe. three args, no drama. πŸ¦‹


πŸŽ€ ARGUMENTS πŸŽ€

  • fifo β€” pointer to the fifo. like, the actual fifo object you're about to bring into existence. main character energy fr. πŸ‘‘
  • size β€” the number of elements in the fifo, and heads up: this must be a power of 2. not "should", must. do not come in here with your 7 or your 100, it's not happening. πŸ’…
  • gfp_mask β€” the get_free_pages mask, which gets passed straight through to kmalloc. it's the little flag that tells the allocator how to behave. 🫢

πŸ’œ DESCRIPTION πŸ’œ

This macro dynamically allocates a new fifo buffer. literally what it says on the tin. πŸ¦‹

The number of elements will be rounded-up to a power of 2 β€” so even though size has to be a power of 2, the macro's out here rounding up anyway, no cap. πŸŽ€

When you're done with your fifo, the fifo will be released with kfifo_free. don't ghost it, kfifo_free it. 😭

It returns 0 if there's no error β€” otherwise you get an error code back. so like, 0 = slay, anything else = go read the code, bestie. πŸ’€

⚠️ reminder: size must be a power of 2, and the returned fifo gets freed with kfifo_free, and the return is 0 on success or an error code otherwise. those are the three things you cannot fumble. πŸ”₯

🌈 SEE ALSO 🌈

Kernel file ./include/linux/kfifo.h β€” like, the whole family lives here, iykyk. πŸ’…

that's the whole group chat, bestie. every single one. go say hi. πŸ«ΆπŸ’–


and that's the page!! this little beauty came out of ./include/linux, dated October 2026, and it's filed under the Kernel API Manual. mwah πŸ’‹βœ¨πŸŽ€πŸ¦‹

πŸ“¦ where this page comes from