From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga17.intel.com (mga17.intel.com [192.55.52.151]) by dpdk.org (Postfix) with ESMTP id CBC7D1B8B4 for ; Tue, 26 Jun 2018 17:00:00 +0200 (CEST) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga002.jf.intel.com ([10.7.209.21]) by fmsmga107.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 26 Jun 2018 07:59:59 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.51,274,1526367600"; d="scan'208";a="70142084" Received: from irsmsx110.ger.corp.intel.com ([163.33.3.25]) by orsmga002.jf.intel.com with ESMTP; 26 Jun 2018 07:59:58 -0700 Received: from irsmsx156.ger.corp.intel.com (10.108.20.68) by irsmsx110.ger.corp.intel.com (163.33.3.25) with Microsoft SMTP Server (TLS) id 14.3.319.2; Tue, 26 Jun 2018 15:59:51 +0100 Received: from irsmsx108.ger.corp.intel.com ([169.254.11.139]) by IRSMSX156.ger.corp.intel.com ([169.254.3.252]) with mapi id 14.03.0319.002; Tue, 26 Jun 2018 15:59:51 +0100 From: "De Lara Guarch, Pablo" To: "Wang, Yipeng1" CC: "dev@dpdk.org" , "Wang, Yipeng1" , "Mcnamara, John" , "Richardson, Bruce" , "honnappa.nagarahalli@arm.com" , "vguvva@caviumnetworks.com" , "brijesh.s.singh@gmail.com" Thread-Topic: [dpdk-dev] [PATCH v1 1/3] hash: add read and write concurrency support Thread-Index: AQHT/1IcUw1oqePJHEan3dWp56QmV6RyruAA Date: Tue, 26 Jun 2018 14:59:51 +0000 Message-ID: References: <1528455078-328182-1-git-send-email-yipeng1.wang@intel.com> <1528455078-328182-2-git-send-email-yipeng1.wang@intel.com> In-Reply-To: <1528455078-328182-2-git-send-email-yipeng1.wang@intel.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-titus-metadata-40: eyJDYXRlZ29yeUxhYmVscyI6IiIsIk1ldGFkYXRhIjp7Im5zIjoiaHR0cDpcL1wvd3d3LnRpdHVzLmNvbVwvbnNcL0ludGVsMyIsImlkIjoiYzAwNDhlOWMtNjU5Ny00MDZkLTlkZjktZjAyZTg1NmZjZDVkIiwicHJvcHMiOlt7Im4iOiJDVFBDbGFzc2lmaWNhdGlvbiIsInZhbHMiOlt7InZhbHVlIjoiQ1RQX05UIn1dfV19LCJTdWJqZWN0TGFiZWxzIjpbXSwiVE1DVmVyc2lvbiI6IjE3LjEwLjE4MDQuNDkiLCJUcnVzdGVkTGFiZWxIYXNoIjoicHVCdVBNdDdGQkpVS3hna21sdzhQWlJxQmFPUGVlV0UwQ0o5ZGpGU1ZHZklPTlppdFRHZWJrWWFqZEpVRlZGdiJ9 x-ctpclassification: CTP_NT dlp-product: dlpe-windows dlp-version: 11.0.200.100 dlp-reaction: no-action x-originating-ip: [163.33.239.182] Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Subject: Re: [dpdk-dev] [PATCH v1 1/3] hash: add read and write concurrency support X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 26 Jun 2018 15:00:01 -0000 Hi Yipeng, > -----Original Message----- > From: dev [mailto:dev-bounces@dpdk.org] On Behalf Of Yipeng Wang > Sent: Friday, June 8, 2018 11:51 AM > To: De Lara Guarch, Pablo > Cc: dev@dpdk.org; Wang, Yipeng1 ; Mcnamara, > John ; Richardson, Bruce > ; honnappa.nagarahalli@arm.com; > vguvva@caviumnetworks.com; brijesh.s.singh@gmail.com > Subject: [dpdk-dev] [PATCH v1 1/3] hash: add read and write concurrency > support >=20 > The existing implementation of librte_hash does not support read-write > concurrency. This commit implements read-write safety using rte_rwlock an= d > rte_rwlock TM version if hardware transactional memory is available. >=20 > Both multi-writer and read-write concurrency is protected by rte_rwlock n= ow. > The x86 specific header file is removed since the x86 specific RTM functi= on 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_bucke= t, 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 me= son.build file too. More comments below. Thanks, Pablo >=20 > Signed-off-by: Yipeng Wang > --- > 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 >=20 > 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 =3D 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 =3D ADD_KEY_SINGLEWRITER; > + rte_rwlock_init(h->readwrite_lock); > + } >=20 ... > +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 =3D sig & h->bucket_bitmask; ... >=20 > 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 ... >=20 > 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.