DPDK patches and discussions
 help / color / mirror / Atom feed
From: Ruifeng Wang <Ruifeng.Wang@arm.com>
To: "thomas@monjalon.net" <thomas@monjalon.net>,
	Honnappa Nagarahalli <Honnappa.Nagarahalli@arm.com>
Cc: "dev@dpdk.org" <dev@dpdk.org>,
	"bruce.richardson@intel.com" <bruce.richardson@intel.com>,
	"konstantin.ananyev@intel.com" <konstantin.ananyev@intel.com>,
	"dev@dpdk.org" <dev@dpdk.org>,
	"david.marchand@redhat.com" <david.marchand@redhat.com>,
	David Christensen <drc@linux.vnet.ibm.com>, nd <nd@arm.com>
Subject: Re: [dpdk-dev] atomic operations
Date: Mon, 5 Jul 2021 07:00:57 +0000	[thread overview]
Message-ID: <AM5PR0802MB2465B3EEEC742C8C1926B5059E1C9@AM5PR0802MB2465.eurprd08.prod.outlook.com> (raw)
In-Reply-To: <1806192.QIeOlYoxj9@thomas>

Removed invalid mail address.

> -----Original Message-----
> From: Thomas Monjalon <thomas@monjalon.net>
> Sent: Sunday, July 4, 2021 8:38 AM
> To: Honnappa Nagarahalli <Honnappa.Nagarahalli@arm.com>; Ruifeng Wang
> <Ruifeng.Wang@arm.com>; Phil Yang <Phil.Yang@arm.com>
> Cc: dev@dpdk.org; bruce.richardson@intel.com;
> konstantin.ananyev@intel.com; dev@dpdk.org;
> david.marchand@redhat.com; David Christensen <drc@linux.vnet.ibm.com>
> Subject: Re: [dpdk-dev] atomic operations
> 
> 03/07/2021 13:29, Thomas Monjalon:
> > In the deprecation notices of DPDK 21.05, we can still read this:
> > "
> > * rte_atomicNN_xxx: These APIs do not take memory order parameter.
> This does
> >   not allow for writing optimized code for all the CPU architectures
> supported
> >   in DPDK. DPDK will adopt C11 atomic operations semantics and provide
> wrappers
> >   using C11 atomic built-ins. These wrappers must be used for patches that
> >   need to be merged in 20.08 onwards. This change will not introduce any
> >   performance degradation.
> >
> > * rte_smp_*mb: These APIs provide full barrier functionality. However,
> many
> >   use cases do not require full barriers. To support such use cases, DPDK will
> >   adopt C11 barrier semantics and provide wrappers using C11 atomic built-
> ins.
> >   These wrappers must be used for patches that need to be merged in
> 20.08
> >   onwards. This change will not introduce any performance degradation.
> > "
> 
> The only new wrapper is rte_atomic_thread_fence(). What else?
Yes. The decision was to use GCC atomic built-ins directly. 
And rte_atomic_thread_fence() is an exception. It is a wrapper of __atomic_thread_fence(), because mem order __ATOMIC_SEQ_CST has an optimized implementation for x86.

> We are missing clear recommendations.
> 
> > Should we keep these notifications forever?
Targeting to obsolete APIs rte_atomicNN_xxx and rte_smp_*mb. 
Arm is working on replace occurrences with equivalent atomic built-ins.
There is still a lot work to do in drivers.

> >
> > It is very difficult to find which wrapper to use.
> 
> We should make function names explicit instead of "These".
> 
> > This is the guide we have:
> > https://doc.dpdk.org/guides/prog_guide/writing_efficient_code.html#loc
> > ks-and-atomic-operations
> > There are 2 blog posts:
> > https://www.dpdk.org/blog/2021/03/26/dpdk-adopts-the-c11-memory-
> model/
> > https://www.dpdk.org/blog/2021/06/09/reader-writer-concurrency/
> >
> > Basically it says we should use "__atomic builtins" but there is
> > example for simple situations like counters, memory barriers, etc.
> 
> Precision: I meant "there is *no* example".
> 
> > Please who could work on improving the documentation?
Agree that the documentation needs improve.
Add link to list of atomic built-ins and the above mentioned blog posts can be part of the improvement.

> 
> One simple example: increment a counter atomically.
> __atomic_fetch_add(&counter, 1, __ATOMIC_RELAXED); or
> __atomic_add_fetch(&counter, 1, __ATOMIC_RELAXED);
> 


  reply	other threads:[~2021-07-05  7:01 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-07-03 11:29 Thomas Monjalon
2021-07-03 17:30 ` Stephen Hemminger
2021-07-04  0:40   ` Thomas Monjalon
2021-07-04  0:37 ` Thomas Monjalon
2021-07-05  7:00   ` Ruifeng Wang [this message]
2021-07-05  7:30     ` Thomas Monjalon
2021-07-05  8:33       ` Ruifeng Wang
2021-07-05 16:20         ` Stephen Hemminger
2021-07-07 19:04 ` Honnappa Nagarahalli
2021-07-07 19:28   ` Thomas Monjalon

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=AM5PR0802MB2465B3EEEC742C8C1926B5059E1C9@AM5PR0802MB2465.eurprd08.prod.outlook.com \
    --to=ruifeng.wang@arm.com \
    --cc=Honnappa.Nagarahalli@arm.com \
    --cc=bruce.richardson@intel.com \
    --cc=david.marchand@redhat.com \
    --cc=dev@dpdk.org \
    --cc=drc@linux.vnet.ibm.com \
    --cc=konstantin.ananyev@intel.com \
    --cc=nd@arm.com \
    --cc=thomas@monjalon.net \
    /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).