DPDK patches and discussions
 help / color / mirror / Atom feed
From: Bruce Richardson <bruce.richardson@intel.com>
To: Stephen Hemminger <stephen@networkplumber.org>
Cc: dev@dpdk.org, ibetts <ian.betts@intel.com>
Subject: Re: [dpdk-dev] [PATCH v5 2/4] examples: add lthread subsystem for performance-thread
Date: Thu, 3 Dec 2015 16:46:27 +0000	[thread overview]
Message-ID: <20151203164626.GA13272@bricha3-MOBL3> (raw)
In-Reply-To: <20151203083139.32b82334@xeon-e3>

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;
> }

Rather than using assembly, I believe the gcc builtin __sync_lock_test_and_set
is actually an xchg op, so can be used here.

/Bruce

  reply	other threads:[~2015-12-03 16:46 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 [this message]
2015-12-03 17:15       ` Betts, Ian
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=20151203164626.GA13272@bricha3-MOBL3 \
    --to=bruce.richardson@intel.com \
    --cc=dev@dpdk.org \
    --cc=ian.betts@intel.com \
    --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).