From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga17.intel.com (mga17.intel.com [192.55.52.151]) by dpdk.org (Postfix) with ESMTP id 83F321B1B9 for ; Sat, 17 Feb 2018 14:59:21 +0100 (CET) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga004.jf.intel.com ([10.7.209.38]) by fmsmga107.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 17 Feb 2018 05:59:19 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.46,525,1511856000"; d="scan'208";a="176119442" Received: from aburakov-mobl.ger.corp.intel.com (HELO [10.252.1.250]) ([10.252.1.250]) by orsmga004.jf.intel.com with ESMTP; 17 Feb 2018 05:59:18 -0800 To: dev@dpdk.org References: From: "Burakov, Anatoly" Message-ID: Date: Sat, 17 Feb 2018 13:59:17 +0000 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:52.0) Gecko/20100101 Thunderbird/52.6.0 MIME-Version: 1.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] release/acquire memory barriers and ring 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: Sat, 17 Feb 2018 13:59:21 -0000 On 13-Feb-18 7:37 PM, Alex Kiselev wrote: > Hi. > > I've been wondering should I use a release/acquire memory barrier pair > in order to be sure that the other thread will see the fully/corrected > initialized object > passed to it via a dpdk ring or ring itself is a kind of barrier? > > Let's say I have a pseudo code: > > Thread1: > obj = alloc(); > ... > obj initialization > ... > > ??? fence(memory_order_release); ??? > rte_ring_sp_enqueue(ring, obj) > > > Thread2: > ??? fence(memory_order_acquire); ??? > rte_ring_sc_dequeue(ring, obj) > > Should I use fences in that code? > > Thanks. > > -- > Alex > Rings do that automatically, no additional fences needed. -- Thanks, Anatoly