From mboxrd@z Thu Jan 1 00:00:00 1970 From: "Eads, Gage" Subject: Re: [PATCH v3 6/8] stack: add C11 atomic implementation Date: Mon, 1 Apr 2019 00:06:35 +0000 Message-ID: <9184057F7FC11744A2107296B6B8EB1E5420DDF2@FMSMSX108.amr.corp.intel.com> References: <20190305164256.2367-1-gage.eads@intel.com> <20190306144559.391-1-gage.eads@intel.com> <20190306144559.391-7-gage.eads@intel.com> <9184057F7FC11744A2107296B6B8EB1E5420D940@FMSMSX108.amr.corp.intel.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Cc: "'olivier.matz@6wind.com'" , "'arybchenko@solarflare.com'" , "Richardson, Bruce" , "Ananyev, Konstantin" , "'Gavin Hu (Arm Technology China)'" , 'nd' , "'thomas@monjalon.net'" , 'nd' , 'Thomas Monjalon' To: 'Honnappa Nagarahalli' , "'dev@dpdk.org'" Return-path: Received: from mga12.intel.com (mga12.intel.com [192.55.52.136]) by dpdk.org (Postfix) with ESMTP id 57D9E11A4 for ; Mon, 1 Apr 2019 02:06:38 +0200 (CEST) In-Reply-To: <9184057F7FC11744A2107296B6B8EB1E5420D940@FMSMSX108.amr.corp.intel.com> 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" > -----Original Message----- > From: Eads, Gage > Sent: Friday, March 29, 2019 2:25 PM > To: Honnappa Nagarahalli ; > dev@dpdk.org > Cc: olivier.matz@6wind.com; arybchenko@solarflare.com; Richardson, Bruce > ; Ananyev, Konstantin > ; Gavin Hu (Arm Technology China) > ; nd ; thomas@monjalon.net; nd > ; Thomas Monjalon > Subject: RE: [PATCH v3 6/8] stack: add C11 atomic implementation >=20 > [snip] >=20 > > > +static __rte_always_inline void > > > +__rte_stack_lf_push(struct rte_stack_lf_list *list, > > > + struct rte_stack_lf_elem *first, > > > + struct rte_stack_lf_elem *last, > > > + unsigned int num) > > > +{ > > > +#ifndef RTE_ARCH_X86_64 > > > + RTE_SET_USED(first); > > > + RTE_SET_USED(last); > > > + RTE_SET_USED(list); > > > + RTE_SET_USED(num); > > > +#else > > > + struct rte_stack_lf_head old_head; > > > + int success; > > > + > > > + old_head =3D list->head; > > This can be a torn read (same as you have mentioned in > > __rte_stack_lf_pop). I suggest we use acquire thread fence here as > > well (please see the comments in __rte_stack_lf_pop). >=20 > Agreed. I'll add the acquire fence. >=20 On second thought, an acquire fence isn't necessary. The acquire fence in _= _rte_stack_lf_pop() ensures the list->head is ordered before the list eleme= nt reads. That isn't necessary here; we need to ensure that the last->next = write occurs (and is observed) before the list->head write, which the CAS's= RELEASE success memorder accomplishes. If a torn read occurs, the CAS will fail and will atomically re-load &old_h= ead.