* [PATCH] linux/blkdev.h: Use ilog2() directly in blksize_bits()
@ 2020-05-23 15:50 Kaitao Cheng
2020-05-23 17:07 ` Jens Axboe
2020-05-23 18:33 ` Bart Van Assche
0 siblings, 2 replies; 4+ messages in thread
From: Kaitao Cheng @ 2020-05-23 15:50 UTC (permalink / raw)
To: axboe
Cc: damien.lemoal, bvanassche, ming.lei, martin.petersen, satyat,
chaitanya.kulkarni, houtao1, asml.silence, ajay.joshi,
linux-kernel, songmuchun, Kaitao Cheng
blksize_bits() can be achieved through ilog2(), and ilog2() is
more efficient.
Signed-off-by: Kaitao Cheng <pilgrimtao@gmail.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
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH] linux/blkdev.h: Use ilog2() directly in blksize_bits()
2020-05-23 15:50 [PATCH] linux/blkdev.h: Use ilog2() directly in blksize_bits() Kaitao Cheng
@ 2020-05-23 17:07 ` Jens Axboe
2020-05-23 18:33 ` Bart Van Assche
1 sibling, 0 replies; 4+ messages in thread
From: Jens Axboe @ 2020-05-23 17:07 UTC (permalink / raw)
To: Kaitao Cheng
Cc: damien.lemoal, bvanassche, ming.lei, martin.petersen, satyat,
chaitanya.kulkarni, houtao1, asml.silence, ajay.joshi,
linux-kernel, songmuchun
On 5/23/20 9:50 AM, Kaitao Cheng wrote:
> blksize_bits() can be achieved through ilog2(), and ilog2() is
> more efficient.
I like the simplification, but do you have any results to back up
that claim? Is the generated code shorter? Runs faster?
--
Jens Axboe
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] linux/blkdev.h: Use ilog2() directly in blksize_bits()
2020-05-23 15:50 [PATCH] linux/blkdev.h: Use ilog2() directly in blksize_bits() Kaitao Cheng
2020-05-23 17:07 ` Jens Axboe
@ 2020-05-23 18:33 ` Bart Van Assche
2020-05-23 18:50 ` Jens Axboe
1 sibling, 1 reply; 4+ messages in thread
From: Bart Van Assche @ 2020-05-23 18:33 UTC (permalink / raw)
To: Kaitao Cheng, axboe
Cc: damien.lemoal, ming.lei, martin.petersen, satyat,
chaitanya.kulkarni, houtao1, asml.silence, ajay.joshi,
linux-kernel, songmuchun
On 2020-05-23 08:50, Kaitao Cheng wrote:
> blksize_bits() can be achieved through ilog2(), and ilog2() is
> more efficient.
If Jens agrees, how about removing the blksize_bits() function entirely
and to make all callers use ilog2() instead of blksize_bits()?
Thanks,
Bart.
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] linux/blkdev.h: Use ilog2() directly in blksize_bits()
2020-05-23 18:33 ` Bart Van Assche
@ 2020-05-23 18:50 ` Jens Axboe
0 siblings, 0 replies; 4+ messages in thread
From: Jens Axboe @ 2020-05-23 18:50 UTC (permalink / raw)
To: Bart Van Assche, Kaitao Cheng
Cc: damien.lemoal, ming.lei, martin.petersen, satyat,
chaitanya.kulkarni, houtao1, asml.silence, ajay.joshi,
linux-kernel, songmuchun
On 5/23/20 12:33 PM, Bart Van Assche wrote:
> On 2020-05-23 08:50, Kaitao Cheng wrote:
>> blksize_bits() can be achieved through ilog2(), and ilog2() is
>> more efficient.
>
> If Jens agrees, how about removing the blksize_bits() function entirely
> and to make all callers use ilog2() instead of blksize_bits()?
Yeah, if we are going this path, then let's just kill the function
completely.
--
Jens Axboe
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2020-05-23 18:50 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-05-23 15:50 [PATCH] linux/blkdev.h: Use ilog2() directly in blksize_bits() Kaitao Cheng
2020-05-23 17:07 ` Jens Axboe
2020-05-23 18:33 ` Bart Van Assche
2020-05-23 18:50 ` Jens Axboe
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).