From mboxrd@z Thu Jan 1 00:00:00 1970 From: Shreyansh Jain Subject: Re: [PATCH v3 50/68] eal: replace memzone array with fbarray Date: Thu, 5 Apr 2018 19:53:08 +0530 Message-ID: <2a275e55-6e18-1e8c-4d05-351c805d5b3f@nxp.com> References: <8a674bd144b81203642082e8fc79446a9ddb552e.1522797505.git.anatoly.burakov@intel.com> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Cc: Marcin Wojtas , Michal Krawczyk , Guy Tzalik , Evgeny Schemeilin , Bruce Richardson , keith.wiles@intel.com, jianfeng.tan@intel.com, andras.kovacs@ericsson.com, laszlo.vadkeri@ericsson.com, benjamin.walker@intel.com, thomas@monjalon.net, konstantin.ananyev@intel.com, kuralamudhan.ramakrishnan@intel.com, louise.m.daly@intel.com, nelio.laranjeiro@6wind.com, yskoh@mellanox.com, pepperjo@japf.ch, jerin.jacob@caviumnetworks.com, hemant.agrawal@nxp.com, olivier.matz@6wind.com, shreyansh.jain@nxp.com, gowrishankar.m@linux.vnet.ibm.com To: Anatoly Burakov , dev@dpdk.org Return-path: Received: from EUR01-DB5-obe.outbound.protection.outlook.com (mail-db5eur01on0040.outbound.protection.outlook.com [104.47.2.40]) by dpdk.org (Postfix) with ESMTP id 60BD91CBD2 for ; Thu, 5 Apr 2018 16:08:01 +0200 (CEST) In-Reply-To: <8a674bd144b81203642082e8fc79446a9ddb552e.1522797505.git.anatoly.burakov@intel.com> Content-Language: en-US List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" On Wednesday 04 April 2018 04:52 AM, Anatoly Burakov wrote: > It's there, so we might as well use it. Some operations will be > sped up by that. > > Since we have to allocate an fbarray for memzones, we have to do > it before we initialize memory subsystem, because that, in > secondary processes, will (later) allocate more fbarrays than the > primary process, which will result in inability to attach to > memzone fbarray if we do it after the fact. > > Signed-off-by: Anatoly Burakov > --- > > Notes: > v3: > - Moved earlier in patchset > - Fixed compiled issues > - Removed rte_panic() calls > [...] > diff --git a/lib/librte_eal/common/eal_common_memzone.c b/lib/librte_eal/common/eal_common_memzone.c > index 529b36f..aed9331 100644 > --- a/lib/librte_eal/common/eal_common_memzone.c > +++ b/lib/librte_eal/common/eal_common_memzone.c > @@ -28,42 +28,31 @@ > static inline const struct rte_memzone * > memzone_lookup_thread_unsafe(const char *name) > { > - const struct rte_mem_config *mcfg; > + struct rte_mem_config *mcfg; > + struct rte_fbarray *arr; > const struct rte_memzone *mz; > - unsigned i = 0; > + int i = 0; > > /* get pointer to global configuration */ > mcfg = rte_eal_get_configuration()->mem_config; > + arr = &mcfg->memzones; > > /* > * the algorithm is not optimal (linear), but there are few > * zones and this function should be called at init only > */ > - for (i = 0; i < RTE_MAX_MEMZONE; i++) { > - mz = &mcfg->memzone[i]; > - if (mz->addr != NULL && !strncmp(name, mz->name, RTE_MEMZONE_NAMESIZE)) > - return &mcfg->memzone[i]; > + i = rte_fbarray_find_next_used(arr, 0); > + while (i >= 0) { > + mz = rte_fbarray_get(arr, i++); ^^^^^^^^ As discussed offline, this needs to be changed. Double increment of 'i' leading to skips over lookup. > + if (mz->addr != NULL && > + !strncmp(name, mz->name, RTE_MEMZONE_NAMESIZE)) > + return mz; > + i = rte_fbarray_find_next_used(arr, i + 1); > } > > return NULL; > } > [..] - Shreyansh