Designing Lock-Free Queues: Inside the Linux KFIFO and Ringbuffer Implementations
How the Linux kernel’s KFIFO achieves a wait-free, lock-free FIFO with a single atomic variable. We walk through the ringbuffer math, the memory-ordering subtlety that makes it correct on weakly ordered CPUs, and what you can borrow for your own high-throughput pipelines.