linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2] quota: code cleanup for hash bits calculation
@ 2019-09-23 13:52 Chengguang Xu
  2019-10-04  8:12 ` Jan Kara
  0 siblings, 1 reply; 2+ messages in thread
From: Chengguang Xu @ 2019-09-23 13:52 UTC (permalink / raw)
  To: jack; +Cc: linux-kernel, Chengguang Xu

Code cleanup for hash bits calculation by
calling ilog2().

Signed-off-by: Chengguang Xu <cgxu519@zoho.com.cn>
---
v1->v2:
- Calculate hash bits by directly calling ilog2().

 fs/quota/dquot.c | 6 +-----
 1 file changed, 1 insertion(+), 5 deletions(-)

diff --git a/fs/quota/dquot.c b/fs/quota/dquot.c
index 6e826b454082..fde1b94ea587 100644
--- a/fs/quota/dquot.c
+++ b/fs/quota/dquot.c
@@ -2983,11 +2983,7 @@ 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--;
+	dq_hash_bits = ilog2(nr_hash);
 
 	nr_hash = 1UL << dq_hash_bits;
 	dq_hash_mask = nr_hash - 1;
-- 
2.21.0




^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH v2] quota: code cleanup for hash bits calculation
  2019-09-23 13:52 [PATCH v2] quota: code cleanup for hash bits calculation Chengguang Xu
@ 2019-10-04  8:12 ` Jan Kara
  0 siblings, 0 replies; 2+ messages in thread
From: Jan Kara @ 2019-10-04  8:12 UTC (permalink / raw)
  To: Chengguang Xu; +Cc: Jan Kara, linux-kernel

On Mon 23-09-19 21:52:23, Chengguang Xu wrote:
> Code cleanup for hash bits calculation by
> calling ilog2().
> 
> Signed-off-by: Chengguang Xu <cgxu519@zoho.com.cn>

Thanks! I've queued your patch.

								Honza

> ---
> v1->v2:
> - Calculate hash bits by directly calling ilog2().
> 
>  fs/quota/dquot.c | 6 +-----
>  1 file changed, 1 insertion(+), 5 deletions(-)
> 
> diff --git a/fs/quota/dquot.c b/fs/quota/dquot.c
> index 6e826b454082..fde1b94ea587 100644
> --- a/fs/quota/dquot.c
> +++ b/fs/quota/dquot.c
> @@ -2983,11 +2983,7 @@ 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--;
> +	dq_hash_bits = ilog2(nr_hash);
>  
>  	nr_hash = 1UL << dq_hash_bits;
>  	dq_hash_mask = nr_hash - 1;
> -- 
> 2.21.0
> 
> 
> 
> 
-- 
Jan Kara <jack@suse.com>
SUSE Labs, CR

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2019-10-07 10:16 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-09-23 13:52 [PATCH v2] quota: code cleanup for hash bits calculation Chengguang Xu
2019-10-04  8:12 ` Jan Kara

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).