summaryrefslogtreecommitdiffstats
path: root/drivers/block/zram
diff options
context:
space:
mode:
authorMinchan Kim <minchan@kernel.org>2017-11-15 20:32:56 -0500
committerLinus Torvalds <torvalds@linux-foundation.org>2017-11-15 21:21:02 -0500
commite447a0151f7ce8dd884fea48279274bd64434c29 (patch)
tree773c942812f56fc421612718ac78ede6876e4519 /drivers/block/zram
parent41710443f790b5f7f5305eba99dacce88e259f4c (diff)
zram: set BDI_CAP_STABLE_WRITES once
With fast swap storage, the platform wants to use swap more aggressively and swap-in is crucial to application latency. The rw_page() based synchronous devices like zram, pmem and btt are such fast storage. When I profile swapin performance with zram lz4 decompress test, S/W overhead is more than 70%. Maybe, it would be bigger in nvdimm. This patchset reduces swap-in latency by skipping swapcache if the swap device is a synchronous device like a rw_page() based device. It enhances by 45% my swapin test (5G sequential swapin, no readahead) from 2.41sec to 1.64sec. This patch (of 4): Commit 19b7ccf8651d ("block: get rid of blk_integrity_revalidate()") fixed a weird thing (i.e., reset BDI_CAP_STABLE_WRITES flag unconditionally whenever revalidat_disk is called) so zram doesn't need to reset the flag any more when revalidating the bdev. Instead, set the flag just once when the zram device is created. It shouldn't change any behavior. Link: http://lkml.kernel.org/r/1505886205-9671-2-git-send-email-minchan@kernel.org Signed-off-by: Minchan Kim <minchan@kernel.org> Reviewed-by: Sergey Senozhatsky <sergey.senozhatsky@gmail.com> Cc: Ilya Dryomov <idryomov@gmail.com> Cc: Christoph Hellwig <hch@lst.de> Cc: Dan Williams <dan.j.williams@intel.com> Cc: Ross Zwisler <ross.zwisler@linux.intel.com> Cc: Jens Axboe <axboe@kernel.dk> Cc: Hugh Dickins <hughd@google.com> Cc: Huang Ying <ying.huang@intel.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'drivers/block/zram')
-rw-r--r--drivers/block/zram/zram_drv.c16
1 files changed, 6 insertions, 10 deletions
diff --git a/drivers/block/zram/zram_drv.c b/drivers/block/zram/zram_drv.c
index f149d3e61234..d95bb8ce5092 100644
--- a/drivers/block/zram/zram_drv.c
+++ b/drivers/block/zram/zram_drv.c
@@ -122,14 +122,6 @@ static inline bool is_partial_io(struct bio_vec *bvec)
122} 122}
123#endif 123#endif
124 124
125static void zram_revalidate_disk(struct zram *zram)
126{
127 revalidate_disk(zram->disk);
128 /* revalidate_disk reset the BDI_CAP_STABLE_WRITES so set again */
129 zram->disk->queue->backing_dev_info->capabilities |=
130 BDI_CAP_STABLE_WRITES;
131}
132
133/* 125/*
134 * Check if request is within bounds and aligned on zram logical blocks. 126 * Check if request is within bounds and aligned on zram logical blocks.
135 */ 127 */
@@ -1373,7 +1365,8 @@ static ssize_t disksize_store(struct device *dev,
1373 zram->comp = comp; 1365 zram->comp = comp;
1374 zram->disksize = disksize; 1366 zram->disksize = disksize;
1375 set_capacity(zram->disk, zram->disksize >> SECTOR_SHIFT); 1367 set_capacity(zram->disk, zram->disksize >> SECTOR_SHIFT);
1376 zram_revalidate_disk(zram); 1368
1369 revalidate_disk(zram->disk);
1377 up_write(&zram->init_lock); 1370 up_write(&zram->init_lock);
1378 1371
1379 return len; 1372 return len;
@@ -1420,7 +1413,7 @@ static ssize_t reset_store(struct device *dev,
1420 /* Make sure all the pending I/O are finished */ 1413 /* Make sure all the pending I/O are finished */
1421 fsync_bdev(bdev); 1414 fsync_bdev(bdev);
1422 zram_reset_device(zram); 1415 zram_reset_device(zram);
1423 zram_revalidate_disk(zram); 1416 revalidate_disk(zram->disk);
1424 bdput(bdev); 1417 bdput(bdev);
1425 1418
1426 mutex_lock(&bdev->bd_mutex); 1419 mutex_lock(&bdev->bd_mutex);
@@ -1539,6 +1532,7 @@ static int zram_add(void)
1539 /* zram devices sort of resembles non-rotational disks */ 1532 /* zram devices sort of resembles non-rotational disks */
1540 queue_flag_set_unlocked(QUEUE_FLAG_NONROT, zram->disk->queue); 1533 queue_flag_set_unlocked(QUEUE_FLAG_NONROT, zram->disk->queue);
1541 queue_flag_clear_unlocked(QUEUE_FLAG_ADD_RANDOM, zram->disk->queue); 1534 queue_flag_clear_unlocked(QUEUE_FLAG_ADD_RANDOM, zram->disk->queue);
1535
1542 /* 1536 /*
1543 * To ensure that we always get PAGE_SIZE aligned 1537 * To ensure that we always get PAGE_SIZE aligned
1544 * and n*PAGE_SIZED sized I/O requests. 1538 * and n*PAGE_SIZED sized I/O requests.
@@ -1563,6 +1557,8 @@ static int zram_add(void)
1563 if (ZRAM_LOGICAL_BLOCK_SIZE == PAGE_SIZE) 1557 if (ZRAM_LOGICAL_BLOCK_SIZE == PAGE_SIZE)
1564 blk_queue_max_write_zeroes_sectors(zram->disk->queue, UINT_MAX); 1558 blk_queue_max_write_zeroes_sectors(zram->disk->queue, UINT_MAX);
1565 1559
1560 zram->disk->queue->backing_dev_info->capabilities |=
1561 BDI_CAP_STABLE_WRITES;
1566 add_disk(zram->disk); 1562 add_disk(zram->disk);
1567 1563
1568 ret = sysfs_create_group(&disk_to_dev(zram->disk)->kobj, 1564 ret = sysfs_create_group(&disk_to_dev(zram->disk)->kobj,