DPDK patches and discussions
 help / color / mirror / Atom feed
From: "Betts, Ian" <ian.betts@intel.com>
To: "Richardson, Bruce" <bruce.richardson@intel.com>,
	Stephen Hemminger <stephen@networkplumber.org>
Cc: "dev@dpdk.org" <dev@dpdk.org>
Subject: Re: [dpdk-dev] [PATCH v5 2/4] examples: add lthread subsystem for performance-thread
Date: Thu, 3 Dec 2015 17:15:53 +0000	[thread overview]
Message-ID: <877C1F8553E92F43898365570816082F35C0B9F9@IRSMSX103.ger.corp.intel.com> (raw)
In-Reply-To: <20151203164626.GA13272@bricha3-MOBL3>



On Thu, Dec 03, 2015 at 08:31:39AM -0800, Stephen Hemminger wrote:
> On Thu,  3 Dec 2015 09:28:23 +0000
> ibetts <ian.betts@intel.com> wrote:
> 
> > +/*
> > + * Atomically set a value and return the old value  */ static 
> > +inline uint64_t atomic64_xchg(uint64_t *ptr, uint64_t val) 
> > +__attribute__ ((always_inline)); static inline uint64_t 
> > +atomic64_xchg(uint64_t *ptr, uint64_t val)
> 
> You don't need a forward declaration for this.
> Instead do:
> 
> static inline uint64_t __attribute__((always_inline)) 
> atomic_xchg64(uint64_t *ptr, uint64_t val)
> 
> Really should be in rte_atomic.h as a primitive and the assembly macro 
> is missing change to ptr so Gcc might optmize it away.
> 
> Something like this mayb?
> 
> static inline uint64_t __attribute__ ((always_inline)); 
> rte_atomic64_xchg(uint64_t *ptr, uint64_t val) {
> 	asm volatile (
> 			MPLOCKED
> 			"xchgq %[ptr],%[val];"
> 			: [val] "=r" (val)
>                           [ptr] "=m" (*ptr)
> 			: [ptr] "m" (*ptr),
> 			  "a" (val)
> 			: "memory");
> 
> 	return val;
> }

>-----Original Message-----
>From: Richardson, Bruce 
>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 missed it.
I just tested it and its fine.
 


/Bruce

  reply	other threads:[~2015-12-03 17:15 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-12-03  9:28 [dpdk-dev] [PATCH v5 0/4] examples: add performance-thread ibetts
2015-12-03  9:28 ` [dpdk-dev] [PATCH v5 1/4] doc: add sample application guide for performance-thread ibetts
2015-12-03  9:28 ` [dpdk-dev] [PATCH v5 2/4] examples: add lthread subsystem " ibetts
2015-12-03 16:31   ` Stephen Hemminger
2015-12-03 16:46     ` Bruce Richardson
2015-12-03 17:15       ` Betts, Ian [this message]
2015-12-03  9:28 ` [dpdk-dev] [PATCH v5 3/4] examples: add l3fwd-thread example in performance-thread ibetts
2015-12-03 16:32   ` Stephen Hemminger
2015-12-03 17:18     ` Betts, Ian
2015-12-03  9:28 ` [dpdk-dev] [PATCH v5 4/4] examples: add pthread_shim example to performance thread ibetts
2015-12-03  9:48 ` [dpdk-dev] [PATCH v5 0/4] examples: add performance-thread Kulasek, TomaszX

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=877C1F8553E92F43898365570816082F35C0B9F9@IRSMSX103.ger.corp.intel.com \
    --to=ian.betts@intel.com \
    --cc=bruce.richardson@intel.com \
    --cc=dev@dpdk.org \
    --cc=stephen@networkplumber.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).