[PATCH] spinlock: remove volatile qualifier

Thomas Monjalon thomas at monjalon.net
Tue May 5 09:01:43 CEST 2026


04/05/2026 19:02, Stephen Hemminger:
> On Mon,  4 May 2026 10:37:14 +0200
> Thomas Monjalon <thomas at monjalon.net> wrote:
> 
> > diff --git a/lib/eal/include/generic/rte_spinlock.h b/lib/eal/include/generic/rte_spinlock.h
> > index c907d4e45c..19c0e34f0a 100644
> > --- a/lib/eal/include/generic/rte_spinlock.h
> > +++ b/lib/eal/include/generic/rte_spinlock.h
> > @@ -197,8 +197,8 @@ rte_spinlock_trylock_tm(rte_spinlock_t *sl)
> >   */
> >  typedef struct {
> >  	rte_spinlock_t sl; /**< the actual spinlock */
> > -	volatile int user; /**< core id using lock, -1 for unused */
> > -	volatile int count; /**< count of time this lock has been called */
> > +	int user; /**< core id using lock, -1 for unused */
> > +	int count; /**< count of time this lock has been called */
> 
> It might make sense to use unsigned for count, and sized types.
> I.e do you really need 32 bit values?

Such a change would need to be evaluated in a performance benchmark.

> Only in tree use of recursive spinlock in vdev code.
> 
> PS: I wonder if we really need to keep the transactional memory versions of stuff.

I don't know, it's part of the API and has no maintenance cost.




More information about the dev mailing list