summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorWanpeng Li <liwanp@linux.vnet.ibm.com>2013-03-15 03:34:16 +0100
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2013-03-19 01:24:35 +0100
commitdcb4e2d9bb4e3b6ad05bc513a237a87e46952341 (patch)
treead6765b07229c7246cd397bcb0790fafcc2c3e9c
parentzcache/TODO: Update on two items. (diff)
downloadlinux-dcb4e2d9bb4e3b6ad05bc513a237a87e46952341.tar.xz
linux-dcb4e2d9bb4e3b6ad05bc513a237a87e46952341.zip
staging: zcache: introduce zero filled pages handler
Introduce zero-filled pages handler to capture and handle zero pages. Acked-by: Dan Magenheimer <dan.magenheimer@oracle.com> Signed-off-by: Wanpeng Li <liwanp@linux.vnet.ibm.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
-rw-r--r--drivers/staging/zcache/zcache-main.c26
1 files changed, 26 insertions, 0 deletions
diff --git a/drivers/staging/zcache/zcache-main.c b/drivers/staging/zcache/zcache-main.c
index 7a6dd966931b..86ead8d96796 100644
--- a/drivers/staging/zcache/zcache-main.c
+++ b/drivers/staging/zcache/zcache-main.c
@@ -277,6 +277,32 @@ static void zcache_obj_free(struct tmem_obj *obj, struct tmem_pool *pool)
kmem_cache_free(zcache_obj_cache, obj);
}
+static bool page_is_zero_filled(void *ptr)
+{
+ unsigned int pos;
+ unsigned long *page;
+
+ page = (unsigned long *)ptr;
+
+ for (pos = 0; pos < PAGE_SIZE / sizeof(*page); pos++) {
+ if (page[pos])
+ return false;
+ }
+
+ return true;
+}
+
+static void handle_zero_filled_page(void *page)
+{
+ void *user_mem;
+
+ user_mem = kmap_atomic(page);
+ memset(user_mem, 0, PAGE_SIZE);
+ kunmap_atomic(user_mem);
+
+ flush_dcache_page(page);
+}
+
static struct tmem_hostops zcache_hostops = {
.obj_alloc = zcache_obj_alloc,
.obj_free = zcache_obj_free,