From: Bruce Richardson <bruce.richardson@intel.com>
To: "Mauricio Vásquez" <mauricio.vasquezbernal@studenti.polito.it>
Cc: Thomas Monjalon <thomas.monjalon@6wind.com>,
dev@dpdk.org, Olivier Matz <olivier.matz@6wind.com>,
Lazaros Koromilas <l@nofutznetworks.com>
Subject: Re: [dpdk-dev] [PATCH v2] ring: check for zero objects mc dequeue / mp enqueue
Date: Fri, 18 Mar 2016 14:16:32 +0000 [thread overview]
Message-ID: <20160318141632.GC12932@bricha3-MOBL3> (raw)
In-Reply-To: <CAPwdgqj0XcC2H=BvpPXApF7g6AH9JsNpsNV+3tcTatsC39XPNw@mail.gmail.com>
On Fri, Mar 18, 2016 at 01:47:29PM +0100, Mauricio Vásquez wrote:
> Hi,
>
>
> On Fri, Mar 18, 2016 at 11:35 AM, Thomas Monjalon <thomas.monjalon@6wind.com
> > wrote:
>
> > 2016-03-18 11:27, Olivier Matz:
> > > On 03/18/2016 11:18 AM, Bruce Richardson wrote:
> > > >>> + /* Avoid the unnecessary cmpset operation below, which is
> > also
> > > >>> + * potentially harmful when n equals 0. */
> > > >>> + if (n == 0)
> > > >>>
> > > >>
> > > >> What about using unlikely here?
> > > >>
> > > >
> > > > Unless there is a measurable performance increase by adding in
> > likely/unlikely
> > > > I'd suggest avoiding it's use. In general, likely/unlikely should only
> > be used
> > > > for things like catestrophic errors because the penalty for taking the
> > unlikely
> > > > leg of the code can be quite severe. For normal stuff, where the code
> > nearly
> > > > always goes one way in the branch but occasionally goes the other, the
> > hardware
> > > > branch predictors generally do a good enough job.
> > >
> > > Do you mean using likely/unlikely could be worst than not using it
> > > in this case?
> > >
> > > To me, using unlikely here is not a bad idea: it shows to the compiler
> > > and to the reader of the code that is case is not the usual case.
> >
> > It would be nice to have a guideline section about likely/unlikely in
> > doc/guides/contributing/design.rst
> >
> > Bruce gave a talk at Dublin about this kind of things.
> > I'm sure he could contribute more design guidelines ;)
> >
>
> There is a small explanation in the section "Branch Prediction" of
> doc/guides/contributing/coding_style.rst, but I do not know if that is
> enough to understand when to use them.
>
> I've made a fast check and there are many PMDs that use them to check if
> number of packets is zero in the transmission function.
Yeah, and I wonder how many of those are actually necessary too :-)
It's not a big deal either way, I just think the patch is fine as-is without
the extra macros.
/Bruce
next prev parent reply other threads:[~2016-03-18 14:16 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-03-17 15:49 Lazaros Koromilas
2016-03-17 16:09 ` Mauricio Vásquez
2016-03-18 10:18 ` Bruce Richardson
2016-03-18 10:27 ` Olivier Matz
2016-03-18 10:35 ` Bruce Richardson
2016-03-18 10:35 ` Thomas Monjalon
2016-03-18 12:47 ` Mauricio Vásquez
2016-03-18 14:16 ` Bruce Richardson [this message]
2016-03-21 17:47 ` Xie, Huawei
2016-03-22 10:13 ` Bruce Richardson
2016-03-22 14:38 ` Xie, Huawei
2016-03-21 12:23 ` Olivier Matz
2016-03-22 16:49 ` Thomas Monjalon
2016-03-25 11:15 ` Olivier Matz
2016-03-28 15:48 ` Lazaros Koromilas
2016-03-29 8:54 ` Bruce Richardson
2016-03-29 15:29 ` Olivier MATZ
2016-03-29 16:04 ` Bruce Richardson
2016-03-29 17:35 ` Lazaros Koromilas
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=20160318141632.GC12932@bricha3-MOBL3 \
--to=bruce.richardson@intel.com \
--cc=dev@dpdk.org \
--cc=l@nofutznetworks.com \
--cc=mauricio.vasquezbernal@studenti.polito.it \
--cc=olivier.matz@6wind.com \
--cc=thomas.monjalon@6wind.com \
/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).