[dpdk-dev] [PATCH v5 5/8] hash: add read and write concurrency support

Stephen Hemminger stephen at networkplumber.org
Wed Jul 11 22:49:07 CEST 2018


On Tue, 10 Jul 2018 09:59:58 -0700
Yipeng Wang <yipeng1.wang at intel.com> wrote:

> +
> +static inline void
> +__hash_rw_reader_lock(const struct rte_hash *h)
> +{
> +	if (h->readwrite_concur_support && h->hw_trans_mem_support)
> +		rte_rwlock_read_lock_tm(h->readwrite_lock);
> +	else if (h->readwrite_concur_support)
> +		rte_rwlock_read_lock(h->readwrite_lock);
> +}
> +
> +static inline void
> +__hash_rw_writer_unlock(const struct rte_hash *h)
> +{
> +	if (h->multi_writer_support && h->hw_trans_mem_support)
> +		rte_rwlock_write_unlock_tm(h->readwrite_lock);
> +	else if (h->multi_writer_support)
> +		rte_rwlock_write_unlock(h->readwrite_lock);
> +}
> +
> +static inline void
> +__hash_rw_reader_unlock(const struct rte_hash *h)
> +{
> +	if (h->readwrite_concur_support && h->hw_trans_mem_support)
> +		rte_rwlock_read_unlock_tm(h->readwrite_lock);
> +	else if (h->readwrite_concur_support)
> +		rte_rwlock_read_unlock(h->readwrite_lock);
> +}
> +

For small windows, reader-writer locks are slower than a spin lock
because there are more cache bounces.


More information about the dev mailing list