kfifo_alloc(9)
π« 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 your7or your100, it's not happening. πgfp_maskβ the get_free_pages mask, which gets passed straight through tokmalloc. 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:sizemust be a power of 2, and the returned fifo gets freed withkfifo_free, and the return is0on 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. π
DECLARE_KFIFO_PTR(9)DECLARE_KFIFO(9)INIT_KFIFO(9)DEFINE_KFIFO(9)kfifo_initialized(9)kfifo_esize(9)kfifo_recsize(9)kfifo_size(9)kfifo_reset(9)kfifo_reset_out(9)kfifo_len(9)kfifo_is_empty(9)kfifo_is_empty_spinlocked(9)kfifo_is_empty_spinlocked_noirqsave(9)kfifo_is_full(9)kfifo_avail(9)kfifo_skip_count(9)kfifo_skip(9)kfifo_peek_len(9)kfifo_alloc_node(9)kfifo_free(9)kfifo_init(9)kfifo_put(9)kfifo_get(9)kfifo_peek(9)kfifo_in(9)kfifo_in_spinlocked(9)kfifo_in_spinlocked_noirqsave(9)kfifo_out(9)kfifo_out_spinlocked(9)kfifo_out_spinlocked_noirqsave(9)kfifo_from_user(9)kfifo_to_user(9)kfifo_dma_in_prepare_mapped(9)kfifo_dma_in_finish(9)kfifo_dma_out_prepare_mapped(9)kfifo_dma_out_finish(9)kfifo_out_peek(9)kfifo_out_linear(9)kfifo_out_linear_ptr(9)
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
- nixpkgs unstable: linux-manual 7.3.1
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms