From: Jan Kara <jack@suse.cz>
To: Chengguang Xu <cgxu519@zoho.com.cn>
Cc: Jan Kara <jack@suse.com>, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] quota: code cleanup for hash bits calculation
Date: Mon, 23 Sep 2019 12:02:59 +0200 [thread overview]
Message-ID: <20190923100259.GD20367@quack2.suse.cz> (raw)
In-Reply-To: <20190921015628.54335-1-cgxu519@zoho.com.cn>
On Sat 21-09-19 09:56:28, Chengguang Xu wrote:
> Code cleanup for hash bits calculation by
> calling rounddown_pow_of_two() and ilog2()
>
> Signed-off-by: Chengguang Xu <cgxu519@zoho.com.cn>
Thanks for the patch! One comment below:
> diff --git a/fs/quota/dquot.c b/fs/quota/dquot.c
> index 6e826b454082..679dd3b5db70 100644
> --- a/fs/quota/dquot.c
> +++ b/fs/quota/dquot.c
> @@ -2983,13 +2983,9 @@ static int __init dquot_init(void)
>
> /* Find power-of-two hlist_heads which can fit into allocation */
> nr_hash = (1UL << order) * PAGE_SIZE / sizeof(struct hlist_head);
> - dq_hash_bits = 0;
> - do {
> - dq_hash_bits++;
> - } while (nr_hash >> dq_hash_bits);
> - dq_hash_bits--;
> + nr_hash = rounddown_pow_of_two(nr_hash);
> + dq_hash_bits = ilog2(nr_hash);
>
> - nr_hash = 1UL << dq_hash_bits;
Why not just:
dq_hash_bits = ilog2(nr_hash);
nr_hash = 1UL << dq_hash_bits;
That way we need to compute fls() only once...
Honza
--
Jan Kara <jack@suse.com>
SUSE Labs, CR
next prev parent reply other threads:[~2019-09-23 10:02 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-09-21 1:56 [PATCH] quota: code cleanup for hash bits calculation Chengguang Xu
2019-09-23 10:02 ` Jan Kara [this message]
2019-09-23 13:36 ` admin
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=20190923100259.GD20367@quack2.suse.cz \
--to=jack@suse.cz \
--cc=cgxu519@zoho.com.cn \
--cc=jack@suse.com \
--cc=linux-kernel@vger.kernel.org \
/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