kfifo_init(9)
π kfifo_init β like, the kernel API manual page, bestie π
okay so you found your way to kfifo_init(9) and honestly? proud of you. this is a kernel API manual page, and we're about to make it make sense. no cap.
β¨ NAME β¨
kfifo_init β initialize a fifo using a preallocated buffer π
like, you already have the buffer, and this macro is the one that goes "slay, let's hook it up."
π¦ SYNOPSIS π¦
kfifo_init (fifo , buffer , size );
that's the whole vibe. three args, no drama.
πΈ ARGUMENTS πΈ
fifoβ the fifo to assign the buffer π«Ά this is the one getting the glow-up.bufferβ the preallocated buffer to be used β¨ you bring your own, that's the whole point.sizeβ the size of the internal buffer, this have to be a power of 2 π yes, exactly like that, it have to be a power of 2. non-negotiable, the math said so.
π DESCRIPTION π
This macro initializes a fifo using a preallocated buffer. main character macro behavior, honestly β it doesn't allocate anything, it just takes your buffer and makes it official.
The number of elements will be rounded-up to a power of 2. π₯ so if you were out here thinking your size was gonna stay exactly as you typed itβ¦ nope, it's getting rounded up, that's just the rules.
Return 0 if no error, otherwise an error code. Simple as. π
ngl, remember the power-of-2 thing. future you will thank present you. π§
π SEE ALSO π
Kernel file ./include/linux/kfifo.h β and like, the entire kfifo cinematic universe:
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(9)kfifo_alloc_node(9)kfifo_free(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)
and that's the page, bestie π this one lives in ./include/linux, October 2026 edition β go forth and round up to powers of 2 πβ¨
π¦ 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