From: Stephen Hemminger <stephen@networkplumber.org>
To: Ruifeng Wang <Ruifeng.Wang@arm.com>
Cc: "thomas@monjalon.net" <thomas@monjalon.net>,
Honnappa Nagarahalli <Honnappa.Nagarahalli@arm.com>,
"dev@dpdk.org" <dev@dpdk.org>,
"bruce.richardson@intel.com" <bruce.richardson@intel.com>,
"konstantin.ananyev@intel.com" <konstantin.ananyev@intel.com>,
"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 09:20:20 -0700 [thread overview]
Message-ID: <20210705092020.77b291b4@hermes.local> (raw)
In-Reply-To: <AM5PR0802MB24659E2D10FEB1827F19CA769E1C9@AM5PR0802MB2465.eurprd08.prod.outlook.com>
On Mon, 5 Jul 2021 08:33:21 +0000
Ruifeng Wang <Ruifeng.Wang@arm.com> wrote:
> >
> > > > One simple example: increment a counter atomically.
> > > > __atomic_fetch_add(&counter, 1, __ATOMIC_RELAXED); or
> > > > __atomic_add_fetch(&counter, 1, __ATOMIC_RELAXED);
> >
> > I really hate how atomics are "documented" in GCC doc.
> > For instance, it doesn't say what is returned (old or new value) in above
> > functions.
> >
> Returns are described as "the result of the operation" and "the value that had previously been in *ptr".
> It can be more concise.
Since English language parses left to right, the function name seem really obvious
to me. __atomic_fetch_add returns the result before the add, and __atomic_add_fetch returns
the result after the add. The one non-obvious question is which way is faster if the
result is not being used?
next prev parent reply other threads:[~2021-07-05 16:20 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
2021-07-05 7:30 ` Thomas Monjalon
2021-07-05 8:33 ` Ruifeng Wang
2021-07-05 16:20 ` Stephen Hemminger [this message]
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=20210705092020.77b291b4@hermes.local \
--to=stephen@networkplumber.org \
--cc=Honnappa.Nagarahalli@arm.com \
--cc=Ruifeng.Wang@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).