[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-id: <54080606.3050106@samsung.com>
Date: Thu, 04 Sep 2014 15:26:14 +0900
From: Heesub Shin <heesub.shin@...sung.com>
To: Minchan Kim <minchan@...nel.org>,
Andrew Morton <akpm@...ux-foundation.org>
Cc: linux-kernel@...r.kernel.org, linux-mm@...ck.org,
Hugh Dickins <hughd@...gle.com>, Shaohua Li <shli@...nel.org>,
Jerome Marchand <jmarchan@...hat.com>,
Sergey Senozhatsky <sergey.senozhatsky@...il.com>,
Dan Streetman <ddstreet@...e.org>,
Nitin Gupta <ngupta@...are.org>,
Luigi Semenzato <semenzato@...gle.com>
Subject: Re: [RFC 3/3] zram: add swap_get_free hint
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 <minchan@...nel.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 majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists