From: Minchan Kim <minchan@kernel.org>
To: Andrew Morton <akpm@linux-foundation.org>
Cc: linux-kernel@vger.kernel.org, linux-mm@kvack.org,
Hugh Dickins <hughd@google.com>, Shaohua Li <shli@kernel.org>,
Jerome Marchand <jmarchan@redhat.com>,
Sergey Senozhatsky <sergey.senozhatsky@gmail.com>,
Dan Streetman <ddstreet@ieee.org>,
Nitin Gupta <ngupta@vflare.org>,
Luigi Semenzato <semenzato@google.com>,
Minchan Kim <minchan@kernel.org>
Subject: [RFC 3/3] zram: add swap_get_free hint
Date: Thu, 4 Sep 2014 10:39:46 +0900 [thread overview]
Message-ID: <1409794786-10951-4-git-send-email-minchan@kernel.org> (raw)
In-Reply-To: <1409794786-10951-1-git-send-email-minchan@kernel.org>
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@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);
+
+ 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;
}
--
2.0.0
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
next prev parent reply other threads:[~2014-09-04 1:38 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-09-04 1:39 [RFC 0/3] make vm aware of zram-swap Minchan Kim
2014-09-04 1:39 ` [RFC 1/3] zram: generalize swap_slot_free_notify Minchan Kim
2014-09-04 1:39 ` [RFC 2/3] mm: add swap_get_free hint for zram Minchan Kim
2014-09-13 19:01 ` Dan Streetman
2014-09-15 0:30 ` Minchan Kim
2014-09-15 14:53 ` Dan Streetman
2014-09-16 0:33 ` Minchan Kim
2014-09-16 15:09 ` Dan Streetman
2014-09-17 7:14 ` Minchan Kim
2014-09-04 1:39 ` Minchan Kim [this message]
2014-09-04 6:26 ` [RFC 3/3] zram: add swap_get_free hint Heesub Shin
2014-09-04 23:59 ` Minchan Kim
2014-09-13 19:39 ` Dan Streetman
2014-09-15 0:57 ` Minchan Kim
2014-09-15 16:00 ` Dan Streetman
2014-09-16 1:21 ` Minchan Kim
2014-09-16 15:58 ` Dan Streetman
2014-09-17 7:44 ` Minchan Kim
2014-09-17 16:28 ` Dan Streetman
2014-09-19 6:14 ` Minchan Kim
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1409794786-10951-4-git-send-email-minchan@kernel.org \
--to=minchan@kernel.org \
--cc=akpm@linux-foundation.org \
--cc=ddstreet@ieee.org \
--cc=hughd@google.com \
--cc=jmarchan@redhat.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=ngupta@vflare.org \
--cc=semenzato@google.com \
--cc=sergey.senozhatsky@gmail.com \
--cc=shli@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).