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  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:   Fri, 29 May 2020 15:27:30 -0700
From:   Bart Van Assche <bvanassche@....org>
To:     Matthew Wilcox <willy@...radead.org>,
        Kaitao Cheng <pilgrimtao@...il.com>
Cc:     axboe@...nel.dk, hch@....de, sth@...ux.ibm.com,
        viro@...iv.linux.org.uk, clm@...com, jaegeuk@...nel.org,
        hch@...radead.org, mark@...heh.com, dhowells@...hat.com,
        balbi@...nel.org, damien.lemoal@....com, 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,
        hoeppner@...ux.ibm.com, heiko.carstens@...ibm.com,
        gor@...ux.ibm.com, borntraeger@...ibm.com,
        linux-s390@...r.kernel.org, sagi@...mberg.me,
        linux-nvme@...ts.infradead.org, gregkh@...uxfoundation.org,
        linux-usb@...r.kernel.org, josef@...icpanda.com, dsterba@...e.com,
        linux-btrfs@...r.kernel.org, chao@...nel.org,
        linux-f2fs-devel@...ts.sourceforge.net, darrick.wong@...cle.com,
        linux-xfs@...r.kernel.org, linux-fsdevel@...r.kernel.org,
        jlbec@...lplan.org, joseph.qi@...ux.alibaba.com,
        ocfs2-devel@....oracle.com, deepa.kernel@...il.com
Subject: Re: [PATCH v2] blkdev: Replace blksize_bits() with ilog2()

On 2020-05-29 13:27, Matthew Wilcox wrote:
> On Fri, May 29, 2020 at 10:11:00PM +0800, Kaitao Cheng wrote:
>> There is a function named ilog2() exist which can replace blksize.
>> The generated code will be shorter and more efficient on some
>> architecture, such as arm64. And ilog2() can be optimized according
>> to different architecture.
> 
> We'd get the same benefit from a smaller patch with just:
> 
> --- a/include/linux/blkdev.h
> +++ b/include/linux/blkdev.h
> @@ -1502,15 +1502,9 @@ static inline int blk_rq_aligned(struct request_queue *q, unsigned long addr,
>  	return !(addr & alignment) && !(len & alignment);
>  }
>  
> -/* 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)

Hi Matthew,

I had suggested to change all blksize_bits() calls into ilog2() calls
because I think that a single function to calculate the logarithm base 2
is sufficient.

Thanks,

Bart.


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