public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Xiaotian Feng <dfeng@redhat.com>
To: axboe@kernel.dk
Cc: linux-kernel@vger.kernel.org, Xiaotian Feng <dfeng@redhat.com>
Subject: [RFC PATCH] block: slightly optimize blkdev_ioctl BLKRA{SET,GET}
Date: Tue, 14 Jul 2009 19:59:54 +0800	[thread overview]
Message-ID: <1247572794-24107-1-git-send-email-dfeng@redhat.com> (raw)

Slightly optimize blkdev_ioctl by using shift instead of multiply
and divide.

Signed-off-by: Xiaotian Feng <dfeng@redhat.com>
---
 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


             reply	other threads:[~2009-07-14 11:59 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-07-14 11:59 Xiaotian Feng [this message]
2009-07-14 13:48 ` [RFC PATCH] block: slightly optimize blkdev_ioctl BLKRA{SET,GET} Américo Wang
2009-07-14 14:08 ` Johannes Weiner
     [not found] <1247572395-24021-1-git-send-email-dfeng@redhat.com>
2009-07-14 14:12 ` Xiaotian Feng
2009-07-17  5:03   ` Tejun Heo

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1247572794-24107-1-git-send-email-dfeng@redhat.com \
    --to=dfeng@redhat.com \
    --cc=axboe@kernel.dk \
    --cc=linux-kernel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox