[PATCH v9] eal: add seqlock
Mattias Rönnblom
mattias.ronnblom at ericsson.com
Wed Jun 1 10:19:54 CEST 2022
On 2022-06-01 00:45, Stephen Hemminger wrote:
> On Mon, 23 May 2022 16:23:46 +0200
> Mattias Rönnblom <mattias.ronnblom at ericsson.com> wrote:
>
>> +/**
>> + * The RTE seqcount type.
>> + */
>> +typedef struct {
>> + uint32_t sn; /**< A sequence number for the protected data. */
>> +} rte_seqcount_t;
>
> Don't need structure for only one element.
>
The struct adds a degree of type safety, with no run-time cost.
> typedef uint32_t rte_seqcount_t;
>
> + if (unlikely(begin_sn != end_sn))
> + return true;
> +
> + return false;
>
> Prefer to avoid conditional if possible (compiler will optimize it as):
>
> return begin_sn == end_sn;
Is this a readability argument, or a performance one?
The compiler might use the unlikely hint to do something useful, like
avoiding a branch in the common case.
More information about the dev
mailing list