lib/hash: remove unnecessary locks in lock-free

Message ID 20191121181759.11401-1-dharmik.thakkar@arm.com (mailing list archive)
State Accepted, archived
Delegated to: Thomas Monjalon
Headers
Series lib/hash: remove unnecessary locks in lock-free |

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/iol-intel-Performance success Performance Testing PASS
ci/iol-compilation success Compile Testing PASS
ci/iol-mellanox-Performance success Performance Testing PASS
ci/Intel-compilation fail Compilation issues
ci/travis-robot success Travis build: passed

Commit Message

Dharmik Thakkar Nov. 21, 2019, 6:17 p.m. UTC
  Remove __hash_rw_reader_unlock() calls from lock free hash lookup

Signed-off-by: Dharmik Thakkar <dharmik.thakkar@arm.com>
Reviewed-by: Gavin Hu <gavin.hu@arm.com>
Reviewed-by: Honnappa Nagarahalli <honnappa.nagarahalli@arm.com>
---
 lib/librte_hash/rte_cuckoo_hash.c | 8 ++------
 1 file changed, 2 insertions(+), 6 deletions(-)
  

Comments

Wang, Yipeng1 Nov. 25, 2019, 6:49 p.m. UTC | #1
>-----Original Message-----
>From: Dharmik Thakkar [mailto:dharmik.thakkar@arm.com]
>Sent: Thursday, November 21, 2019 10:18 AM
>To: Wang, Yipeng1 <yipeng1.wang@intel.com>; Gobriel, Sameh <sameh.gobriel@intel.com>; Richardson, Bruce
><bruce.richardson@intel.com>
>Cc: dev@dpdk.org; honnappa.nagarahalli@arm.com; Dharmik Thakkar <dharmik.thakkar@arm.com>
>Subject: [PATCH] lib/hash: remove unnecessary locks in lock-free
>
>Remove __hash_rw_reader_unlock() calls from lock free hash lookup
>
>Signed-off-by: Dharmik Thakkar <dharmik.thakkar@arm.com>
>Reviewed-by: Gavin Hu <gavin.hu@arm.com>
>Reviewed-by: Honnappa Nagarahalli <honnappa.nagarahalli@arm.com>
>---
Acked-by: Yipeng Wang <yipeng1.wang@intel.com>

Thanks for the patch!
  
Thomas Monjalon Nov. 25, 2019, 9:54 p.m. UTC | #2
25/11/2019 19:49, Wang, Yipeng1:
> >-----Original Message-----
> >From: Dharmik Thakkar [mailto:dharmik.thakkar@arm.com]
> >Sent: Thursday, November 21, 2019 10:18 AM
> >To: Wang, Yipeng1 <yipeng1.wang@intel.com>; Gobriel, Sameh <sameh.gobriel@intel.com>; Richardson, Bruce
> ><bruce.richardson@intel.com>
> >Cc: dev@dpdk.org; honnappa.nagarahalli@arm.com; Dharmik Thakkar <dharmik.thakkar@arm.com>
> >Subject: [PATCH] lib/hash: remove unnecessary locks in lock-free
> >
> >Remove __hash_rw_reader_unlock() calls from lock free hash lookup
> >
> >Signed-off-by: Dharmik Thakkar <dharmik.thakkar@arm.com>
> >Reviewed-by: Gavin Hu <gavin.hu@arm.com>
> >Reviewed-by: Honnappa Nagarahalli <honnappa.nagarahalli@arm.com>
> >---
> Acked-by: Yipeng Wang <yipeng1.wang@intel.com>
> 
> Thanks for the patch!

Excuse me, there is no motivation (the why) in this patch.
Is it critical? which gain?
  
