emm: block: introduce basic flags for ramdisk swap optimization
Upstream: alternative Currently only for zram and brd, like a stronger version of QUEUE_FLAG_SYNCHRONOUS, which also indicates that the device requires runtime page allocation, and may even get accounted. Signed-off-by: Kairui Song <kasong@tencent.com>
This commit is contained in:
parent
c24b2ddf1f
commit
0b8736a8e3
|
@ -360,6 +360,9 @@ static int brd_alloc(int i)
|
|||
blk_queue_flag_set(QUEUE_FLAG_NONROT, disk->queue);
|
||||
blk_queue_flag_set(QUEUE_FLAG_SYNCHRONOUS, disk->queue);
|
||||
blk_queue_flag_set(QUEUE_FLAG_NOWAIT, disk->queue);
|
||||
#ifdef CONFIG_EMM_RAMDISK_SWAP
|
||||
blk_queue_flag_set(QUEUE_FLAG_RAMDISK, disk->queue);
|
||||
#endif
|
||||
err = add_disk(disk);
|
||||
if (err)
|
||||
goto out_cleanup_disk;
|
||||
|
|
|
@ -2220,6 +2220,9 @@ static int zram_add(void)
|
|||
/* zram devices sort of resembles non-rotational disks */
|
||||
blk_queue_flag_set(QUEUE_FLAG_NONROT, zram->disk->queue);
|
||||
blk_queue_flag_set(QUEUE_FLAG_SYNCHRONOUS, zram->disk->queue);
|
||||
#ifdef CONFIG_EMM_RAMDISK_SWAP
|
||||
blk_queue_flag_set(QUEUE_FLAG_RAMDISK, zram->disk->queue);
|
||||
#endif
|
||||
|
||||
/*
|
||||
* To ensure that we always get PAGE_SIZE aligned
|
||||
|
|
|
@ -573,6 +573,9 @@ struct request_queue {
|
|||
#define QUEUE_FLAG_NOWAIT 29 /* device supports NOWAIT */
|
||||
#define QUEUE_FLAG_SQ_SCHED 30 /* single queue style io dispatch */
|
||||
#define QUEUE_FLAG_SKIP_TAGSET_QUIESCE 31 /* quiesce_tagset skip the queue*/
|
||||
#ifdef CONFIG_EMM_RAMDISK_SWAP
|
||||
#define QUEUE_FLAG_RAMDISK 32 /* ramdisk requires runtime page alloc */
|
||||
#endif
|
||||
|
||||
#define QUEUE_FLAG_MQ_DEFAULT ((1UL << QUEUE_FLAG_IO_STAT) | \
|
||||
(1UL << QUEUE_FLAG_SAME_COMP) | \
|
||||
|
@ -1564,4 +1567,15 @@ struct io_comp_batch {
|
|||
|
||||
#define DEFINE_IO_COMP_BATCH(name) struct io_comp_batch name = { }
|
||||
|
||||
#ifdef CONFIG_EMM_RAMDISK_SWAP
|
||||
/*
|
||||
* Check if a bdev is ramdisk based
|
||||
*/
|
||||
static inline bool bdev_ramdisk(struct block_device *bdev)
|
||||
{
|
||||
return test_bit(QUEUE_FLAG_RAMDISK,
|
||||
&bdev_get_queue(bdev)->queue_flags);
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* _LINUX_BLKDEV_H */
|
||||
|
|
11
mm/Kconfig
11
mm/Kconfig
|
@ -1293,4 +1293,15 @@ config EMM_FORCE_SWAPPINESS
|
|||
|
||||
If unsure say N.
|
||||
|
||||
config EMM_RAMDISK_SWAP
|
||||
bool "Tune ramdisks based swaps"
|
||||
depends on ENHANCED_MM
|
||||
depends on SWAP
|
||||
default n
|
||||
help
|
||||
This option will enable a few tunes for ramdisk based swaps,
|
||||
and make swap work better with memcg bounded ramdisk.
|
||||
|
||||
If unsure say N.
|
||||
|
||||
endmenu
|
||||
|
|
Loading…
Reference in New Issue