On Tue, Jun 9, 2026 at 2:20 PM Ilya Maximets <[email protected]> wrote:

> On 6/9/26 12:47 PM, Ales Musil via dev wrote:
> > Add a Single-Producer, Single-Consumer lock-free ring buffer
> > to lib/ for use as a building block in removing pinctrl_mutex
> > contention from packet-in processing.
> >
> > The ring buffer uses a pre-allocated array with atomic read
> > and write indices for synchronization.  Data is copied in
> > and out by value (memcpy), making it well suited for small,
> > fixed-size structs.  Capacity must be a power of two; the
> > implementation uses unsigned 32-bit wraparound arithmetic
> > for correct index handling.
> >
> > Provide SPSC_RING_INIT() for compile-time capacity checking
> > and SPSC_RING_FOR_EACH_POP() for idiomatic drain loops.
> >
> > Include unit tests covering basic push/pop, FIFO ordering,
> > full ring behavior, index wraparound, the FOR_EACH_POP
> > macro, and multi-field struct elements.
>
> Hi, Ales.  Thanks for the patch!  Not a full review, but I wonder why
> a new data structure is needed here.  Is the existing mpsc-queue not
> sufficient?  It is a bit more general, but serves the same purpose more
> or less.
>
> Best regards, Ilya Maximets.
>
>
Hi Ilya,

thank you for the comment, I didn't feel like introducing another
struct that would work with the mpsc-queue node as it didn't really fit
into the existing ones, in the end. On the micro optimaztion side,
mpsc-queue uses a linked list, while the spsc has an array buffer so
it should be better for cache performance, it probably doesn't matter that
much here.

I'm probably fine with rewriting it using mpsc-queue if that feels like a
better
fit.

Regards,
Ales
_______________________________________________
dev mailing list
[email protected]
https://mail.openvswitch.org/mailman/listinfo/ovs-dev

Reply via email to