Wang, Yipeng1 Nov. 25, 2019, 10:02 p.m. UTC | #3
>-----Original Message-----
>From: Thomas Monjalon [mailto:thomas@monjalon.net]
>Sent: Monday, November 25, 2019 1:55 PM
>To: Wang, Yipeng1 <yipeng1.wang@intel.com>; Dharmik Thakkar <dharmik.thakkar@arm.com>
>Cc: dev@dpdk.org; Gobriel, Sameh <sameh.gobriel@intel.com>; Richardson, Bruce <bruce.richardson@intel.com>;
>honnappa.nagarahalli@arm.com
>Subject: Re: [dpdk-dev] [PATCH] lib/hash: remove unnecessary locks in lock-free
>
>25/11/2019 19:49, Wang, Yipeng1:
>> >-----Original Message-----
>> >From: Dharmik Thakkar [mailto:dharmik.thakkar@arm.com]
>> >Sent: Thursday, November 21, 2019 10:18 AM
>> >To: Wang, Yipeng1 <yipeng1.wang@intel.com>; Gobriel, Sameh <sameh.gobriel@intel.com>; Richardson, Bruce
>> ><bruce.richardson@intel.com>
>> >Cc: dev@dpdk.org; honnappa.nagarahalli@arm.com; Dharmik Thakkar <dharmik.thakkar@arm.com>
>> >Subject: [PATCH] lib/hash: remove unnecessary locks in lock-free
>> >
>> >Remove __hash_rw_reader_unlock() calls from lock free hash lookup
>> >
>> >Signed-off-by: Dharmik Thakkar <dharmik.thakkar@arm.com>
>> >Reviewed-by: Gavin Hu <gavin.hu@arm.com>
>> >Reviewed-by: Honnappa Nagarahalli <honnappa.nagarahalli@arm.com>
>> >---
>> Acked-by: Yipeng Wang <yipeng1.wang@intel.com>
>>
>> Thanks for the patch!
>
>Excuse me, there is no motivation (the why) in this patch.
>Is it critical? which gain?
>
[Wang, Yipeng] 
Thomas, do you mean the commit message is not clear enough?
I think it is self-explained that in the "lock-free" implementation, we don't need
"read_unlock()" and the subject line also says that.
But it is always better to be more explicit.
  
Thomas Monjalon Nov. 25, 2019, 10:44 p.m. UTC | #4
25/11/2019 23:02, Wang, Yipeng1:
> From: Thomas Monjalon [mailto:thomas@monjalon.net]
> >25/11/2019 19:49, Wang, Yipeng1:
> >> From: Dharmik Thakkar [mailto:dharmik.thakkar@arm.com]
> >> >
> >> >Remove __hash_rw_reader_unlock() calls from lock free hash lookup
> >> >
> >> >Signed-off-by: Dharmik Thakkar <dharmik.thakkar@arm.com>
> >> >Reviewed-by: Gavin Hu <gavin.hu@arm.com>
> >> >Reviewed-by: Honnappa Nagarahalli <honnappa.nagarahalli@arm.com>
> >> >---
> >> Acked-by: Yipeng Wang <yipeng1.wang@intel.com>
> >>
> >> Thanks for the patch!
> >
> >Excuse me, there is no motivation (the why) in this patch.
> >Is it critical? which gain?
> >
> [Wang, Yipeng] 
> Thomas, do you mean the commit message is not clear enough?
> I think it is self-explained that in the "lock-free" implementation, we don't need
> "read_unlock()" and the subject line also says that.
> But it is always better to be more explicit.

I understand that it is not needed.
But it doesn't say what is the impact of having this unlock.
Is there a real performance impact?
Is it critical enough to be merged in 19.11-rc4?
If it is not candidate for 19.11, it is better to prepend the title with [20.02].
  
