From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga01.intel.com (mga01.intel.com [192.55.52.88]) by dpdk.org (Postfix) with ESMTP id 945A07F8C for ; Wed, 10 Dec 2014 12:09:02 +0100 (CET) Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by fmsmga101.fm.intel.com with ESMTP; 10 Dec 2014 03:09:01 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="4.97,862,1389772800"; d="scan'208";a="427295926" Received: from irsmsx101.ger.corp.intel.com ([163.33.3.153]) by FMSMGA003.fm.intel.com with ESMTP; 10 Dec 2014 02:58:19 -0800 Received: from irsmsx105.ger.corp.intel.com ([169.254.7.144]) by IRSMSX101.ger.corp.intel.com ([169.254.1.126]) with mapi id 14.03.0195.001; Wed, 10 Dec 2014 11:09:00 +0000 From: "Ananyev, Konstantin" To: "Qiu, Michael" , "Richardson, Bruce" Thread-Topic: [dpdk-dev] [PATCH] Avoid possible memory cpoy when sort hugepages Thread-Index: AQHQFGhutuM0Xl1jBUa4i281i56gzZyIqSpg Date: Wed, 10 Dec 2014 11:08:58 +0000 Message-ID: <2601191342CEEE43887BDE71AB977258213BEA97@IRSMSX105.ger.corp.intel.com> References: <1418178341-4193-1-git-send-email-michael.qiu@intel.com> <20141210104110.GB10056@bricha3-MOBL3> <533710CFB86FA344BFBF2D6802E60286C9E768@SHSMSX101.ccr.corp.intel.com> In-Reply-To: <533710CFB86FA344BFBF2D6802E60286C9E768@SHSMSX101.ccr.corp.intel.com> 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] 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 11:09:03 -0000 > -----Original Message----- > From: dev [mailto:dev-bounces@dpdk.org] On Behalf Of Qiu, Michael > Sent: Wednesday, December 10, 2014 10:59 AM > To: Richardson, Bruce > Cc: dev@dpdk.org > Subject: Re: [dpdk-dev] [PATCH] Avoid possible memory cpoy when sort huge= pages >=20 > On 12/10/2014 6:41 PM, Richardson, Bruce wrote: > > On Wed, Dec 10, 2014 at 10:25:41AM +0800, Michael Qiu wrote: > >> When the first address is the compared address in the loop, > >> it will also do memory copy, which is meaningless, > >> worse more, when hugepg_tbl is mostly in order. This should > >> be a big deal in large hugepage memory systerm(like hunderd > >> or thousand GB). > > I actually doubt the time taken by this sorting is a significant part o= f the > > initialization time taken, even for hundreds of GBs of memory. Do you h= ave > > any measurements to confirm this? > > [However, that's not to say that we can't merge in this patch] >=20 > I've no hardware env of so huge memory, so I haven't do measurements on > this. >=20 > This is not a big improvement, but indeed it may do lots of useless > memory copy in initialize stat. >=20 > It could, at least could save time :) I wonder why we do need to write our own bubble sort procedure? Why we can't use standard qsort() here? Konstantin >=20 > Thanks, > Michael > > > > > >> Meanwhile smallest_idx never be a value of -1,so remove this check. > >> > >> This patch also includes some coding style fix. > >> > >> Signed-off-by: Michael Qiu > >> --- > >> lib/librte_eal/linuxapp/eal/eal_memory.c | 13 +++++-------- > >> 1 file changed, 5 insertions(+), 8 deletions(-) > >> > >> diff --git a/lib/librte_eal/linuxapp/eal/eal_memory.c b/lib/librte_eal= /linuxapp/eal/eal_memory.c > >> index e6cb919..700aba2 100644 > >> --- a/lib/librte_eal/linuxapp/eal/eal_memory.c > >> +++ b/lib/librte_eal/linuxapp/eal/eal_memory.c > >> @@ -678,14 +678,13 @@ error: > >> static int > >> sort_by_physaddr(struct hugepage_file *hugepg_tbl, struct hugepage_in= fo *hpi) > >> { > >> - unsigned i, j; > >> - int compare_idx; > >> + unsigned i, j, compare_idx; > >> uint64_t compare_addr; > >> struct hugepage_file tmp; > >> > >> for (i =3D 0; i < hpi->num_pages[0]; i++) { > >> compare_addr =3D 0; > >> - compare_idx =3D -1; > >> + compare_idx =3D i; > >> > >> /* > >> * browse all entries starting at 'i', and find the > >> @@ -704,11 +703,9 @@ sort_by_physaddr(struct hugepage_file *hugepg_tbl= , struct hugepage_info *hpi) > >> } > >> } > >> > >> - /* should not happen */ > >> - if (compare_idx =3D=3D -1) { > >> - RTE_LOG(ERR, EAL, "%s(): error in physaddr sorting\n", __func__); > >> - return -1; > >> - } > >> + /* avoid memory copy when the first entry is the compared */ > >> + if (compare_idx =3D=3D i) > >> + continue; > >> > >> /* swap the 2 entries in the table */ > >> memcpy(&tmp, &hugepg_tbl[compare_idx], > >> -- > >> 1.9.3 > >>