Introduce zero-filled pages handler to capture and handle zero pages.

Acked-by: Dan Magenheimer <dan.magenhei...@oracle.com>
Signed-off-by: Wanpeng Li <liw...@linux.vnet.ibm.com>
---
 drivers/staging/zcache/zcache-main.c |   26 ++++++++++++++++++++++++++
 1 files changed, 26 insertions(+), 0 deletions(-)

diff --git a/drivers/staging/zcache/zcache-main.c 
b/drivers/staging/zcache/zcache-main.c
index 328898e..d73dd4b 100644
--- a/drivers/staging/zcache/zcache-main.c
+++ b/drivers/staging/zcache/zcache-main.c
@@ -460,6 +460,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,
-- 
1.7.7.6

--
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/

Reply via email to