On 04/10/2021 02:37, Han Zhou wrote:
Although not used currently, it is better to fix:
1. The type of the mask field should be the same as hmap->mask: size_t.
2. Calculating the index is better to use & instead of %.
Signed-off-by: Han Zhou <hz...@ovn.org>
---
lib/ovn-parallel-hmap.h | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/lib/ovn-parallel-hmap.h b/lib/ovn-parallel-hmap.h
index 2df132ea8..897208ef8 100644
--- a/lib/ovn-parallel-hmap.h
+++ b/lib/ovn-parallel-hmap.h
@@ -224,7 +224,7 @@ static inline void wait_for_work_completion(struct
worker_pool *pool)
*/
struct hashrow_locks {
- ssize_t mask;
+ size_t mask;
struct ovs_mutex *row_locks;
};
@@ -235,13 +235,13 @@ void ovn_update_hashrow_locks(struct hmap *lflows, struct hashrow_locks *hrl);
/* Lock a hash row */
static inline void lock_hash_row(struct hashrow_locks *hrl, uint32_t hash)
{
- ovs_mutex_lock(&hrl->row_locks[hash % hrl->mask]);
+ ovs_mutex_lock(&hrl->row_locks[hash & hrl->mask]);
}
/* Unlock a hash row */
static inline void unlock_hash_row(struct hashrow_locks *hrl, uint32_t hash)
{
- ovs_mutex_unlock(&hrl->row_locks[hash % hrl->mask]);
+ ovs_mutex_unlock(&hrl->row_locks[hash & hrl->mask]);
}
/* Init the row locks structure */
+1.
--
Anton R. Ivanov
Cambridgegreys Limited. Registered in England. Company Number 10273661
https://www.cambridgegreys.com/
_______________________________________________
dev mailing list
d...@openvswitch.org
https://mail.openvswitch.org/mailman/listinfo/ovs-dev