[dpdk-dev] [PATCH v2 2/6] hash: add read and write concurrency support

De Lara Guarch, Pablo pablo.de.lara.guarch at intel.com
Fri Jul 6 19:11:11 CEST 2018



> -----Original Message-----
> From: Wang, Yipeng1
> Sent: Friday, June 29, 2018 1:25 PM
> To: De Lara Guarch, Pablo <pablo.de.lara.guarch at intel.com>
> Cc: dev at dpdk.org; Wang, Yipeng1 <yipeng1.wang 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: [PATCH v2 2/6] 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.
> 
> Signed-off-by: Yipeng Wang <yipeng1.wang at intel.com>
> ---
>  lib/librte_hash/meson.build           |   1 -
>  lib/librte_hash/rte_cuckoo_hash.c     | 507 ++++++++++++++++++++++------------
>  lib/librte_hash/rte_cuckoo_hash.h     |  18 +-
>  lib/librte_hash/rte_cuckoo_hash_x86.h | 164 -----------
>  lib/librte_hash/rte_hash.h            |   3 +
>  5 files changed, 338 insertions(+), 355 deletions(-)  delete mode 100644
> lib/librte_hash/rte_cuckoo_hash_x86.h
> 

...

> --- a/lib/librte_hash/rte_cuckoo_hash.c
> +++ b/lib/librte_hash/rte_cuckoo_hash.c
> @@ -31,9 +31,6 @@

...

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

I think LCORE_CACHE_SIZE should be RTE_CACHE_LINE_SIZE (same value, but different meaning).

> -			rte_spinlock_init(h->multiwriter_lock);
> -		}

...

> +
> +	/* Didnt' find a match, so get a new slot for storing the new key */

Typo: Didn't

> +	if (h->multi_writer_support) {
>  		lcore_id = rte_lcore_id();
>  		cached_free_slots = &h->local_free_slots[lcore_id];


More information about the dev mailing list