From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga14.intel.com (mga14.intel.com [192.55.52.115]) by dpdk.org (Postfix) with ESMTP id BC10E37A6 for ; Thu, 3 Dec 2015 18:15:59 +0100 (CET) Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by fmsmga103.fm.intel.com with ESMTP; 03 Dec 2015 09:15:56 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.20,378,1444719600"; d="scan'208";a="865996727" Received: from irsmsx109.ger.corp.intel.com ([163.33.3.23]) by fmsmga002.fm.intel.com with ESMTP; 03 Dec 2015 09:15:54 -0800 Received: from irsmsx103.ger.corp.intel.com ([169.254.3.13]) by IRSMSX109.ger.corp.intel.com ([169.254.13.96]) with mapi id 14.03.0248.002; Thu, 3 Dec 2015 17:15:53 +0000 From: "Betts, Ian" To: "Richardson, Bruce" , Stephen Hemminger Thread-Topic: [dpdk-dev] [PATCH v5 2/4] examples: add lthread subsystem for performance-thread Thread-Index: AQHRLa0TfVwxYj1gIUauLHICJfZHv565dNGAgAAEIoCAAAc9MA== Date: Thu, 3 Dec 2015 17:15:53 +0000 Message-ID: <877C1F8553E92F43898365570816082F35C0B9F9@IRSMSX103.ger.corp.intel.com> References: <1449134905-28261-1-git-send-email-ian.betts@intel.com> <1449134905-28261-3-git-send-email-ian.betts@intel.com> <20151203083139.32b82334@xeon-e3> <20151203164626.GA13272@bricha3-MOBL3> In-Reply-To: <20151203164626.GA13272@bricha3-MOBL3> Accept-Language: en-IE, en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-inteldataclassification: CTP_IC x-titus-metadata-40: eyJDYXRlZ29yeUxhYmVscyI6IiIsIk1ldGFkYXRhIjp7Im5zIjoiaHR0cDpcL1wvd3d3LnRpdHVzLmNvbVwvbnNcL0ludGVsIiwiaWQiOiJhZWE5ODA4OS1jZmJlLTQxN2EtODJkOC1mY2ZhOGZmYjRiOWYiLCJwcm9wcyI6W3sibiI6IkludGVsRGF0YUNsYXNzaWZpY2F0aW9uIiwidmFscyI6W3sidmFsdWUiOiJDVFBfSUMifV19XX0sIlN1YmplY3RMYWJlbHMiOltdLCJUTUNWZXJzaW9uIjoiMTUuNC4xMC4xOSIsIlRydXN0ZWRMYWJlbEhhc2giOiJRQVQrUzRObEFsMVRTNEJsY1ZBWmk5a1RtVFhDM3NEdytPbGJlR0JrWVIwPSJ9 x-originating-ip: [163.33.239.181] Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Cc: "dev@dpdk.org" Subject: Re: [dpdk-dev] [PATCH v5 2/4] examples: add lthread subsystem for performance-thread X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches and discussions about DPDK List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 03 Dec 2015 17:16:00 -0000 On Thu, Dec 03, 2015 at 08:31:39AM -0800, Stephen Hemminger wrote: > On Thu, 3 Dec 2015 09:28:23 +0000 > ibetts wrote: >=20 > > +/* > > + * Atomically set a value and return the old value */ static=20 > > +inline uint64_t atomic64_xchg(uint64_t *ptr, uint64_t val)=20 > > +__attribute__ ((always_inline)); static inline uint64_t=20 > > +atomic64_xchg(uint64_t *ptr, uint64_t val) >=20 > You don't need a forward declaration for this. > Instead do: >=20 > static inline uint64_t __attribute__((always_inline))=20 > atomic_xchg64(uint64_t *ptr, uint64_t val) >=20 > Really should be in rte_atomic.h as a primitive and the assembly macro=20 > is missing change to ptr so Gcc might optmize it away. >=20 > Something like this mayb? >=20 > static inline uint64_t __attribute__ ((always_inline));=20 > rte_atomic64_xchg(uint64_t *ptr, uint64_t val) { > asm volatile ( > MPLOCKED > "xchgq %[ptr],%[val];" > : [val] "=3Dr" (val) > [ptr] "=3Dm" (*ptr) > : [ptr] "m" (*ptr), > "a" (val) > : "memory"); >=20 > return val; > } >-----Original Message----- >From: Richardson, Bruce=20 >Sent: Thursday, December 3, 2015 4:46 PM >To: Stephen Hemminger >Cc: Betts, Ian; dev@dpdk.org >Subject: Re: [dpdk-dev] [PATCH v5 2/4] examples: add lthread subsystem for= performance-thread >Rather than using assembly, I believe the gcc builtin __sync_lock_test_and= _set is actually an xchg op, so can be used here. Thanks for the suggestion Bruce, I had looked for a builin I must have miss= ed it. I just tested it and its fine. =20 /Bruce