hash: don't use memzone for allocations
Signed-off-by: Intel
This commit is contained in:
parent
de7212b822
commit
1651e2166b
@ -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
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
*/
|
||||
|
Loading…
x
Reference in New Issue
Block a user