From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga11.intel.com (mga11.intel.com [192.55.52.93]) by dpdk.org (Postfix) with ESMTP id BC0B88043 for ; Tue, 16 Dec 2014 18:24:12 +0100 (CET) Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by fmsmga102.fm.intel.com with ESMTP; 16 Dec 2014 09:23:13 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="4.97,862,1389772800"; d="scan'208";a="429731806" Received: from irsmsx110.ger.corp.intel.com ([163.33.3.25]) by FMSMGA003.fm.intel.com with ESMTP; 16 Dec 2014 09:12:07 -0800 Received: from irsmsx105.ger.corp.intel.com ([169.254.7.144]) by IRSMSX110.ger.corp.intel.com ([169.254.15.55]) with mapi id 14.03.0195.001; Tue, 16 Dec 2014 17:23:11 +0000 From: "Ananyev, Konstantin" To: Ravi Kerur , Neil Horman Thread-Topic: [dpdk-dev] [PATCH] Minor fixes in rte_common.h file. Thread-Index: AQHQFmApWiU3vD4qnEqmyF8/gKxH9pyNVVuAgAUdrICAAAhSMA== Date: Tue, 16 Dec 2014 17:23:10 +0000 Message-ID: <2601191342CEEE43887BDE71AB977258213C1316@IRSMSX105.ger.corp.intel.com> References: <20141213103921.GA1162@localhost.localdomain> In-Reply-To: Accept-Language: en-IE, en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [163.33.239.182] Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Cc: "dev@dpdk.org" Subject: Re: [dpdk-dev] [PATCH] Minor fixes in rte_common.h file. X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches and discussions about DPDK List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 16 Dec 2014 17:24:13 -0000 > -----Original Message----- > From: dev [mailto:dev-bounces@dpdk.org] On Behalf Of Ravi Kerur > Sent: Tuesday, December 16, 2014 4:47 PM > To: Neil Horman > Cc: dev@dpdk.org > Subject: Re: [dpdk-dev] [PATCH] Minor fixes in rte_common.h file. >=20 > On Sat, Dec 13, 2014 at 2:39 AM, Neil Horman wrot= e: > > > > 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 > > > --- > > > 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; stat= ic > > > inline int rte_is_power_of_2(uint32_t n) { > > > - return ((n-1) & n) =3D=3D 0; > > > + return n && !(n & (n - 1)); > > > } > > > > > > /** > > > @@ -259,7 +259,7 @@ rte_align64pow2(uint64_t v) #define RTE_MIN(a, b= ) > > ({ \ > > > typeof (a) _a =3D (a); \ > > > typeof (b) _b =3D (b); \ > > > - _a < _b ? _a : _b; \ > > > + _b ^ ((_a ^ _b) & -(_a < _b)); \ > > Are you sure this is actually faster than the branch version? What abo= ut > > using > > a cmov instead? > > > > > 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. I also think most modern compilers are smart enough to avoid any branching = here and will use cmov instead. And we are way ahead of Pentium 4 times these days. Konstantin >=20 > > }) > > > > > > /** > > > @@ -268,7 +268,7 @@ rte_align64pow2(uint64_t v) #define RTE_MAX(a, b= ) > > ({ \ > > > typeof (a) _a =3D (a); \ > > > typeof (b) _b =3D (b); \ > > > - _a > _b ? _a : _b; \ > > > + _a ^ ((_a ^ _b) & -(_a < _b)); \ > > Same as above > > > > Same as above. >=20 > > > }) > > > > > > /*********** 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 =3D (msgbuf[0] & E1000_VT_MSGINFO_MASK) >> > > > + int32_t entries =3D (msgbuf[0] & E1000_VT_MSGINFO_MASK) >> > > > E1000_VT_MSGINFO_SHIFT; > > NAK, this has nothing to do with the included changelog > > >=20 > It does, it causes compilation errors such as >=20 > /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=3Darray-bounds] > vfinfo->vf_mc_hashes[i] =3D hash_list[i]; > ^ > cc1: all warnings being treated as errors >=20 > Also it is always better to use explicit int definitions esp. for 64bit > systems. >=20 >=20 >=20 > > > > > uint16_t *hash_list =3D (uint16_t *)&msgbuf[1]; > > > struct e1000_hw *hw =3D > > > E1000_DEV_PRIVATE_TO_HW(dev->data->dev_private); > > > diff --git a/lib/librte_pmd_ixgbe/ixgbe_pf.c > > > b/lib/librte_pmd_ixgbe/ixgbe_pf.c index 51da1fd..426caf9 100644 > > > --- a/lib/librte_pmd_ixgbe/ixgbe_pf.c > > > +++ b/lib/librte_pmd_ixgbe/ixgbe_pf.c > > > @@ -390,7 +390,7 @@ ixgbe_vf_set_multicast(struct rte_eth_dev *dev, > > > __rte_unused uint32_t vf, uint32 > > > struct ixgbe_hw *hw =3D > > > IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private); > > > struct ixgbe_vf_info *vfinfo =3D > > > *(IXGBE_DEV_PRIVATE_TO_P_VFDATA(dev->data->dev_privat= e)); > > > - int nb_entries =3D (msgbuf[0] & IXGBE_VT_MSGINFO_MASK) >> > > > + int32_t nb_entries =3D (msgbuf[0] & IXGBE_VT_MSGINFO_MASK) >> > > > IXGBE_VT_MSGINFO_SHIFT; > > ditto > > > uint16_t *hash_list =3D (uint16_t *)&msgbuf[1]; > > > uint32_t mta_idx; > > > @@ -399,7 +399,7 @@ ixgbe_vf_set_multicast(struct rte_eth_dev *dev, > > > __rte_unused uint32_t vf, uint32 > > > const uint32_t IXGBE_MTA_BIT_SHIFT =3D 5; > > > const uint32_t IXGBE_MTA_BIT_MASK =3D (0x1 << IXGBE_MTA_BIT_S= HIFT) > > - > > > 1; > > > uint32_t reg_val; > > > - int i; > > > + int16_t i; > > ditto > > > > Same as above. >=20 > > > > > > /* only so many hash values supported */ > > > nb_entries =3D RTE_MIN(nb_entries, IXGBE_MAX_VF_MC_ENTRIES); > > > -- > > > 1.9.1 > > > > >