Dharmik Thakkar Nov. 25, 2019, 10:55 p.m. UTC | #5
> On Nov 25, 2019, at 4:44 PM, Thomas Monjalon <thomas@monjalon.net> wrote:
>
> 25/11/2019 23:02, Wang, Yipeng1:
>> From: Thomas Monjalon [mailto:thomas@monjalon.net]
>>> 25/11/2019 19:49, Wang, Yipeng1:
>>>> From: Dharmik Thakkar [mailto:dharmik.thakkar@arm.com]
>>>>>
>>>>> Remove __hash_rw_reader_unlock() calls from lock free hash lookup
>>>>>
>>>>> Signed-off-by: Dharmik Thakkar <dharmik.thakkar@arm.com>
>>>>> Reviewed-by: Gavin Hu <gavin.hu@arm.com>
>>>>> Reviewed-by: Honnappa Nagarahalli <honnappa.nagarahalli@arm.com>
>>>>> ---
>>>> Acked-by: Yipeng Wang <yipeng1.wang@intel.com>
>>>>
>>>> Thanks for the patch!
>>>
>>> Excuse me, there is no motivation (the why) in this patch.
>>> Is it critical? which gain?
>>>
>> [Wang, Yipeng]
>> Thomas, do you mean the commit message is not clear enough?
>> I think it is self-explained that in the "lock-free" implementation, we don't need
>> "read_unlock()" and the subject line also says that.
>> But it is always better to be more explicit.
>
> I understand that it is not needed.
> But it doesn't say what is the impact of having this unlock.
> Is there a real performance impact?
> Is it critical enough to be merged in 19.11-rc4?
> If it is not candidate for 19.11, it is better to prepend the title with [20.02].
>
Thomas, I don’t think there is any performance impact. This is more of a clean-up patch.
It is not critical as those “read_unlock()” don’t cause any error.
Should I update the patch title with [20.02]?
>

IMPORTANT NOTICE: The contents of this email and any attachments are confidential and may also be privileged. If you are not the intended recipient, please notify the sender immediately and do not disclose the contents to any other person, use it for any purpose, or store or copy the information in any medium. Thank you.
  
Thomas Monjalon Nov. 25, 2019, 11:14 p.m. UTC | #6
25/11/2019 23:55, Dharmik Thakkar:
> 
> > On Nov 25, 2019, at 4:44 PM, Thomas Monjalon <thomas@monjalon.net> wrote:
> >
> > 25/11/2019 23:02, Wang, Yipeng1:
> >> From: Thomas Monjalon [mailto:thomas@monjalon.net]
> >>> 25/11/2019 19:49, Wang, Yipeng1:
> >>>> From: Dharmik Thakkar [mailto:dharmik.thakkar@arm.com]
> >>>>>
> >>>>> Remove __hash_rw_reader_unlock() calls from lock free hash lookup
> >>>>>
> >>>>> Signed-off-by: Dharmik Thakkar <dharmik.thakkar@arm.com>
> >>>>> Reviewed-by: Gavin Hu <gavin.hu@arm.com>
> >>>>> Reviewed-by: Honnappa Nagarahalli <honnappa.nagarahalli@arm.com>
> >>>>> ---
> >>>> Acked-by: Yipeng Wang <yipeng1.wang@intel.com>
> >>>>
> >>>> Thanks for the patch!
> >>>
> >>> Excuse me, there is no motivation (the why) in this patch.
> >>> Is it critical? which gain?
> >>>
> >> [Wang, Yipeng]
> >> Thomas, do you mean the commit message is not clear enough?
> >> I think it is self-explained that in the "lock-free" implementation, we don't need
> >> "read_unlock()" and the subject line also says that.
> >> But it is always better to be more explicit.
> >
> > I understand that it is not needed.
> > But it doesn't say what is the impact of having this unlock.
> > Is there a real performance impact?
> > Is it critical enough to be merged in 19.11-rc4?
> > If it is not candidate for 19.11, it is better to prepend the title with [20.02].
> >
> Thomas, I don’t think there is any performance impact. This is more of a clean-up patch.
> It is not critical as those “read_unlock()” don’t cause any error.
> Should I update the patch title with [20.02]?

No that's fine, it's clear now.
Thank you
  
Dharmik Thakkar Jan. 17, 2020, 4:42 p.m. UTC | #7
Hi Thomas,
Can this patch be merged?

