Re: [RFC PATCH] block: slightly optimize blkdev_ioctl BLKRA{SET,GET}

From: AmÃrico Wang
Date: Tue Jul 14 2009 - 09:48:34 EST


On Tue, Jul 14, 2009 at 7:59 PM, Xiaotian Feng<dfeng@xxxxxxxxxx> wrote:
> Slightly optimize blkdev_ioctl by using shift instead of multiply
> and divide.

Not necessary, I believe gcc can do this by itself.

Have you checked its asm code?

>
> Signed-off-by: Xiaotian Feng <dfeng@xxxxxxxxxx>
> ---
> Âblock/ioctl.c | Â Â4 ++--
> Â1 files changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/block/ioctl.c b/block/ioctl.c
> index 500e4c7..f8c7362 100644
> --- a/block/ioctl.c
> +++ b/block/ioctl.c
> @@ -305,7 +305,7 @@ int blkdev_ioctl(struct block_device *bdev, fmode_t mode, unsigned cmd,
> Â Â Â Â Â Â Â Âbdi = blk_get_backing_dev_info(bdev);
> Â Â Â Â Â Â Â Âif (bdi == NULL)
> Â Â Â Â Â Â Â Â Â Â Â Âreturn -ENOTTY;
> - Â Â Â Â Â Â Â return put_long(arg, (bdi->ra_pages * PAGE_CACHE_SIZE) / 512);
> + Â Â Â Â Â Â Â return put_long(arg, bdi->ra_pages << (PAGE_CACHE_SHIFT - 9));
> Â Â Â Âcase BLKROGET:
> Â Â Â Â Â Â Â Âreturn put_int(arg, bdev_read_only(bdev) != 0);
> Â Â Â Âcase BLKBSZGET: /* get the logical block size (cf. BLKSSZGET) */
> @@ -321,7 +321,7 @@ int blkdev_ioctl(struct block_device *bdev, fmode_t mode, unsigned cmd,
> Â Â Â Â Â Â Â Âbdi = blk_get_backing_dev_info(bdev);
> Â Â Â Â Â Â Â Âif (bdi == NULL)
> Â Â Â Â Â Â Â Â Â Â Â Âreturn -ENOTTY;
> - Â Â Â Â Â Â Â bdi->ra_pages = (arg * 512) / PAGE_CACHE_SIZE;
> + Â Â Â Â Â Â Â bdi->ra_pages = arg >> (PAGE_CACHE_SHIFT - 9);
> Â Â Â Â Â Â Â Âreturn 0;
> Â Â Â Âcase BLKBSZSET:
> Â Â Â Â Â Â Â Â/* set the logical block size */
> --
> 1.6.2.5
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
> the body of a message to majordomo@xxxxxxxxxxxxxxx
> More majordomo info at Âhttp://vger.kernel.org/majordomo-info.html
> Please read the FAQ at Âhttp://www.tux.org/lkml/
>
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/