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 C7E8618F for ; Wed, 17 Dec 2014 14:09:18 +0100 (CET) Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by fmsmga102.fm.intel.com with ESMTP; 17 Dec 2014 05:08:11 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.07,593,1413270000"; d="scan'208";a="638992489" Received: from pgsmsx102.gar.corp.intel.com ([10.221.44.80]) by fmsmga001.fm.intel.com with ESMTP; 17 Dec 2014 05:08:08 -0800 Received: from shsmsx152.ccr.corp.intel.com (10.239.6.52) by PGSMSX102.gar.corp.intel.com (10.221.44.80) with Microsoft SMTP Server (TLS) id 14.3.195.1; Wed, 17 Dec 2014 21:08:07 +0800 Received: from shsmsx101.ccr.corp.intel.com ([169.254.1.110]) by SHSMSX152.ccr.corp.intel.com ([169.254.6.5]) with mapi id 14.03.0195.001; Wed, 17 Dec 2014 21:08:06 +0800 From: "Qiu, Michael" To: Jay Rolette Thread-Topic: [dpdk-dev] [PATCH] replaced O(n^2) sort in sort_by_physaddr() with qsort() from standard library Thread-Index: AQHQFVyUzM73wKmoD0q2SblCkPUZhA== Date: Wed, 17 Dec 2014 13:08:05 +0000 Message-ID: <533710CFB86FA344BFBF2D6802E60286CA0963@SHSMSX101.ccr.corp.intel.com> References: <2601191342CEEE43887BDE71AB977258213C1357@IRSMSX105.ger.corp.intel.com> <2601191342CEEE43887BDE71AB977258213C16E7@IRSMSX105.ger.corp.intel.com> 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="Windows-1252" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Cc: Dev Subject: Re: [dpdk-dev] [PATCH] replaced O(n^2) sort in sort_by_physaddr() with qsort() from standard library 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, 17 Dec 2014 13:09:19 -0000 On 12/17/2014 7:01 PM, Ananyev, Konstantin wrote:=0A= > Hi Jay,=0A= >=0A= > From: Jay Rolette [mailto:rolette@infiniteio.com]=0A= > Sent: Tuesday, December 16, 2014 7:21 PM=0A= > To: Ananyev, Konstantin=0A= > Cc: Dev=0A= > Subject: Re: [dpdk-dev] [PATCH] replaced O(n^2) sort in sort_by_physaddr(= ) with qsort() from standard library=0A= >=0A= > Actually, I just relooked at the email I sent and it looks correct (prope= rly indented, etc.). Any suggestions for what might be going on?=0A= >=0A= > On Tue, Dec 16, 2014 at 1:18 PM, Jay Rolette > wrote:=0A= > Thanks Konstantin. Yes, I'll resend. Not sure why gmail is removing white= space when I sent in Plain Text mode.=0A= >=0A= > Sorry, don=92t know either.=0A= > Wonder, did you see this:=0A= > https://www.kernel.org/pub/software/scm/git/docs/git-format-patch.html=0A= > There is a section about different mailers, etc.=0A= > Konstantin=0A= >=0A= > Ultimately I'll need to figure out how to properly configure git to send = these directly instead of handling them more manually. The examples I saw a= ssumed you were using a gmail.com email rather than a cor= porate email hosted via google apps.=0A= Hi Jay,=0A= =0A= I was ever use git send-email with my gmail account, it works.=0A= =0A= So do you config your git send-email correctly?=0A= =0A= Thanks,=0A= Michael=0A= =0A= =0A= > Jay=0A= >=0A= > On Tue, Dec 16, 2014 at 12:39 PM, Ananyev, Konstantin > wrote:=0A= >=0A= > Hi Jay,=0A= >=0A= >> -----Original Message-----=0A= >> From: dev [mailto:dev-bounces@dpdk.org] On = Behalf Of Jay Rolette=0A= >> Sent: Thursday, December 11, 2014 4:06 PM=0A= >> To: Dev=0A= >> Subject: [dpdk-dev] [PATCH] replaced O(n^2) sort in sort_by_physaddr() w= ith qsort() from standard library=0A= >>=0A= >> Signed-off-by: Jay Rolette >=0A= > The patch itself looks good to me.=0A= > Though it seems something wrong with formatting - all lines start with of= fset 0.=0A= > Probably your mail client?=0A= > Konstantin=0A= >=0A= >=0A= >> ---=0A= >> lib/librte_eal/linuxapp/eal/eal_memory.c | 59=0A= >> +++++++++++---------------------=0A= >> 1 file changed, 20 insertions(+), 39 deletions(-)=0A= >>=0A= >> diff --git a/lib/librte_eal/linuxapp/eal/eal_memory.c=0A= >> b/lib/librte_eal/linuxapp/eal/eal_memory.c=0A= >> index bae2507..3656515 100644=0A= >> --- a/lib/librte_eal/linuxapp/eal/eal_memory.c=0A= >> +++ b/lib/librte_eal/linuxapp/eal/eal_memory.c=0A= >> @@ -670,6 +670,25 @@ error:=0A= >> return -1;=0A= >> }=0A= >>=0A= >> +static int=0A= >> +cmp_physaddr(const void *a, const void *b)=0A= >> +{=0A= >> +#ifndef RTE_ARCH_PPC_64=0A= >> + const struct hugepage_file *p1 =3D (const struct hugepage_file *)a;=0A= >> + const struct hugepage_file *p2 =3D (const struct hugepage_file *)b;=0A= >> +#else=0A= >> + // PowerPC needs memory sorted in reverse order from x86=0A= >> + const struct hugepage_file *p1 =3D (const struct hugepage_file *)b;=0A= >> + const struct hugepage_file *p2 =3D (const struct hugepage_file *)a;=0A= >> +#endif=0A= >> + if (p1->physaddr < p2->physaddr)=0A= >> + return -1;=0A= >> + else if (p1->physaddr > p2->physaddr)=0A= >> + return 1;=0A= >> + else=0A= >> + return 0;=0A= >> +}=0A= >> +=0A= >> /*=0A= >> * Sort the hugepg_tbl by physical address (lower addresses first on x8= 6,=0A= >> * higher address first on powerpc). We use a slow algorithm, but we wo= n't=0A= >> @@ -678,45 +697,7 @@ error:=0A= >> static int=0A= >> sort_by_physaddr(struct hugepage_file *hugepg_tbl, struct hugepage_info= =0A= >> *hpi)=0A= >> {=0A= >> - unsigned i, j;=0A= >> - int 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= >> -=0A= >> - /*=0A= >> - * browse all entries starting at 'i', and find the=0A= >> - * entry with the smallest addr=0A= >> - */=0A= >> - for (j=3Di; j< hpi->num_pages[0]; j++) {=0A= >> -=0A= >> - if (compare_addr =3D=3D 0 ||=0A= >> -#ifdef RTE_ARCH_PPC_64=0A= >> - hugepg_tbl[j].physaddr > compare_addr) {=0A= >> -#else=0A= >> - hugepg_tbl[j].physaddr < compare_addr) {=0A= >> -#endif=0A= >> - compare_addr =3D hugepg_tbl[j].physaddr;=0A= >> - compare_idx =3D j;=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= >> -=0A= >> - /* swap the 2 entries in the table */=0A= >> - memcpy(&tmp, &hugepg_tbl[compare_idx],=0A= >> - sizeof(struct hugepage_file));=0A= >> - memcpy(&hugepg_tbl[compare_idx], &hugepg_tbl[i],=0A= >> - sizeof(struct hugepage_file));=0A= >> - memcpy(&hugepg_tbl[i], &tmp, sizeof(struct hugepage_file));=0A= >> - }=0A= >> + qsort(hugepg_tbl, hpi->num_pages[0], sizeof(struct hugepage_file),=0A= >> cmp_physaddr);=0A= >> return 0;=0A= >> }=0A= >>=0A= >> --=0A= =0A=