[PATCH] eal: add seqlock

Mattias Rönnblom mattias.ronnblom at ericsson.com
Wed Mar 30 13:25:54 CEST 2022


On 2022-03-30 12:50, 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. */"

Will do.

>
> 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!

It might make a difference, but not for the better. There are almost no 
valid uses of volatile for core-to-core/thread-to-thread 
synchronization, in C11.

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

Thanks for your comments.



More information about the dev mailing list