[dpdk-dev] [PATCH 14/25] hash: use new tailq locking API

Anatoly Burakov anatoly.burakov at intel.com
Wed May 29 18:31:00 CEST 2019


Replace usages of direct access to shared memory config with
calls to the new API.

Signed-off-by: Anatoly Burakov <anatoly.burakov at intel.com>
---
 lib/librte_hash/rte_cuckoo_hash.c | 16 ++++++++--------
 lib/librte_hash/rte_fbk_hash.c    | 14 +++++++-------
 lib/librte_kni/rte_kni.c          | 16 ++++++++--------
 3 files changed, 23 insertions(+), 23 deletions(-)

diff --git a/lib/librte_hash/rte_cuckoo_hash.c b/lib/librte_hash/rte_cuckoo_hash.c
index 2dc423fba..ffe649411 100644
--- a/lib/librte_hash/rte_cuckoo_hash.c
+++ b/lib/librte_hash/rte_cuckoo_hash.c
@@ -52,13 +52,13 @@ rte_hash_find_existing(const char *name)
 
 	hash_list = RTE_TAILQ_CAST(rte_hash_tailq.head, rte_hash_list);
 
-	rte_rwlock_read_lock(RTE_EAL_TAILQ_RWLOCK);
+	rte_eal_mcfg_tailq_read_lock();
 	TAILQ_FOREACH(te, hash_list, next) {
 		h = (struct rte_hash *) te->data;
 		if (strncmp(name, h->name, RTE_HASH_NAMESIZE) == 0)
 			break;
 	}
