[dpdk-dev] [PATCH 1/2] ring: fix declaration after code

Andy Green andy at warmcat.com
Mon May 28 10:46:59 CEST 2018



On 05/28/2018 04:15 PM, Gavin Hu wrote:

>   do {
> +const uint32_t cons_tail = r->cons.tail;
> +
>   /* Reset n to the initial burst count */
>   n = max;
> 
>   *old_head = __atomic_load_n(&r->prod.head,
>   __ATOMIC_ACQUIRE);
> -const uint32_t cons_tail = r->cons.tail;
> +
> [Gavin Hu] The ACQUIRE and RELEASE pair protects anything that between the two must be visible to other threads when they perform an acquire operation on the same memory address. Your changes broke this semantics.  I advise to move the declaration before and keep the assignment in the old place.

I see, thanks for the tip.

How about just get rid of this temp altogether if access to it is locked 
during this sequence anyway?  It's not like we had to sample it after 
the lock then, or it's bringing anything else to the party.

So instead of cons_tail / prod_tail at all, replace directly with 
r->cons.tail / r->prod.tail at the single usage for each.

-Andy



More information about the dev mailing list