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

Gavin Hu Gavin.Hu at arm.com
Mon May 28 10:54:15 CEST 2018



-----Original Message-----
From: Andy Green <andy at warmcat.com>
Sent: Monday, May 28, 2018 4:47 PM
To: Gavin Hu <Gavin.Hu at arm.com>; dev at dpdk.org
Subject: Re: [dpdk-dev] [PATCH 1/2] ring: fix declaration after code



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.
[Gavin Hu] I think it is ok.

-Andy

IMPORTANT NOTICE: The contents of this email and any attachments are confidential and may also be privileged. If you are not the intended recipient, please notify the sender immediately and do not disclose the contents to any other person, use it for any purpose, or store or copy the information in any medium. Thank you.


More information about the dev mailing list