From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga06.intel.com (mga06.intel.com [134.134.136.31]) by dpdk.org (Postfix) with ESMTP id 9EA972C4A for ; Wed, 5 Jul 2017 16:50:35 +0200 (CEST) Received: from orsmga001.jf.intel.com ([10.7.209.18]) by orsmga104.jf.intel.com with ESMTP; 05 Jul 2017 07:50:34 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.40,312,1496127600"; d="scan'208";a="1147978767" Received: from irsmsx106.ger.corp.intel.com ([163.33.3.31]) by orsmga001.jf.intel.com with ESMTP; 05 Jul 2017 07:50:33 -0700 Received: from irsmsx108.ger.corp.intel.com ([169.254.11.133]) by IRSMSX106.ger.corp.intel.com ([169.254.8.236]) with mapi id 14.03.0319.002; Wed, 5 Jul 2017 15:50:33 +0100 From: "De Lara Guarch, Pablo" To: mstolarchuk , "Richardson, Bruce" CC: "dev@dpdk.org" Thread-Topic: [dpdk-dev] [PATCH] __rte_hash_add_key_with_hash not releasing multiwriter_lock in failure paths Thread-Index: AQHS1hvvy4XqSAwRvkOq75kFJWlkJqJFjJ/Q Date: Wed, 5 Jul 2017 14:50:32 +0000 Message-ID: References: <1495801830-36849-1-git-send-email-mike.stolarchuk@bigswitch.com> In-Reply-To: <1495801830-36849-1-git-send-email-mike.stolarchuk@bigswitch.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: dlp-product: dlpe-windows dlp-version: 10.0.102.7 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] __rte_hash_add_key_with_hash not releasing multiwriter_lock in failure paths 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: Wed, 05 Jul 2017 14:50:36 -0000 > -----Original Message----- > From: dev [mailto:dev-bounces@dpdk.org] On Behalf Of mstolarchuk > Sent: Friday, May 26, 2017 1:31 PM > To: bruce.richardson@intel.co > Cc: dev@dpdk.org > Subject: [dpdk-dev] [PATCH] __rte_hash_add_key_with_hash not releasing > multiwriter_lock in failure paths >=20 > Signed-off-by: mstolarchuk > --- > lib/librte_hash/rte_cuckoo_hash.c | 13 +++++++++---- > 1 file changed, 9 insertions(+), 4 deletions(-) >=20 > diff --git a/lib/librte_hash/rte_cuckoo_hash.c > b/lib/librte_hash/rte_cuckoo_hash.c > index 645c0cf..37a8110 100644 > --- a/lib/librte_hash/rte_cuckoo_hash.c > +++ b/lib/librte_hash/rte_cuckoo_hash.c > @@ -538,8 +538,10 @@ struct rte_hash * > n_slots =3D rte_ring_mc_dequeue_burst(h- > >free_slots, > cached_free_slots->objs, > LCORE_CACHE_SIZE, NULL); > - if (n_slots =3D=3D 0) > - return -ENOSPC; > + if (n_slots =3D=3D 0) { > + ret =3D -ENOSPC; > + goto failure; > + } >=20 > cached_free_slots->len +=3D n_slots; > } > @@ -548,8 +550,10 @@ struct rte_hash * > cached_free_slots->len--; > slot_id =3D cached_free_slots->objs[cached_free_slots->len]; > } else { > - if (rte_ring_sc_dequeue(h->free_slots, &slot_id) !=3D 0) > - return -ENOSPC; > + if (rte_ring_sc_dequeue(h->free_slots, &slot_id) !=3D 0) { > + ret =3D -ENOSPC; > + goto failure; > + } > } >=20 > new_k =3D RTE_PTR_ADD(keys, (uintptr_t)slot_id * h- > >key_entry_size); @@ -659,6 +663,7 @@ struct rte_hash * > /* Error in addition, store new slot back in the ring and return error > */ > enqueue_slot_back(h, cached_free_slots, (void *)((uintptr_t) > new_idx)); >=20 > +failure: > if (h->add_key =3D=3D ADD_KEY_MULTIWRITER) > rte_spinlock_unlock(h->multiwriter_lock); > return ret; > -- > 1.9.1 Hi Mike, Thanks for the patch, it looks correct to me. The code is fine, but the commit message needs some rework. Title should start with: "hash: ...", since this is aiming the hash library= , So the title could be: "hash: fix lock release on add" Then, some explanation on what the fix is doing would be good. Lastly, since this is a fix, it requires a fixes line and CC to the stable = branch: Fixes: be856325cba3 ("hash: add scalable multi-writer insertion with Intel = TSX") CC: stable@dpdk.org Thanks, Pablo