> On Nov 25, 2019, at 5:14 PM, Thomas Monjalon <thomas@monjalon.net> wrote:
>
> 25/11/2019 23:55, Dharmik Thakkar:
>>
>>> On Nov 25, 2019, at 4:44 PM, Thomas Monjalon <thomas@monjalon.net> wrote:
>>>
>>> 25/11/2019 23:02, Wang, Yipeng1:
>>>> From: Thomas Monjalon [mailto:thomas@monjalon.net]
>>>>> 25/11/2019 19:49, Wang, Yipeng1:
>>>>>> From: Dharmik Thakkar [mailto:dharmik.thakkar@arm.com]
>>>>>>>
>>>>>>> Remove __hash_rw_reader_unlock() calls from lock free hash lookup
>>>>>>>
>>>>>>> Signed-off-by: Dharmik Thakkar <dharmik.thakkar@arm.com>
>>>>>>> Reviewed-by: Gavin Hu <gavin.hu@arm.com>
>>>>>>> Reviewed-by: Honnappa Nagarahalli <honnappa.nagarahalli@arm.com>
>>>>>>> ---
>>>>>> Acked-by: Yipeng Wang <yipeng1.wang@intel.com>
>>>>>>
>>>>>> Thanks for the patch!
>>>>>
>>>>> Excuse me, there is no motivation (the why) in this patch.
>>>>> Is it critical? which gain?
>>>>>
>>>> [Wang, Yipeng]
>>>> Thomas, do you mean the commit message is not clear enough?
>>>> I think it is self-explained that in the "lock-free" implementation, we don't need
>>>> "read_unlock()" and the subject line also says that.
>>>> But it is always better to be more explicit.
>>>
>>> I understand that it is not needed.
>>> But it doesn't say what is the impact of having this unlock.
>>> Is there a real performance impact?
>>> Is it critical enough to be merged in 19.11-rc4?
>>> If it is not candidate for 19.11, it is better to prepend the title with [20.02].
>>>
>> Thomas, I don’t think there is any performance impact. This is more of a clean-up patch.
>> It is not critical as those “read_unlock()” don’t cause any error.
>> Should I update the patch title with [20.02]?
>
> No that's fine, it's clear now.
> Thank you

IMPORTANT NOTICE: The contents of this email and any attachments are confidential and may also be privileged. If you are not the intended recipient, please notify the sender immediately and do not disclose the contents to any other person, use it for any purpose, or store or copy the information in any medium. Thank you.
IMPORTANT NOTICE: The contents of this email and any attachments are confidential and may also be privileged. If you are not the intended recipient, please notify the sender immediately and do not disclose the contents to any other person, use it for any purpose, or store or copy the information in any medium. Thank you.
  
Thomas Monjalon Jan. 19, 2020, 11:37 p.m. UTC | #8
25/11/2019 19:49, Wang, Yipeng1:
>From: Dharmik Thakkar [mailto:dharmik.thakkar@arm.com]
> >Remove __hash_rw_reader_unlock() calls from lock free hash lookup
> >
> >Signed-off-by: Dharmik Thakkar <dharmik.thakkar@arm.com>
> >Reviewed-by: Gavin Hu <gavin.hu@arm.com>
> >Reviewed-by: Honnappa Nagarahalli <honnappa.nagarahalli@arm.com>
> >---
> Acked-by: Yipeng Wang <yipeng1.wang@intel.com>

Applied, thanks
  

Patch

diff --git a/lib/librte_hash/rte_cuckoo_hash.c b/lib/librte_hash/rte_cuckoo_hash.c
index 87a4c01f2f9e..1a4795c82321 100644
--- a/lib/librte_hash/rte_cuckoo_hash.c
+++ b/lib/librte_hash/rte_cuckoo_hash.c
@@ -1285,10 +1285,8 @@  __rte_hash_lookup_with_hash_lf(const struct rte_hash *h, const void *key,
 		/* Check if key is in primary location */
 		bkt = &h->buckets[prim_bucket_idx];
 		ret = search_one_bucket_lf(h, key, short_sig, data, bkt);
-		if (ret != -1) {
-			__hash_rw_reader_unlock(h);
+		if (ret != -1)
 			return ret;
-		}
 		/* Calculate secondary hash */
 		bkt = &h->buckets[sec_bucket_idx];
 
@@ -1296,10 +1294,8 @@  __rte_hash_lookup_with_hash_lf(const struct rte_hash *h, const void *key,
 		FOR_EACH_BUCKET(cur_bkt, bkt) {
 			ret = search_one_bucket_lf(h, key, short_sig,
 						data, cur_bkt);
-			if (ret != -1) {
-				__hash_rw_reader_unlock(h);
+			if (ret != -1)
 				return ret;
-			}
 		}
 
 		/* The loads of sig_current in search_one_bucket