Hasty Briefsbeta

Bilingual

Lockless MPSC FIFO queues for io_uring

6 days ago
  • Old io_uring task queues used a lockless singly linked list (llist), which acts as a stack, requiring reversal for FIFO ordering, causing inefficiency and extra complexity.
  • The new lockless MPSC queue (multiple producer, single consumer) uses a tail pointer and stub sentinel to enable true FIFO without reversal or retry loops.
  • Producers atomically update the tail pointer with xchg(), ensuring ordering via full memory barrier; no locks or retries needed.
  • Consumers maintain a separate head pointer to avoid cache contention and use mpscq_pop() with cmpxchg to handle races when the list is empty or concurrent additions occur.
  • The new queue simplifies io_uring code, reduces kernel overhead, improves performance, and is used in io_uring 7.2, with code in io_uring/mpscq.h.