From: Pablo de Lara Date: Fri, 2 Oct 2015 16:07:13 +0000 (+0100) Subject: hash: free internal ring when freeing hash X-Git-Tag: spdx-start~8146 X-Git-Url: http://git.droids-corp.org/?a=commitdiff_plain;h=9fd0052ee6102618701d4bb2faf7bc8ed1b5c97d;p=dpdk.git hash: free internal ring when freeing hash Since freeing a ring is now possible, then when freeing a hash table, its internal ring can be freed as well. Therefore when a new table, with the same name as a previously freed table, is created, there is no need to look up the already allocated ring. Signed-off-by: Pablo de Lara Acked-by: Bruce Richardson --- diff --git a/lib/librte_hash/rte_cuckoo_hash.c b/lib/librte_hash/rte_cuckoo_hash.c index 70197638b9..409fc2e27c 100644 --- a/lib/librte_hash/rte_cuckoo_hash.c +++ b/lib/librte_hash/rte_cuckoo_hash.c @@ -180,7 +180,7 @@ rte_hash_create(const struct rte_hash_parameters *params) struct rte_hash_list *hash_list; struct rte_ring *r = NULL; char hash_name[RTE_HASH_NAMESIZE]; - void *ptr, *k = NULL; + void *k = NULL; void *buckets = NULL; char ring_name[RTE_RING_NAMESIZE]; unsigned i; @@ -288,13 +288,7 @@ rte_hash_create(const struct rte_hash_parameters *params) #endif snprintf(ring_name, sizeof(ring_name), "HT_%s", params->name); - r = rte_ring_lookup(ring_name); - if (r != NULL) { - /* clear the free ring */ - while (rte_ring_dequeue(r, &ptr) == 0) - rte_pause(); - } else - r = rte_ring_create(ring_name, rte_align32pow2(params->entries + 1), + r = rte_ring_create(ring_name, rte_align32pow2(params->entries + 1), params->socket_id, 0); if (r == NULL) { RTE_LOG(ERR, HASH, "memory allocation failed\n"); @@ -363,6 +357,7 @@ rte_hash_free(struct rte_hash *h) rte_rwlock_write_unlock(RTE_EAL_TAILQ_RWLOCK); + rte_ring_free(h->free_slots); rte_free(h->key_store); rte_free(h->buckets); rte_free(h);