lkml.org 
[lkml]   [2019]   [Sep]   [23]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCH v2] quota: code cleanup for hash bits calculation
Date
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


\
 
 \ /
  Last update: 2019-09-23 15:53    [W:1.271 / U:0.016 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site