[ltt-dev] [PATCH 7/9] rculfhash: Simplify lookup_bucket()
Lai Jiangshan
laijs at cn.fujitsu.com
Fri Oct 14 10:51:48 EDT 2011
On 10/14/2011 10:25 PM, Mathieu Desnoyers wrote:
> * Lai Jiangshan (laijs at cn.fujitsu.com) wrote:
>> They are the same, but I don't think the compiler
>> can optimize it.
>
> Can you double-check this by comparing assembly output ?
>
>>
>> And it also helps for understanding the following code.
>
> I try to use "get_count_order" in the algorithms everywhere so we have
> only a single semantic to keep in mind.
The algorithm uses the highest bit's order for order array index.
The algorithm drops the highest bit for aridx,
I think fls_ulong()'s semantic matchs "the highest bit" mostly.
Thanks
Lai
>
> Thanks,
>
> Mathieu
>
>>
>> Signed-off-by: Lai Jiangshan <laijs at cn.fujitsu.com>
>> ---
>> rculfhash.c | 2 +-
>> 1 files changed, 1 insertions(+), 1 deletions(-)
>>
>> diff --git a/rculfhash.c b/rculfhash.c
>> index edbd24a..7b880d7 100644
>> --- a/rculfhash.c
>> +++ b/rculfhash.c
>> @@ -719,7 +719,7 @@ struct _cds_lfht_node *lookup_bucket(struct cds_lfht *ht, unsigned long size,
>>
>> assert(size > 0);
>> index = hash & (size - 1);
>> - order = get_count_order_ulong(index + 1);
>> + order = fls_ulong(index);
>>
>> dbg_printf("lookup hash %lu index %lu order %lu aridx %lu\n",
>> hash, index, order, index & (!order ? 0 : ((1UL << (order - 1)) - 1)));
>> --
>> 1.7.4.4
>>
>
More information about the lttng-dev
mailing list