[PATCH v4 03/27] ring: unify memory model on C11, remove atomic32

Stephen Hemminger stephen at networkplumber.org
Mon Jun 1 23:05:59 CEST 2026


On Mon, 1 Jun 2026 18:18:18 +0000
Konstantin Ananyev <konstantin.ananyev at huawei.com> wrote:

> > +	/* check that we have enough room in ring */
> > +	if (unlikely(n > *entries))
> > +		n = (behavior == RTE_RING_QUEUE_FIXED) ? 0 : *entries;
> > +
> > +	if (n > 0) {
> > +		*new_head = *old_head + n;
> > +		d->head = *new_head;  
> 
> There is a bit of inconsistency with the 'load' operation above:
> If we use atomic_load(&d->head. ...) then it would be better to use
> atomic_store(&d->head,..., order_relaxed) here.

This is single thread case, so not sure atomic_store is needed.
The old code didn't do it.

There is a little confusion in the ST path.
It is used in two different context SP and SC.

For move_head, it is SC that matters and consumer moves the head;
BUT if using multiple produces MP the tail is also examined to
determine space.


More information about the dev mailing list