From mboxrd@z Thu Jan 1 00:00:00 1970 From: Jerin Jacob Subject: Re: [PATCH v2 3/5] test: add distributor_perf autotest Date: Wed, 4 Jan 2017 18:39:54 +0530 Message-ID: <20170104130952.GC19798@localhost.localdomain> References: <1480567821-70846-2-git-send-email-david.hunt@intel.com> <1482381428-148094-1-git-send-email-david.hunt@intel.com> <1482381428-148094-4-git-send-email-david.hunt@intel.com> <20161222121943.GA8778@localhost.localdomain> <088a8953-9c8f-0665-7a53-505cd1c389bc@intel.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Cc: , To: "Hunt, David" Return-path: Received: from NAM02-BL2-obe.outbound.protection.outlook.com (mail-bl2nam02on0069.outbound.protection.outlook.com [104.47.38.69]) by dpdk.org (Postfix) with ESMTP id 25B041094 for ; Wed, 4 Jan 2017 14:10:16 +0100 (CET) Content-Disposition: inline In-Reply-To: <088a8953-9c8f-0665-7a53-505cd1c389bc@intel.com> 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 Mon, Jan 02, 2017 at 04:24:01PM +0000, Hunt, David wrote: > > > On 22/12/2016 12:19 PM, Jerin Jacob wrote: > > On Thu, Dec 22, 2016 at 04:37:06AM +0000, David Hunt wrote: > > > + struct rte_distributor_burst *d = arg; > > > + unsigned int count = 0; > > > + unsigned int num = 0; > > > + unsigned int id = __sync_fetch_and_add(&worker_idx, 1); > > Use rte_atomic equivalent > > Jerin, > I'm looking for an equivalent, but I can't seem to find one. Here I'm > assigning 'id' with the incremented value of worker_idx in one statement. > However, rte_atomic32_add just increments the variable and returns void, so > I'd have to use two statements, losing the atomicity. > > static inline void > rte_atomic32_add(rte_atomic32_t *v, int32_t inc) It would have been better rte_atomic32_add returns the old value. > > There's a second reason why I can't use the rte_atomics, and that's because > worker_idx is a volatile. may be you could change worker_idx as rte_atomic32_t > > Maybe we could add new atomic functions in the future to address this? Yes. I guess, the fixing the return value of rte_atomic*_[add/sub] may be enough > > Thanks, > Dave.