From mboxrd@z Thu Jan 1 00:00:00 1970 From: Andy Green Subject: Re: [PATCH 1/2] ring: fix declaration after code Date: Mon, 28 May 2018 16:46:59 +0800 Message-ID: <206e8a27-9039-17ac-315f-fd8f52230b4c@warmcat.com> References: <152747443129.35192.15673273827095899997.stgit@localhost.localdomain> <152747454575.35192.11685010940587705005.stgit@localhost.localdomain> Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit To: Gavin Hu , "dev@dpdk.org" Return-path: Received: from mail.warmcat.com (mail.warmcat.com [163.172.24.82]) by dpdk.org (Postfix) with ESMTP id 33203B62 for ; Mon, 28 May 2018 10:47:17 +0200 (CEST) In-Reply-To: Content-Language: en-US List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" 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