summaryrefslogtreecommitdiff
path: root/lib/hash
diff options
context:
space:
mode:
authorDavid Marchand <[email protected]>2023-04-04 14:48:28 +0200
committerThomas Monjalon <[email protected]>2023-04-23 16:17:37 +0200
commitfa5cb058fb842b5f93e9ecf2d2909f1b991c66f4 (patch)
tree3d8c62105a966f247f0b851f228b9bf956ff8f13 /lib/hash
parent0c156487ca73596a05d04fbeb395dcd170d752fa (diff)
hash: annotate cuckoo hash lock
__hash_rw_(reader|writer)_(|un)lock helpers take locks depending on conditions that are fixed at the rte_hash object initialisation. So we can tell clang that those helpers unconditionally take/release those locks (and waive the lock check on their implementation). Signed-off-by: David Marchand <[email protected]>
Diffstat (limited to 'lib/hash')
-rw-r--r--lib/hash/rte_cuckoo_hash.c8
1 files changed, 8 insertions, 0 deletions
diff --git a/lib/hash/rte_cuckoo_hash.c b/lib/hash/rte_cuckoo_hash.c
index 829b79c89a..d92a903bb3 100644
--- a/lib/hash/rte_cuckoo_hash.c
+++ b/lib/hash/rte_cuckoo_hash.c
@@ -575,6 +575,8 @@ rte_hash_count(const struct rte_hash *h)
/* Read write locks implemented using rte_rwlock */
static inline void
__hash_rw_writer_lock(const struct rte_hash *h)
+ __rte_exclusive_lock_function(&h->readwrite_lock)
+ __rte_no_thread_safety_analysis
{
if (h->writer_takes_lock && h->hw_trans_mem_support)
rte_rwlock_write_lock_tm(h->readwrite_lock);
@@ -584,6 +586,8 @@ __hash_rw_writer_lock(const struct rte_hash *h)
static inline void
__hash_rw_reader_lock(const struct rte_hash *h)
+ __rte_shared_lock_function(&h->readwrite_lock)
+ __rte_no_thread_safety_analysis
{
if (h->readwrite_concur_support && h->hw_trans_mem_support)
rte_rwlock_read_lock_tm(h->readwrite_lock);
@@ -593,6 +597,8 @@ __hash_rw_reader_lock(const struct rte_hash *h)
static inline void
__hash_rw_writer_unlock(const struct rte_hash *h)
+ __rte_unlock_function(&h->readwrite_lock)
+ __rte_no_thread_safety_analysis
{
if (h->writer_takes_lock && h->hw_trans_mem_support)
rte_rwlock_write_unlock_tm(h->readwrite_lock);
@@ -602,6 +608,8 @@ __hash_rw_writer_unlock(const struct rte_hash *h)
static inline void
__hash_rw_reader_unlock(const struct rte_hash *h)
+ __rte_unlock_function(&h->readwrite_lock)
+ __rte_no_thread_safety_analysis
{
if (h->readwrite_concur_support && h->hw_trans_mem_support)
rte_rwlock_read_unlock_tm(h->readwrite_lock);