From: Phil Yang <Phil.Yang@arm.com>
To: Olivier Matz <olivier.matz@6wind.com>
Cc: Stephen Hemminger <stephen@networkplumber.org>,
"david.marchand@redhat.com" <david.marchand@redhat.com>,
"dev@dpdk.org" <dev@dpdk.org>,
"drc@linux.vnet.ibm.com" <drc@linux.vnet.ibm.com>,
Honnappa Nagarahalli <Honnappa.Nagarahalli@arm.com>,
Ruifeng Wang <Ruifeng.Wang@arm.com>, nd <nd@arm.com>
Subject: Re: [dpdk-dev] [PATCH v2] mbuf: use C11 atomics for refcnt operations
Date: Thu, 9 Jul 2020 09:52:45 +0000 [thread overview]
Message-ID: <VE1PR08MB4640ED9DD63FB69B113701AEE9640@VE1PR08MB4640.eurprd08.prod.outlook.com> (raw)
In-Reply-To: <20200708114301.GN5869@platinum>
> -----Original Message-----
> From: Olivier Matz <olivier.matz@6wind.com>
> Sent: Wednesday, July 8, 2020 7:43 PM
> To: Phil Yang <Phil.Yang@arm.com>
> Cc: Stephen Hemminger <stephen@networkplumber.org>;
> david.marchand@redhat.com; dev@dpdk.org; drc@linux.vnet.ibm.com;
> Honnappa Nagarahalli <Honnappa.Nagarahalli@arm.com>; Ruifeng Wang
> <Ruifeng.Wang@arm.com>; nd <nd@arm.com>
> Subject: Re: [dpdk-dev] [PATCH v2] mbuf: use C11 atomics for refcnt
> operations
>
> On Wed, Jul 08, 2020 at 04:48:33AM +0000, Phil Yang wrote:
> > > -----Original Message-----
> > > From: Stephen Hemminger <stephen@networkplumber.org>
> > > Sent: Wednesday, July 8, 2020 1:13 AM
> > > To: Phil Yang <Phil.Yang@arm.com>
> > > Cc: david.marchand@redhat.com; dev@dpdk.org;
> drc@linux.vnet.ibm.com;
> > > Honnappa Nagarahalli <Honnappa.Nagarahalli@arm.com>;
> > > olivier.matz@6wind.com; Ruifeng Wang <Ruifeng.Wang@arm.com>; nd
> > > <nd@arm.com>
> > > Subject: Re: [dpdk-dev] [PATCH v2] mbuf: use C11 atomics for refcnt
> > > operations
> > >
> > > On Tue, 7 Jul 2020 18:10:33 +0800
> > > Phil Yang <phil.yang@arm.com> wrote:
> > >
> > > > + return (uint16_t)(__atomic_add_fetch((int16_t *)&shinfo-
> > > >refcnt_atomic,
> > > > +
> > >
> > > Why do you need so many casts here?
> > > The type of refcnt_atomic is now uint16 after your patch.
> >
> > In the existing code, the input parameter type for this API is signed integer.
> For example:
> > drivers/net/netvsc/hn_rxtx.c:531
> > lib/librte_mbuf/rte_mbuf.h:1194
> >
> > However, the output type of rte_mbuf_ext_refcnt related APIs is not
> uniform. We use these typecast to consistent with the current API definition.
>
> Would it make sense to cast the increment instead?
Yes. It is better.
Thanks.
>
> I mean:
>
> return __atomic_add_fetch(&m->refcnt, (uint16_t)value,
> __ATOMIC_ACQ_REL);
>
> instead of:
>
> return (uint16_t)(__atomic_add_fetch((int16_t *)&m->refcnt, value,
> __ATOMIC_ACQ_REL));
>
>
> The same could apply to __rte_pktmbuf_pinned_extbuf_decref() I think:
>
> > - if (likely(rte_atomic16_add_return
> > - (&shinfo->refcnt_atomic, -1)))
> > + if (likely(__atomic_add_fetch((int *)&shinfo->refcnt_atomic, -1,
> > + __ATOMIC_ACQ_REL)))
>
> By the way, why was the cast was to (int *) in this case? I think
> it can overwrite fields beside refcnt.
Fixed in the next version.
Thanks,
Phil
next prev parent reply other threads:[~2020-07-09 9:52 UTC|newest]
Thread overview: 40+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-06-11 10:26 [dpdk-dev] [PATCH] mbuf: use c11 " Phil Yang
2020-07-03 15:38 ` David Marchand
2020-07-06 8:03 ` Phil Yang
2020-07-07 10:10 ` [dpdk-dev] [PATCH v2] mbuf: use C11 " Phil Yang
2020-07-07 17:13 ` Stephen Hemminger
2020-07-08 4:48 ` Phil Yang
2020-07-08 11:43 ` Olivier Matz
2020-07-09 9:52 ` Phil Yang [this message]
2020-07-08 5:11 ` Phil Yang
2020-07-08 11:44 ` Olivier Matz
2020-07-09 10:00 ` Phil Yang
2020-07-09 10:10 ` [dpdk-dev] [PATCH v3] mbuf: use C11 atomic built-ins " Phil Yang
2020-07-09 11:03 ` Olivier Matz
2020-07-09 13:00 ` Phil Yang
2020-07-09 13:31 ` Honnappa Nagarahalli
2020-07-09 14:10 ` Phil Yang
2020-07-09 15:58 ` [dpdk-dev] [PATCH v4 1/2] " Phil Yang
2020-07-09 15:58 ` [dpdk-dev] [PATCH v4 2/2] doc: announce deprecation of refcnt atomic member Phil Yang
2020-07-10 2:55 ` Ruifeng Wang
2020-07-13 15:54 ` Phil Yang
2020-07-14 10:41 ` Ananyev, Konstantin
2020-07-15 12:29 ` [dpdk-dev] [PATCH v4 1/2] mbuf: use C11 atomic built-ins for refcnt operations David Marchand
2020-07-15 12:49 ` Aaron Conole
2020-07-15 16:29 ` Phil Yang
2020-07-16 4:16 ` Phil Yang
2020-07-16 11:30 ` David Marchand
2020-07-16 13:20 ` Dodji Seketeli
2020-07-16 19:11 ` David Marchand
2020-07-17 4:41 ` Phil Yang
2020-07-16 11:32 ` Olivier Matz
2020-07-17 4:36 ` [dpdk-dev] [PATCH v5 1/2] mbuf: use C11 atomic builtins " Phil Yang
2020-07-17 4:36 ` [dpdk-dev] [PATCH v5 2/2] doc: announce deprecation of refcnt atomic member Phil Yang
2020-07-17 11:45 ` Olivier Matz
2020-07-17 14:32 ` David Marchand
2020-07-17 14:35 ` David Marchand
2020-07-17 16:06 ` Ananyev, Konstantin
2020-07-17 16:20 ` Bruce Richardson
2020-07-21 8:35 ` David Marchand
2020-07-21 8:48 ` Ananyev, Konstantin
2020-07-21 8:37 ` [dpdk-dev] [PATCH v5 1/2] mbuf: use C11 atomic builtins for refcnt operations David Marchand
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=VE1PR08MB4640ED9DD63FB69B113701AEE9640@VE1PR08MB4640.eurprd08.prod.outlook.com \
--to=phil.yang@arm.com \
--cc=Honnappa.Nagarahalli@arm.com \
--cc=Ruifeng.Wang@arm.com \
--cc=david.marchand@redhat.com \
--cc=dev@dpdk.org \
--cc=drc@linux.vnet.ibm.com \
--cc=nd@arm.com \
--cc=olivier.matz@6wind.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).