[PATCH] eal: add seqlock

Tyler Retzlaff roretzla at linux.microsoft.com
Wed Mar 30 13:24:55 CEST 2022


On Wed, Mar 30, 2022 at 12:50:42PM +0200, Morten Brørup wrote:
> > From: Mattias Rönnblom [mailto:mattias.ronnblom at ericsson.com]
> > Sent: Wednesday, 30 March 2022 12.07
> 
> > +
> > +/**
> > + * The RTE seqlock type.
> > + */
> > +typedef struct {
> > +	uint32_t sn; /**< A generation number for the protected data. */
> > +	rte_spinlock_t lock; /**< Spinlock used to serialize writers.  */
> > +} rte_seqlock_t;
> > +
> 
> You refer to 'sn' as the sequence number everywhere else, so please document is as such:
> "/**< Sequence number for the protected data. */"
> 
> Also, consider making 'sn' volatile, although it is only accessed through the __atomic_load_n() function. I don't know if it makes any difference, so I'm just bringing this to the attention of the experts!

i don't think there is value added by cv-volatile qualification.
if we want correct/portable behavior for all targets then we should
just access with appropriate atomics builtins/intrinsics they will
be qualifying volatile and generating correct barriers when
necessary.

> 
> Acked-by: Morten Brørup <mb at smartsharesystems.com>
> 


More information about the dev mailing list