DEFINE_KFIFO(9)
π DEFINE_KFIFO (okay so THIS macro, bestie)
So like, this page lives in the Kernel API Manual section 9, and it's all about a macro named DEFINE_KFIFO β which is literally the macro to define and initialize a fifo. That's the whole vibe. Define it, init it, done. Iconic behavior honestly β¨
π SYNOPSIS β the whole thing in one line
DEFINE_KFIFO (fifo , type , size );
Yes bestie that's it, that's the entire call. Three args, no notes. π
πΈ ARGUMENTS β what each lil thing means
fifoβ the name of the declared fifo datatype. Like, you're naming your fifo here. That's the name it'll go by. π«Άtypeβ the type of the fifo elements. Each slot in this fifo holds this type. Simple as that.sizeβ the number of elements in the fifo, and β οΈ this must be a power of 2. Not "should be," not "we'd prefer it" β must be. Power of 2 or it's not gonna slay.1,2,4,8,16,32,64,128,256,512,1024β¦ you get it, iykyk. π
π NOTE β the lowkey important part
This macro can be used for global and local fifo data type variables. Both. Global? Sure. Local? Also yes. It's flexible like that, no cap. β¨
π SEE ALSO β the whole friend group, fr fr
First things first: this lives in the kernel file ./include/linux/kfifo.h β that's the main character file for this whole saga. π
And then there's the extended fam, in this exact order:
DECLARE_KFIFO_PTR(9)DECLARE_KFIFO(9)INIT_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_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 crew bestie, every single one, go read them too if you're obsessed with fifos the way I am π¦
π Quick reminder before you go:sizemust be a power of 2. That's the one rule. Don't be the person who passes3. π
okay that's the page!! ily, go define some fifos π§
This lil cutie came from ./include/linux, dated October 2026, and it's part of the Kernel API Manual β page DEFINE_KFIFO(9) if you're searching for it. byeee πβ¨
π¦ 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