[dpdk-dev] [PATCH v1 1/3] hash: add read and write concurrency support

De Lara Guarch, Pablo pablo.de.lara.guarch at intel.com
Tue Jun 26 16:59:51 CEST 2018


Hi Yipeng,

> -----Original Message-----
> From: dev [mailto:dev-bounces at dpdk.org] On Behalf Of Yipeng Wang
> Sent: Friday, June 8, 2018 11:51 AM
> To: De Lara Guarch, Pablo <pablo.de.lara.guarch at intel.com>
> Cc: dev at dpdk.org; Wang, Yipeng1 <yipeng1.wang at intel.com>; Mcnamara,
> John <john.mcnamara at intel.com>; Richardson, Bruce
> <bruce.richardson at intel.com>; honnappa.nagarahalli at arm.com;
> vguvva at caviumnetworks.com; brijesh.s.singh at gmail.com
> Subject: [dpdk-dev] [PATCH v1 1/3] hash: add read and write concurrency
> support
> 
> The existing implementation of librte_hash does not support read-write
> concurrency. This commit implements read-write safety using rte_rwlock and
> rte_rwlock TM version if hardware transactional memory is available.
> 
> Both multi-writer and read-write concurrency is protected by rte_rwlock now.
> The x86 specific header file is removed since the x86 specific RTM function is not
> called directly by rte hash now.

Sorry for the late review.

Could you split this patch to make it easier to review?
I suggest first refactor the code adding and using the API search_one_bucket, search_and_update
and search_and_remove, and then add the rest of the patch.

Since you are removing rte_cuckoo_hash_x86.h, you need to remove it from meson.build file too.

More comments below.

Thanks,
Pablo

> 
> Signed-off-by: Yipeng Wang <yipeng1.wang at intel.com>
> ---
>  lib/librte_hash/rte_cuckoo_hash.c     | 627 +++++++++++++++++++++-------------
>  lib/librte_hash/rte_cuckoo_hash.h     |  16 +-
>  lib/librte_hash/rte_cuckoo_hash_x86.h | 164 ---------
>  lib/librte_hash/rte_hash.h            |   3 +
>  4 files changed, 390 insertions(+), 420 deletions(-)  delete mode 100644
> lib/librte_hash/rte_cuckoo_hash_x86.h
> 
> diff --git a/lib/librte_hash/rte_cuckoo_hash.c
> b/lib/librte_hash/rte_cuckoo_hash.c
> index a07543a..a5bb4d4 100644
> --- a/lib/librte_hash/rte_cuckoo_hash.c
> +++ b/lib/librte_hash/rte_cuckoo_hash.c

...

> +	if (h->multi_writer_support) {
> +		h->readwrite_lock = rte_malloc(NULL, sizeof(rte_rwlock_t),
>  							LCORE_CACHE_SIZE);

Check if malloc was successful, if not go to err_unlock.

> -			rte_spinlock_init(h->multiwriter_lock);
> -		}
> -	} else
> -		h->add_key = ADD_KEY_SINGLEWRITER;
> +		rte_rwlock_init(h->readwrite_lock);
> +	}
> 

...

> +static inline int32_t
> +__rte_hash_del_key_with_hash(const struct rte_hash *h, const void *key,
> +						hash_sig_t sig)
> +{
> +	int32_t bucket_idx;

Shouldn't this be "uint32_t"?

> +	hash_sig_t alt_hash;
> +	struct rte_hash_bucket *bkt;
> +	int32_t ret_val;
> +
> +	bucket_idx = sig & h->bucket_bitmask;

...

> 
> diff --git a/lib/librte_hash/rte_cuckoo_hash.h
> b/lib/librte_hash/rte_cuckoo_hash.h
> index 7a54e55..40b6be0 100644
> --- a/lib/librte_hash/rte_cuckoo_hash.h
> +++ b/lib/librte_hash/rte_cuckoo_hash.h

...

> 
>  	uint32_t key_len __rte_cache_aligned;
>  	/**< Length of hash key. */
> +	uint8_t hw_trans_mem_support;
> +	uint8_t multi_writer_support;

Add comments for these two fields.



More information about the dev mailing list