aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorkaram.lee <karam.lee@lge.com>2014-12-12 19:56:53 -0500
committerLinus Torvalds <torvalds@linux-foundation.org>2014-12-13 15:42:50 -0500
commit8c7f01025f7becd577bed9af93f974fc6798c5a3 (patch)
treed20d965db5436a6a6418a8e918403cab43806ebf
parent54850e73e86e3bc092680d1bdb84eb322f982ab1 (diff)
zram: implement rw_page operation of zram
This patch implements rw_page operation for zram block device. I implemented the feature in zram and tested it. Test bed was the G2, LG electronic mobile device, whtich has msm8974 processor and 2GB memory. With a memory allocation test program consuming memory, the system generates swap. Operating time of swap_write_page() was measured. -------------------------------------------------- | | operating time | improvement | | | (20 runs average) | | -------------------------------------------------- |with patch | 1061.15 us | +2.4% | -------------------------------------------------- |without patch| 1087.35 us | | -------------------------------------------------- Each test(with paged_io,with BIO) result set shows normal distribution and has equal variance. I mean the two values are valid result to compare. I can say operation with paged I/O(without BIO) is faster 2.4% with confidence level 95%. [minchan@kernel.org: make rw_page opeartion return 0] [minchan@kernel.org: rely on the bi_end_io for zram_rw_page fails] [sergey.senozhatsky@gmail.com: code cleanup] [minchan@kernel.org: add comment] Signed-off-by: karam.lee <karam.lee@lge.com> Acked-by: Minchan Kim <minchan@kernel.org> Acked-by: Jerome Marchand <jmarchan@redhat.com> Cc: Matthew Wilcox <matthew.r.wilcox@intel.com> Cc: Nitin Gupta <ngupta@vflare.org> Cc: <seungho1.park@lge.com> Signed-off-by: Minchan Kim <minchan@kernel.org> Signed-off-by: Sergey Senozhatsky <sergey.senozhatsky@gmail.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
-rw-r--r--drivers/block/zram/zram_drv.c44
1 files changed, 44 insertions, 0 deletions
diff --git a/drivers/block/zram/zram_drv.c b/drivers/block/zram/zram_drv.c
index 98af4aae2618..976eab6f35b9 100644
--- a/drivers/block/zram/zram_drv.c
+++ b/drivers/block/zram/zram_drv.c
@@ -945,8 +945,52 @@ static void zram_slot_free_notify(struct block_device *bdev,
945 atomic64_inc(&zram->stats.notify_free); 945 atomic64_inc(&zram->stats.notify_free);
946} 946}
947 947
948static int zram_rw_page(struct block_device *bdev, sector_t sector,
949 struct page *page, int rw)
950{
951 int offset, err;
952 u32 index;
953 struct zram *zram;
954 struct bio_vec bv;
955
956 zram = bdev->bd_disk->private_data;
957 if (!valid_io_request(zram, sector, PAGE_SIZE)) {
958 atomic64_inc(&zram->stats.invalid_io);
959 return -EINVAL;
960 }
961
962 down_read(&zram->init_lock);
963 if (unlikely(!init_done(zram))) {
964 err = -EIO;
965 goto out_unlock;
966 }
967
968 index = sector >> SECTORS_PER_PAGE_SHIFT;
969 offset = sector & (SECTORS_PER_PAGE - 1) << SECTOR_SHIFT;
970
971 bv.bv_page = page;
972 bv.bv_len = PAGE_SIZE;
973 bv.bv_offset = 0;
974
975 err = zram_bvec_rw(zram, &bv, index, offset, rw);
976out_unlock:
977 up_read(&zram->init_lock);
978 /*
979 * If I/O fails, just return error(ie, non-zero) without
980 * calling page_endio.
981 * It causes resubmit the I/O with bio request by upper functions
982 * of rw_page(e.g., swap_readpage, __swap_writepage) and
983 * bio->bi_end_io does things to handle the error
984 * (e.g., SetPageError, set_page_dirty and extra works).
985 */
986 if (err == 0)
987 page_endio(page, rw, 0);
988 return err;
989}
990
948static const struct block_device_operations zram_devops = { 991static const struct block_device_operations zram_devops = {
949 .swap_slot_free_notify = zram_slot_free_notify, 992 .swap_slot_free_notify = zram_slot_free_notify,
993 .rw_page = zram_rw_page,
950 .owner = THIS_MODULE 994 .owner = THIS_MODULE
951}; 995};
952 996