From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga09.intel.com (mga09.intel.com [134.134.136.24]) by dpdk.org (Postfix) with ESMTP id AB8016A8B for ; Wed, 10 Dec 2014 11:59:34 +0100 (CET) Received: from orsmga001.jf.intel.com ([10.7.209.18]) by orsmga102.jf.intel.com with ESMTP; 10 Dec 2014 02:58:11 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.07,552,1413270000"; d="scan'208";a="621512977" Received: from kmsmsx152.gar.corp.intel.com ([172.21.73.87]) by orsmga001.jf.intel.com with ESMTP; 10 Dec 2014 02:59:32 -0800 Received: from shsmsx104.ccr.corp.intel.com (10.239.4.70) by KMSMSX152.gar.corp.intel.com (172.21.73.87) with Microsoft SMTP Server (TLS) id 14.3.195.1; Wed, 10 Dec 2014 18:59:32 +0800 Received: from shsmsx101.ccr.corp.intel.com ([169.254.1.110]) by SHSMSX104.ccr.corp.intel.com ([169.254.5.182]) with mapi id 14.03.0195.001; Wed, 10 Dec 2014 18:59:23 +0800 From: "Qiu, Michael" To: "Richardson, Bruce" Thread-Topic: [dpdk-dev] [PATCH] Avoid possible memory cpoy when sort hugepages Thread-Index: AQHQFCCveQHAhi5G1EGzjn+KIF1x5w== Date: Wed, 10 Dec 2014 10:59:23 +0000 Message-ID: <533710CFB86FA344BFBF2D6802E60286C9E768@SHSMSX101.ccr.corp.intel.com> References: <1418178341-4193-1-git-send-email-michael.qiu@intel.com> <20141210104110.GB10056@bricha3-MOBL3> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [10.239.127.40] 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] Avoid possible memory cpoy when sort hugepages 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: Wed, 10 Dec 2014 10:59:35 -0000 On 12/10/2014 6:41 PM, Richardson, Bruce wrote:=0A= > On Wed, Dec 10, 2014 at 10:25:41AM +0800, Michael Qiu wrote:=0A= >> When the first address is the compared address in the loop,=0A= >> it will also do memory copy, which is meaningless,=0A= >> worse more, when hugepg_tbl is mostly in order. This should=0A= >> be a big deal in large hugepage memory systerm(like hunderd=0A= >> or thousand GB).=0A= > I actually doubt the time taken by this sorting is a significant part of = the=0A= > initialization time taken, even for hundreds of GBs of memory. Do you hav= e=0A= > any measurements to confirm this?=0A= > [However, that's not to say that we can't merge in this patch]=0A= =0A= I've no hardware env of so huge memory, so I haven't do measurements on=0A= this.=0A= =0A= This is not a big improvement, but indeed it may do lots of useless=0A= memory copy in initialize stat.=0A= =0A= It could, at least could save time :)=0A= =0A= Thanks,=0A= Michael=0A= >=0A= >=0A= >> Meanwhile smallest_idx never be a value of -1,so remove this check.=0A= >>=0A= >> This patch also includes some coding style fix.=0A= >>=0A= >> Signed-off-by: Michael Qiu =0A= >> ---=0A= >> lib/librte_eal/linuxapp/eal/eal_memory.c | 13 +++++--------=0A= >> 1 file changed, 5 insertions(+), 8 deletions(-)=0A= >>=0A= >> diff --git a/lib/librte_eal/linuxapp/eal/eal_memory.c b/lib/librte_eal/l= inuxapp/eal/eal_memory.c=0A= >> index e6cb919..700aba2 100644=0A= >> --- a/lib/librte_eal/linuxapp/eal/eal_memory.c=0A= >> +++ b/lib/librte_eal/linuxapp/eal/eal_memory.c=0A= >> @@ -678,14 +678,13 @@ error:=0A= >> static int=0A= >> sort_by_physaddr(struct hugepage_file *hugepg_tbl, struct hugepage_info= *hpi)=0A= >> {=0A= >> - unsigned i, j;=0A= >> - int compare_idx;=0A= >> + unsigned i, j, compare_idx;=0A= >> uint64_t compare_addr;=0A= >> struct hugepage_file tmp;=0A= >> =0A= >> for (i =3D 0; i < hpi->num_pages[0]; i++) {=0A= >> compare_addr =3D 0;=0A= >> - compare_idx =3D -1;=0A= >> + compare_idx =3D i;=0A= >> =0A= >> /*=0A= >> * browse all entries starting at 'i', and find the=0A= >> @@ -704,11 +703,9 @@ sort_by_physaddr(struct hugepage_file *hugepg_tbl, = struct hugepage_info *hpi)=0A= >> }=0A= >> }=0A= >> =0A= >> - /* should not happen */=0A= >> - if (compare_idx =3D=3D -1) {=0A= >> - RTE_LOG(ERR, EAL, "%s(): error in physaddr sorting\n", __func__);=0A= >> - return -1;=0A= >> - }=0A= >> + /* avoid memory copy when the first entry is the compared */=0A= >> + if (compare_idx =3D=3D i)=0A= >> + continue;=0A= >> =0A= >> /* swap the 2 entries in the table */=0A= >> memcpy(&tmp, &hugepg_tbl[compare_idx],=0A= >> -- =0A= >> 1.9.3=0A= >>=0A= =0A=