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  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Date:   Sat, 23 May 2020 23:50:48 +0800
From:   Kaitao Cheng <pilgrimtao@...il.com>
To:     axboe@...nel.dk
Cc:     damien.lemoal@....com, bvanassche@....org, ming.lei@...hat.com,
        martin.petersen@...cle.com, satyat@...gle.com,
        chaitanya.kulkarni@....com, houtao1@...wei.com,
        asml.silence@...il.com, ajay.joshi@....com,
        linux-kernel@...r.kernel.org, songmuchun@...edance.com,
        Kaitao Cheng <pilgrimtao@...il.com>
Subject: [PATCH] linux/blkdev.h: Use ilog2() directly in blksize_bits()

blksize_bits() can be achieved through ilog2(), and ilog2() is
more efficient.

Signed-off-by: Kaitao Cheng <pilgrimtao@...il.com>
---
 include/linux/blkdev.h | 7 +------
 1 file changed, 1 insertion(+), 6 deletions(-)

diff --git a/include/linux/blkdev.h b/include/linux/blkdev.h
index 2b33166b9daf..cce96abac4d4 100644
--- a/include/linux/blkdev.h
+++ b/include/linux/blkdev.h
@@ -1505,12 +1505,7 @@ static inline int blk_rq_aligned(struct request_queue *q, unsigned long addr,
 /* assumes size > 256 */
 static inline unsigned int blksize_bits(unsigned int size)
 {
-	unsigned int bits = 8;
-	do {
-		bits++;
-		size >>= 1;
-	} while (size > 256);
-	return bits;
+	return ilog2(size);
 }
 
 static inline unsigned int block_size(struct block_device *bdev)
-- 
2.20.1

Powered by blists - more mailing lists