From: Intel Date: Wed, 19 Dec 2012 23:00:00 +0000 (+0100) Subject: hash: don't use memzone for allocations X-Git-Tag: spdx-start~11390 X-Git-Url: http://git.droids-corp.org/?a=commitdiff_plain;h=1651e2166be228125287c2e00d3ce792e9a68265;p=dpdk.git hash: don't use memzone for allocations Signed-off-by: Intel --- diff --git a/config/defconfig_i686-default-linuxapp-gcc b/config/defconfig_i686-default-linuxapp-gcc index 9c534ed55e..cfe8aa0469 100644 --- a/config/defconfig_i686-default-linuxapp-gcc +++ b/config/defconfig_i686-default-linuxapp-gcc @@ -199,7 +199,6 @@ CONFIG_RTE_LIBRTE_CMDLINE_DEBUG=n # CONFIG_RTE_LIBRTE_HASH=y CONFIG_RTE_LIBRTE_HASH_DEBUG=n -CONFIG_RTE_LIBRTE_HASH_USE_MEMZONE=n # # Compile librte_lpm diff --git a/config/defconfig_i686-default-linuxapp-icc b/config/defconfig_i686-default-linuxapp-icc index efac8f678b..9057084331 100644 --- a/config/defconfig_i686-default-linuxapp-icc +++ b/config/defconfig_i686-default-linuxapp-icc @@ -199,7 +199,6 @@ CONFIG_RTE_LIBRTE_CMDLINE_DEBUG=n # CONFIG_RTE_LIBRTE_HASH=y CONFIG_RTE_LIBRTE_HASH_DEBUG=n -CONFIG_RTE_LIBRTE_HASH_USE_MEMZONE=n # # Compile librte_lpm diff --git a/config/defconfig_x86_64-default-linuxapp-gcc b/config/defconfig_x86_64-default-linuxapp-gcc index 8989a9dfbb..0df200824f 100644 --- a/config/defconfig_x86_64-default-linuxapp-gcc +++ b/config/defconfig_x86_64-default-linuxapp-gcc @@ -199,7 +199,6 @@ CONFIG_RTE_LIBRTE_CMDLINE_DEBUG=n # CONFIG_RTE_LIBRTE_HASH=y CONFIG_RTE_LIBRTE_HASH_DEBUG=n -CONFIG_RTE_LIBRTE_HASH_USE_MEMZONE=n # # Compile librte_lpm diff --git a/config/defconfig_x86_64-default-linuxapp-icc b/config/defconfig_x86_64-default-linuxapp-icc index 8dc32aa234..86e656deba 100644 --- a/config/defconfig_x86_64-default-linuxapp-icc +++ b/config/defconfig_x86_64-default-linuxapp-icc @@ -199,7 +199,6 @@ CONFIG_RTE_LIBRTE_CMDLINE_DEBUG=n # CONFIG_RTE_LIBRTE_HASH=y CONFIG_RTE_LIBRTE_HASH_DEBUG=n -CONFIG_RTE_LIBRTE_HASH_USE_MEMZONE=n # # Compile librte_lpm diff --git a/lib/librte_hash/rte_fbk_hash.c b/lib/librte_hash/rte_fbk_hash.c index 915831e984..fa397f5243 100644 --- a/lib/librte_hash/rte_fbk_hash.c +++ b/lib/librte_hash/rte_fbk_hash.c @@ -138,17 +138,9 @@ rte_fbk_hash_create(const struct rte_fbk_hash_params *params) return NULL; /* Allocate memory for table. */ -#if defined(RTE_LIBRTE_HASH_USE_MEMZONE) - const struct rte_memzone *mz; - mz = rte_memzone_reserve(hash_name, mem_size, params->socket_id, 0); - if (mz == NULL) - return NULL; - ht = (struct rte_fbk_hash_table *)mz->addr; -#else ht = (struct rte_fbk_hash_table *)rte_malloc(hash_name, mem_size, 0); if (ht == NULL) return NULL; -#endif memset(ht, 0, mem_size); /* Set up hash table context. */ @@ -187,12 +179,7 @@ rte_fbk_hash_free(struct rte_fbk_hash_table *ht) if (ht == NULL) return; - /* No way to deallocate memzones - but can de-allocate from malloc */ -#if !defined(RTE_LIBRTE_HASH_USE_MEMZONE) RTE_EAL_TAILQ_REMOVE(RTE_TAILQ_FBK_HASH, rte_fbk_hash_list, ht); rte_free(ht); -#endif - RTE_SET_USED(ht); - return; } diff --git a/lib/librte_hash/rte_hash.c b/lib/librte_hash/rte_hash.c index c8569710fe..13958a3a55 100644 --- a/lib/librte_hash/rte_hash.c +++ b/lib/librte_hash/rte_hash.c @@ -201,7 +201,7 @@ rte_hash_create(const struct rte_hash_parameters *params) CACHE_LINE_SIZE); key_tbl_size = align_size(num_buckets * key_size * params->bucket_entries, CACHE_LINE_SIZE); - + /* Total memory required for hash context */ mem_size = hash_tbl_size + sig_tbl_size + key_tbl_size; @@ -213,24 +213,12 @@ rte_hash_create(const struct rte_hash_parameters *params) if (h != NULL) return NULL; - /* Allocate as a memzone, or in normal memory space */ -#if defined(RTE_LIBRTE_HASH_USE_MEMZONE) - const struct rte_memzone *mz; - mz = rte_memzone_reserve(hash_name, mem_size, params->socket_id, 0); - if (mz == NULL) { - RTE_LOG(ERR, HASH, "memzone reservation failed\n"); - return NULL; - } - memset(mz->addr, 0, mem_size); - h = (struct rte_hash *)mz->addr; -#else h = (struct rte_hash *)rte_zmalloc(hash_name, mem_size, CACHE_LINE_SIZE); if (h == NULL) { RTE_LOG(ERR, HASH, "memory allocation failed\n"); return NULL; } -#endif /* Setup hash context */ rte_snprintf(h->name, sizeof(h->name), "%s", params->name); @@ -258,12 +246,8 @@ rte_hash_free(struct rte_hash *h) if (h == NULL) return; -#if !defined(RTE_LIBRTE_HASH_USE_MEMZONE) RTE_EAL_TAILQ_REMOVE(RTE_TAILQ_HASH, rte_hash_list, h); rte_free(h); -#endif - /* No way to deallocate memzones */ - return; } int32_t diff --git a/lib/librte_hash/rte_hash.h b/lib/librte_hash/rte_hash.h index cd630e79ea..ec7d442dd0 100644 --- a/lib/librte_hash/rte_hash.h +++ b/lib/librte_hash/rte_hash.h @@ -109,9 +109,7 @@ struct rte_hash { }; /** - * Create a new hash table. If RTE_LIBRTE_HASH_USE_MEMZONE is defined, then - * the hash table is allocated in a memzone on a specific NUMA socket ID, - * otherwise it is allocated in the heap. + * Create a new hash table. * * @param params * Parameters used to create and initialise the hash table. @@ -146,8 +144,7 @@ struct rte_hash * rte_hash_find_existing(const char *name); /** - * De-allocate all memory used by hash table. If RTE_LIBRTE_HASH_USE_MEMZONE - * is defined, then this has no effect. + * De-allocate all memory used by hash table. * @param h * Hash table to free */