From: Neil Horman <nhorman@tuxdriver.com>
To: Ravi Kerur <rkerur@gmail.com>
Cc: "dev@dpdk.org" <dev@dpdk.org>
Subject: Re: [dpdk-dev] [PATCH] Minor fixes in rte_common.h file.
Date: Tue, 16 Dec 2014 16:40:06 -0500 [thread overview]
Message-ID: <20141216213420.GE13806@hmsreliant.think-freely.org> (raw)
In-Reply-To: <CAFb4SLB+P9x_6MUgr+ZCJi0vgP4O0+atqp8gFVvGPXry86_siA@mail.gmail.com>
On Tue, Dec 16, 2014 at 08:46:51AM -0800, Ravi Kerur wrote:
> On Sat, Dec 13, 2014 at 2:39 AM, Neil Horman <nhorman@tuxdriver.com> wrote:
> >
> > On Fri, Dec 12, 2014 at 03:04:34PM -0800, r k wrote:
> > > Subject: [PATCH] Minor fixes in rte_common.h file.
> > >
> > > Fix rte_is_power_of_2 since 0 is not.
> > > Avoid branching instructions in RTE_MAX and RTE_MIN.
> > >
> > > Signed-off-by: Ravi Kerur <rkerur@gmail.com>
> > > ---
> > > lib/librte_eal/common/include/rte_common.h | 6 +++---
> > > lib/librte_pmd_e1000/igb_pf.c | 4 ++--
> > > lib/librte_pmd_ixgbe/ixgbe_pf.c | 4 ++--
> > > 3 files changed, 7 insertions(+), 7 deletions(-)
> > >
> > > diff --git a/lib/librte_eal/common/include/rte_common.h
> > > b/lib/librte_eal/common/include/rte_common.h
> > > index 921b91f..e163f35 100644
> > > --- a/lib/librte_eal/common/include/rte_common.h
> > > +++ b/lib/librte_eal/common/include/rte_common.h
> > > @@ -203,7 +203,7 @@ extern int RTE_BUILD_BUG_ON_detected_error; static
> > > inline int rte_is_power_of_2(uint32_t n) {
> > > - return ((n-1) & n) == 0;
> > > + return n && !(n & (n - 1));
> > > }
> > >
> > > /**
> > > @@ -259,7 +259,7 @@ rte_align64pow2(uint64_t v) #define RTE_MIN(a, b)
> > ({ \
> > > typeof (a) _a = (a); \
> > > typeof (b) _b = (b); \
> > > - _a < _b ? _a : _b; \
> > > + _b ^ ((_a ^ _b) & -(_a < _b)); \
> > Are you sure this is actually faster than the branch version? What about
> > using
> > a cmov instead?
> >
> >
> <rk> i am pretty sure modified code is faster than branching. I remember
> cmov had performance issues esp. on Pentuim-4 not sure how new intel cpu's
> perform.
>
Pretty sure isn't sure. Theres no point in code churn if theres no obvious
advantage. Some perf tests to deomonstrate the advantage here would be great.
> > })
> > >
> > > /**
> > > @@ -268,7 +268,7 @@ rte_align64pow2(uint64_t v) #define RTE_MAX(a, b)
> > ({ \
> > > typeof (a) _a = (a); \
> > > typeof (b) _b = (b); \
> > > - _a > _b ? _a : _b; \
> > > + _a ^ ((_a ^ _b) & -(_a < _b)); \
> > Same as above
> >
> > <rk> Same as above.
>
> > > })
> > >
> > > /*********** Other general functions / macros ********/ diff --git
> > > a/lib/librte_pmd_e1000/igb_pf.c b/lib/librte_pmd_e1000/igb_pf.c index
> > > bc3816a..546499c 100644
> > > --- a/lib/librte_pmd_e1000/igb_pf.c
> > > +++ b/lib/librte_pmd_e1000/igb_pf.c
> > > @@ -321,11 +321,11 @@ igb_vf_set_mac_addr(struct rte_eth_dev *dev,
> > uint32_t
> > > vf, uint32_t *msgbuf) static int igb_vf_set_multicast(struct
> > rte_eth_dev
> > > *dev, __rte_unused uint32_t vf, uint32_t *msgbuf) {
> > > - int i;
> > > + int16_t i;
> > > uint32_t vector_bit;
> > > uint32_t vector_reg;
> > > uint32_t mta_reg;
> > > - int entries = (msgbuf[0] & E1000_VT_MSGINFO_MASK) >>
> > > + int32_t entries = (msgbuf[0] & E1000_VT_MSGINFO_MASK) >>
> > > E1000_VT_MSGINFO_SHIFT;
> > NAK, this has nothing to do with the included changelog
> >
>
> <rk> It does, it causes compilation errors such as
>
> /root/dpdk-new/dpdk/lib/librte_pmd_e1000/igb_pf.c: In function
> \u2018igb_pf_mbx_process\u2019:
> /root/dpdk-new/dpdk/lib/librte_pmd_e1000/igb_pf.c:350:23: error: array
> subscript is above array bounds [-Werror=array-bounds]
> vfinfo->vf_mc_hashes[i] = hash_list[i];
> ^
> cc1: all warnings being treated as errors
>
> Also it is always better to use explicit int definitions esp. for 64bit
> systems.
>
This is your changelog:
=============================================================
Subject: [PATCH] Minor fixes in rte_common.h file.
Fix rte_is_power_of_2 since 0 is not.
Avoid branching instructions in RTE_MAX and RTE_MIN
=============================================================
Nowhere does your changelog indicate that you are fixing compliation errors.
That would in and of itself be far more serious that making micro optimizations.
If you want to fix build breaks, great, please do, but send a patch that clearly
indicates what the break is and how your fixing it. Don't just toss it in with
whatever other work you happen to be doing.
next prev parent reply other threads:[~2014-12-16 21:40 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-12-12 23:04 r k
2014-12-13 10:39 ` Neil Horman
2014-12-16 16:46 ` Ravi Kerur
2014-12-16 17:23 ` Ananyev, Konstantin
2014-12-16 20:13 ` Ravi Kerur
[not found] ` <2601191342CEEE43887BDE71AB977258213C1499@IRSMSX105.ger.corp.intel.com>
2014-12-17 1:05 ` Ananyev, Konstantin
2014-12-17 16:28 ` Ravi Kerur
2014-12-16 21:40 ` Neil Horman [this message]
2014-12-17 16:40 ` Ravi Kerur
2014-12-18 19:07 ` Neil Horman
2014-12-19 13:28 ` Ravi Kerur
-- strict thread matches above, loose matches on Subject: below --
2014-12-12 23:03 r k
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=20141216213420.GE13806@hmsreliant.think-freely.org \
--to=nhorman@tuxdriver.com \
--cc=dev@dpdk.org \
--cc=rkerur@gmail.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).