From: Ying Xue <ying.xue@windriver.com>
To: Thomas Graf <tgraf@suug.ch>
Cc: <davem@davemloft.net>, <eric.dumazet@gmail.com>,
<netdev@vger.kernel.org>
Subject: Re: [PATCH net-next v2] lib/rhashtable: allow users to set the minimum shifts of shrinking
Date: Fri, 29 Aug 2014 18:08:09 +0800 [thread overview]
Message-ID: <54005109.3070904@windriver.com> (raw)
In-Reply-To: <20140829093107.GA3563@casper.infradead.org>
On 08/29/2014 05:31 PM, Thomas Graf wrote:
> On 08/28/14 at 09:45am, Ying Xue wrote:
>> Now the resizeable hash table size is allowed to shrink a too smaller
>> size - HASH_MIN_SIZE(4) although users initially specify a rather big
>> size when table is created. Especially when the number of objects
>> saved in the table keeps a small value in comparison with the initial
>> setting of table size during a quite long time, lots of actions of
>> expanding and shrinking are involved with objects being inserted or
>
> Can you work on this part of the commit message a bit? I know what
> you want to say but it's not very clear from the text.
>
OK. I will revise it.
>> removed from table. However, as synchronize_rcu() has to be called
>> during expanding and shrinking, these unnecessary actions would
>> seriously hit users' performance.
>>
>> Therefore, we should permit users to set the minimum table size
>> through configuring the minimum of number of shifts when table is
>> created according to users specific requirement.
>>
>> diff --git a/lib/rhashtable.c b/lib/rhashtable.c
>> index a2c7881..85a4ac2 100644
>> --- a/lib/rhashtable.c
>> +++ b/lib/rhashtable.c
>> @@ -566,8 +568,13 @@ int rhashtable_init(struct rhashtable *ht, struct rhashtable_params *params)
>> (!params->key_len && !params->obj_hashfn))
>> return -EINVAL;
>>
>> + if (params->min_shift)
>> + params->min_shift = max(params->min_shift, min_shift);
>> + else
>> + params->min_shift = min_shift;
>> +
>
> You can simplify all of the above to just:
>
> params->min_shift = max(params->min_shift, ilog2(HASH_MIN_SIZE));
>
>
Oops! when I created the code, I wrongly deemed params->min_shift as a
pointer so that the code became so complex. Thanks, I will change it
with your good advice.
Regards,
Ying
prev parent reply other threads:[~2014-08-29 10:08 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-08-28 1:45 [PATCH net-next v2] lib/rhashtable: allow users to set the minimum shifts of shrinking Ying Xue
2014-08-29 9:31 ` Thomas Graf
2014-08-29 10:08 ` Ying Xue [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=54005109.3070904@windriver.com \
--to=ying.xue@windriver.com \
--cc=davem@davemloft.net \
--cc=eric.dumazet@gmail.com \
--cc=netdev@vger.kernel.org \
--cc=tgraf@suug.ch \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox