From mboxrd@z Thu Jan 1 00:00:00 1970 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) To: Gavin Hu , "dev@dpdk.org" References: <152747443129.35192.15673273827095899997.stgit@localhost.localdomain> <152747454575.35192.11685010940587705005.stgit@localhost.localdomain> From: Andy Green Message-ID: <206e8a27-9039-17ac-315f-fd8f52230b4c@warmcat.com> Date: Mon, 28 May 2018 16:46:59 +0800 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.7.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit Subject: Re: [dpdk-dev] [PATCH 1/2] ring: fix declaration after code X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 28 May 2018 08:47:18 -0000 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