[dpdk-dev] [PATCH v3 50/68] eal: replace memzone array with fbarray
Shreyansh Jain
shreyansh.jain at nxp.com
Thu Apr 5 16:23:08 CEST 2018
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 <anatoly.burakov at intel.com>
> ---
>
> 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
More information about the dev
mailing list