From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-yh0-f46.google.com (mail-yh0-f46.google.com [209.85.213.46]) by dpdk.org (Postfix) with ESMTP id 49D8D18F for ; Mon, 15 Dec 2014 14:17:05 +0100 (CET) Received: by mail-yh0-f46.google.com with SMTP id t59so5081630yho.5 for ; Mon, 15 Dec 2014 05:17:04 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:in-reply-to:references:date :message-id:subject:from:to:cc:content-type; bh=LVCD+4yOqxm0yiBMm8dn/YQbtoTK54K9i6WBMx/ZLjY=; b=gPb2bnpdDEKvU2VU2SrIRJShE6CmGbmWsV2fjiLvHbdB+ltFr+aN9Tkcy2yCbDBUVE 5tknajftB0VW3ipK8F76jTjbwxVdgzCwLMdCzooUda6cjoNh0URjDB/OVgzavslhsb9x QQdnusfC6s3Qo1LcdYiTnUJTs77niLTkpHaF8beBmP15lDEO9XXS2u/uTXxBY5yeuLAY tm4KSlXSJVNn5RDhHAKeBn4eYqMSM0DpU51BJ+RmTRzk1ux8afTSEv3LBkY4qgvMywnq SIPLQiHMRJSsZsok5EEZN2JSKWUZ2Pb4XeTuog5eWH+z1E0RgZawTZJEWRyRf6Ces5/P /ePg== X-Gm-Message-State: ALoCoQnTxANS1lD5/GVi51dZRPzWtcduzIe3TeFC0KiJpYw9PABWjGv3QhoVSyVjCFWZ27aWcwbm MIME-Version: 1.0 X-Received: by 10.170.211.67 with SMTP id c64mr7763855ykf.110.1418649424549; Mon, 15 Dec 2014 05:17:04 -0800 (PST) Received: by 10.170.54.78 with HTTP; Mon, 15 Dec 2014 05:17:04 -0800 (PST) In-Reply-To: References: Date: Mon, 15 Dec 2014 07:17:04 -0600 Message-ID: From: Jay Rolette To: "Wodkowski, PawelX" Content-Type: text/plain; charset=UTF-8 X-Content-Filtered-By: Mailman/MimeDel 2.1.15 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: Mon, 15 Dec 2014 13:17:05 -0000 Because it doesn't work correctly :-) On Mon, Dec 15, 2014 at 3:05 AM, Wodkowski, PawelX < pawelx.wodkowski@intel.com> wrote: > > > -----Original Message----- > > From: dev [mailto:dev-bounces@dpdk.org] On Behalf Of Jay Rolette > > Sent: Thursday, December 11, 2014 5:06 PM > > To: Dev > > Subject: [dpdk-dev] [PATCH] replaced O(n^2) sort in sort_by_physaddr() > with > > qsort() from standard library > > > > Signed-off-by: Jay Rolette > > --- > > lib/librte_eal/linuxapp/eal/eal_memory.c | 59 > > +++++++++++--------------------- > > 1 file changed, 20 insertions(+), 39 deletions(-) > > > > diff --git a/lib/librte_eal/linuxapp/eal/eal_memory.c > > b/lib/librte_eal/linuxapp/eal/eal_memory.c > > index bae2507..3656515 100644 > > --- a/lib/librte_eal/linuxapp/eal/eal_memory.c > > +++ b/lib/librte_eal/linuxapp/eal/eal_memory.c > > @@ -670,6 +670,25 @@ error: > > return -1; > > } > > > > +static int > > +cmp_physaddr(const void *a, const void *b) > > +{ > > +#ifndef RTE_ARCH_PPC_64 > > + const struct hugepage_file *p1 = (const struct hugepage_file *)a; > > + const struct hugepage_file *p2 = (const struct hugepage_file *)b; > > +#else > > + // PowerPC needs memory sorted in reverse order from x86 > > + const struct hugepage_file *p1 = (const struct hugepage_file *)b; > > + const struct hugepage_file *p2 = (const struct hugepage_file *)a; > > +#endif > > + if (p1->physaddr < p2->physaddr) > > + return -1; > > + else if (p1->physaddr > p2->physaddr) > > + return 1; > > + else > > + return 0; > > +} > > + > > Why not simply > > return (int)(p1->physaddr - p2->physaddr); > >