diff --git a/drivers/block/brd.c b/drivers/block/brd.c index 970bd6ff38c4..090eaa84c3a1 100644 --- a/drivers/block/brd.c +++ b/drivers/block/brd.c @@ -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; diff --git a/drivers/block/zram/zram_drv.c b/drivers/block/zram/zram_drv.c index 06673c6ca255..5f24456bf181 100644 --- a/drivers/block/zram/zram_drv.c +++ b/drivers/block/zram/zram_drv.c @@ -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 diff --git a/include/linux/blkdev.h b/include/linux/blkdev.h index 89e2ff525a56..573332acb081 100644 --- a/include/linux/blkdev.h +++ b/include/linux/blkdev.h @@ -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 */ diff --git a/mm/Kconfig b/mm/Kconfig index 6344c1f943e8..71fb4ca93dc3 100644 --- a/mm/Kconfig +++ b/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