kfifo_out_linear(9)
π kfifo_out_linear(9) β like, the kernel API manual, but make it make sense
okay so real talk bestie, this one's from the Kernel API Manual and it's genuinely not scary, i promise π«Ά it's a macro. a little macro. and it's about to make your linear data processing slay.
β¨ NAME β¨
kfifo_out_linear β gets a tail of/offset to available data π
πΈ SYNOPSIS πΈ
kfifo_out_linear (fifo , tail , n );
π ARGUMENTS π
fifoβ address of the fifo to be used. yes bestie, the actual fifo, hand it over πtailβ pointer to anunsigned intto store the value oftail. it's a pointer, so we're writing through it, not copying it, okay? π¦nβ max. number of elements to point at. like a cap. a limit. a "girl, don't go past this" number π―
π¦ DESCRIPTION π¦
so this macro does the cute thing where it obtains the offset (tail) to the available data in the fifo buffer, and then it returns the numbers of elements available. two jobs, one macro, main character energy fr fr β¨
here's the part that's lowkey iconic: it returns the available count till the end of data or till the end of the buffer. whichever comes first. so you can literally use it for linear data processing β the manpage's own example is a memcpy of (fifo->data + tail) with the count returned. yes. that. exactly that. slay π
β οΈ important caveat, do not skip: note that with only one concurrent reader and one concurrent writer, you don't need extra locking to use these macro. one reader, one writer, that's the vibe. more than that? you're on your own, bestie π
π SEE ALSO π
the whole friend group, no cap β Kernel file ./include/linux/kfifo.h plus:
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_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_ptr(9)
π one more time for the people in the back: kfifo_out_linear_ptr(9) is a different function. don't @ me. iykyk π§
and that's the whole page, bestie! this one came from ./include/linux, dated October 2026 β so go forth, process your data linearly, and remember: one reader, one writer, no extra locking needed πβπ
π¦ 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