# Re: \[PATCH\] buffer: a small optimization in grow\_buffers

- From: Al Viro \<viro@zeniv.linux.org.uk\>
- Date: 2021-03-22 15:37:17 
- List: linux-block
- Page: https://ratatoskr.run/linux-block/2021/03/202264
- Thread: https://ratatoskr.run/linux-fsdevel/2021/03/202240/t.md

```text
On Mon, Mar 22, 2021 at 10:05:05AM -0400, Mikulas Patocka wrote:
> This patch replaces a loop with a "tzcnt" instruction.
> 
> Signed-off-by: Mikulas Patocka <mpatocka@redhat.com>
> 
> Index: linux-2.6/fs/buffer.c
> ===================================================================
> --- linux-2.6.orig/fs/buffer.c
> +++ linux-2.6/fs/buffer.c
> @@ -1020,11 +1020,7 @@ grow_buffers(struct block_device *bdev,
>  	pgoff_t index;
>  	int sizebits;
>  
> -	sizebits = -1;
> -	do {
> -		sizebits++;
> -	} while ((size << sizebits) < PAGE_SIZE);
> -
> +	sizebits = PAGE_SHIFT - __ffs(size);
>  	index = block >> sizebits;
>  
>  	/*

Applied.
```
