Hello Minchan, First of all, I agree with the overall purpose of your patch set.
On 09/04/2014 10:39 AM, Minchan Kim wrote:
This patch implement SWAP_GET_FREE handler in zram so that VM can know how many zram has freeable space. VM can use it to stop anonymous reclaiming once zram is full. Signed-off-by: Minchan Kim <minc...@kernel.org> --- drivers/block/zram/zram_drv.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/drivers/block/zram/zram_drv.c b/drivers/block/zram/zram_drv.c index 88661d62e46a..8e22b20aa2db 100644 --- a/drivers/block/zram/zram_drv.c +++ b/drivers/block/zram/zram_drv.c @@ -951,6 +951,22 @@ static int zram_slot_free_notify(struct block_device *bdev, return 0; } +static int zram_get_free_pages(struct block_device *bdev, long *free) +{ + struct zram *zram; + struct zram_meta *meta; + + zram = bdev->bd_disk->private_data; + meta = zram->meta; + + if (!zram->limit_pages) + return 1; + + *free = zram->limit_pages - zs_get_total_pages(meta->mem_pool);
Even if 'free' is zero here, there may be free spaces available to store more compressed pages into the zs_pool. I mean calculation above is not quite accurate and wastes memory, but have no better idea for now.
heesub
+ + return 0; +} + static int zram_swap_hint(struct block_device *bdev, unsigned int hint, void *arg) { @@ -958,6 +974,8 @@ static int zram_swap_hint(struct block_device *bdev, if (hint == SWAP_SLOT_FREE) ret = zram_slot_free_notify(bdev, (unsigned long)arg); + else if (hint == SWAP_GET_FREE) + ret = zram_get_free_pages(bdev, arg); return ret; }
-- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/