lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <53FE8011.4060100@windriver.com>
Date:	Thu, 28 Aug 2014 09:04:17 +0800
From:	Ying Xue <ying.xue@...driver.com>
To:	Thomas Graf <tgraf@...g.ch>
CC:	<davem@...emloft.net>, <eric.dumazet@...il.com>,
	<netdev@...r.kernel.org>
Subject: Re: [PATCH RFC] lib/rhashtable: allow users to set the minimum shifts
 of shrinking

On 08/27/2014 06:34 PM, Thomas Graf wrote:
> On 08/27/14 at 04:57pm, Ying Xue wrote:
>> diff --git a/lib/rhashtable.c b/lib/rhashtable.c
>> index a2c7881..1466e2d 100644
>> --- a/lib/rhashtable.c
>> +++ b/lib/rhashtable.c
>> @@ -293,12 +293,15 @@ EXPORT_SYMBOL_GPL(rhashtable_expand);
>>  int rhashtable_shrink(struct rhashtable *ht, gfp_t flags)
>>  {
>>  	struct bucket_table *ntbl, *tbl = rht_dereference(ht->tbl, ht);
>> +	size_t min_shift = ilog2(HASH_MIN_SIZE);
>>  	struct rhash_head __rcu **pprev;
>>  	unsigned int i;
>>  
>>  	ASSERT_RHT_MUTEX(ht);
>>  
>> -	if (tbl->size <= HASH_MIN_SIZE)
>> +	if (ht->p.min_shift)
>> +		min_shift = max(ht->p.min_shift, min_shift);
>> +	if (ht->shift <= min_shift)
>>  		return 0;
> 
> I like it. Can you translate HASH_MIN_SIZE to .minshift in
> rhashtable_init()? That way we only have to deal with .min_shift in
> rhashtable_shrink().
> 

Good suggestion! I will change it in next version.

> Note that shrinking can also be disabled by not providing a
> .shrink_decision function in rhashtable_params if the shrinking is
> too expensive for your case.
> 

Yes, I know the rule. But in some case we hope that rhashtable doesn't
take such expensive actions like expanding and shrinking when its size
is small; meanwhile, when its size is rather big, shrinking is able to
de done as usual.

In fact, we already published the max_shift to users, allowing them to
limit the biggest size of rhashtable. So, exporting min_shift should be
reasonable, having users have a chance to specify the smallest size of
rhashtable.

>> -static size_t rounded_hashtable_size(unsigned int nelem)
>> +static size_t rounded_hashtable_size(struct rhashtable_params *params)
>>  {
>> -	return max(roundup_pow_of_two(nelem * 4 / 3), HASH_MIN_SIZE);
>> +	size_t size = HASH_MIN_SIZE;
>> +
>> +	if (params->min_shift)
>> +		size = max((1UL << params->min_shift), HASH_MIN_SIZE);
>> +
>> +	return max(roundup_pow_of_two(params->nelem_hint * 4 / 3), size);
>>  }
> 
> Same here. If you merge the provided .min_shift with HASH_MIN_SIZE
> in rhashtable_init() before calculating the size, the above logic
> can be simplified a lot.
> 

Thanks for your suggestion.

Regards,
Ying

> 

--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