-	rte_rwlock_read_unlock(RTE_EAL_TAILQ_RWLOCK);
+	rte_eal_mcfg_tailq_read_unlock();
 
 	if (te == NULL) {
 		rte_errno = ENOENT;
@@ -239,7 +239,7 @@ rte_hash_create(const struct rte_hash_parameters *params)
 
 	snprintf(hash_name, sizeof(hash_name), "HT_%s", params->name);
 
-	rte_rwlock_write_lock(RTE_EAL_TAILQ_RWLOCK);
+	rte_eal_mcfg_tailq_write_lock();
 
 	/* guarantee there's no existing: this is normally already checked
 	 * by ring creation above */
@@ -437,11 +437,11 @@ rte_hash_create(const struct rte_hash_parameters *params)
 
 	te->data = (void *) h;
 	TAILQ_INSERT_TAIL(hash_list, te, next);
-	rte_rwlock_write_unlock(RTE_EAL_TAILQ_RWLOCK);
+	rte_eal_mcfg_tailq_write_unlock();
 
 	return h;
 err_unlock:
-	rte_rwlock_write_unlock(RTE_EAL_TAILQ_RWLOCK);
+	rte_eal_mcfg_tailq_write_unlock();
 err:
 	rte_ring_free(r);
 	rte_ring_free(r_ext);
@@ -466,7 +466,7 @@ rte_hash_free(struct rte_hash *h)
 
 	hash_list = RTE_TAILQ_CAST(rte_hash_tailq.head, rte_hash_list);
 
-	rte_rwlock_write_lock(RTE_EAL_TAILQ_RWLOCK);
+	rte_eal_mcfg_tailq_write_lock();
 
 	/* find out tailq entry */
 	TAILQ_FOREACH(te, hash_list, next) {
@@ -475,13 +475,13 @@ rte_hash_free(struct rte_hash *h)
 	}
 
 	if (te == NULL) {
-		rte_rwlock_write_unlock(RTE_EAL_TAILQ_RWLOCK);
+		rte_eal_mcfg_tailq_write_unlock();
 		return;
 	}
 
 	TAILQ_REMOVE(hash_list, te, next);
 
-	rte_rwlock_write_unlock(RTE_EAL_TAILQ_RWLOCK);
+	rte_eal_mcfg_tailq_write_unlock();
 
 	if (h->use_local_cache)
 		rte_free(h->local_free_slots);
diff --git a/lib/librte_hash/rte_fbk_hash.c b/lib/librte_hash/rte_fbk_hash.c
index 9360f7981..54a8596ab 100644
--- a/lib/librte_hash/rte_fbk_hash.c
+++ b/lib/librte_hash/rte_fbk_hash.c
@@ -50,13 +50,13 @@ rte_fbk_hash_find_existing(const char *name)
 	fbk_hash_list = RTE_TAILQ_CAST(rte_fbk_hash_tailq.head,
 				       rte_fbk_hash_list);
 
-	rte_rwlock_read_lock(RTE_EAL_TAILQ_RWLOCK);
+	rte_eal_mcfg_tailq_read_lock();
 	TAILQ_FOREACH(te, fbk_hash_list, next) {
 		h = (struct rte_fbk_hash_table *) te->data;
 		if (strncmp(name, h->name, RTE_FBK_HASH_NAMESIZE) == 0)
 			break;
 	}
-	rte_rwlock_read_unlock(RTE_EAL_TAILQ_RWLOCK);
+	rte_eal_mcfg_tailq_read_unlock();
 	if (te == NULL) {
 		rte_errno = ENOENT;
 		return NULL;
@@ -103,7 +103,7 @@ rte_fbk_hash_create(const struct rte_fbk_hash_params *params)
 
 	snprintf(hash_name, sizeof(hash_name), "FBK_%s", params->name);
 
-	rte_rwlock_write_lock(RTE_EAL_TAILQ_RWLOCK);
+	rte_eal_mcfg_tailq_write_lock();
 
 	/* guarantee there's no existing */
 	TAILQ_FOREACH(te, fbk_hash_list, next) {
@@ -165,7 +165,7 @@ rte_fbk_hash_create(const struct rte_fbk_hash_params *params)
 	TAILQ_INSERT_TAIL(fbk_hash_list, te, next);
 
 exit:
-	rte_rwlock_write_unlock(RTE_EAL_TAILQ_RWLOCK);
+	rte_eal_mcfg_tailq_write_unlock();
 
 	return ht;
 }
@@ -188,7 +188,7 @@ rte_fbk_hash_free(struct rte_fbk_hash_table *ht)
 	fbk_hash_list = RTE_TAILQ_CAST(rte_fbk_hash_tailq.head,
 				       rte_fbk_hash_list);
 
-	rte_rwlock_write_lock(RTE_EAL_TAILQ_RWLOCK);
+	rte_eal_mcfg_tailq_write_lock();
 
 	/* find out tailq entry */
 	TAILQ_FOREACH(te, fbk_hash_list, next) {
@@ -197,13 +197,13 @@ rte_fbk_hash_free(struct rte_fbk_hash_table *ht)
 	}
 
 	if (te == NULL) {
-		rte_rwlock_write_unlock(RTE_EAL_TAILQ_RWLOCK);
+		rte_eal_mcfg_tailq_write_unlock();
 		return;
 	}
 
 	TAILQ_REMOVE(fbk_hash_list, te, next);
 
-	rte_rwlock_write_unlock(RTE_EAL_TAILQ_RWLOCK);
+	rte_eal_mcfg_tailq_write_unlock();
 
 	rte_free(ht);
 	rte_free(te);
diff --git a/lib/librte_kni/rte_kni.c b/lib/librte_kni/rte_kni.c
index e6507b07d..d0884aeb9 100644
--- a/lib/librte_kni/rte_kni.c
+++ b/lib/librte_kni/rte_kni.c
@@ -214,7 +214,7 @@ rte_kni_alloc(struct rte_mempool *pktmbuf_pool,
 		return NULL;
 	}
 
-	rte_rwlock_write_lock(RTE_EAL_TAILQ_RWLOCK);
+	rte_eal_mcfg_tailq_write_lock();
 
 	kni = __rte_kni_get(conf->name);
 	if (kni != NULL) {
@@ -313,7 +313,7 @@ rte_kni_alloc(struct rte_mempool *pktmbuf_pool,
 	kni_list = RTE_TAILQ_CAST(rte_kni_tailq.head, rte_kni_list);
 	TAILQ_INSERT_TAIL(kni_list, te, next);
 
-	rte_rwlock_write_unlock(RTE_EAL_TAILQ_RWLOCK);
+	rte_eal_mcfg_tailq_write_unlock();
 
 	/* Allocate mbufs and then put them into alloc_q */
 	kni_allocate_mbufs(kni);
@@ -327,7 +327,7 @@ rte_kni_alloc(struct rte_mempool *pktmbuf_pool,
 kni_fail:
 	rte_free(te);
 unlock:
-	rte_rwlock_write_unlock(RTE_EAL_TAILQ_RWLOCK);
+	rte_eal_mcfg_tailq_write_unlock();
 
 	return NULL;
 }
@@ -390,7 +390,7 @@ rte_kni_release(struct rte_kni *kni)
 
 	kni_list = RTE_TAILQ_CAST(rte_kni_tailq.head, rte_kni_list);
 
-	rte_rwlock_write_lock(RTE_EAL_TAILQ_RWLOCK);
+	rte_eal_mcfg_tailq_write_lock();
 
 	TAILQ_FOREACH(te, kni_list, next) {
 		if (te->data == kni)
@@ -408,7 +408,7 @@ rte_kni_release(struct rte_kni *kni)
 
 	TAILQ_REMOVE(kni_list, te, next);
 
-	rte_rwlock_write_unlock(RTE_EAL_TAILQ_RWLOCK);
+	rte_eal_mcfg_tailq_write_unlock();
 
 	/* mbufs in all fifo should be released, except request/response */
 
@@ -432,7 +432,7 @@ rte_kni_release(struct rte_kni *kni)
 	return 0;
 
 unlock:
-	rte_rwlock_write_unlock(RTE_EAL_TAILQ_RWLOCK);
+	rte_eal_mcfg_tailq_write_unlock();
 
 	return -1;
 }
@@ -649,11 +649,11 @@ rte_kni_get(const char *name)
 	if (name == NULL || name[0] == '\0')
 		return NULL;
 
-	rte_rwlock_read_lock(RTE_EAL_TAILQ_RWLOCK);
+	rte_eal_mcfg_tailq_read_lock();
 
 	kni = __rte_kni_get(name);
 
-	rte_rwlock_read_unlock(RTE_EAL_TAILQ_RWLOCK);
+	rte_eal_mcfg_tailq_read_unlock();
 
 	return kni;
 }
-- 
2.17.1


More information about the dev mailing list