diff options
author | Wanpeng Li <liwanp@linux.vnet.ibm.com> | 2013-04-02 10:46:13 +0800 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2013-04-02 12:49:51 -0700 |
commit | bdcde42d74a12e170971038671a80ef00603ae4e (patch) | |
tree | b514a0090b7165c69754c5ecc64ebb90847a1782 /drivers/staging/zcache | |
parent | 6fd3d05a8f4b0979960a3d90b0f9ea3c6cefe282 (diff) |
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>
Diffstat (limited to 'drivers/staging/zcache')
-rw-r--r-- | drivers/staging/zcache/zcache-main.c | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/drivers/staging/zcache/zcache-main.c b/drivers/staging/zcache/zcache-main.c index fb699df3071..274a48e94cf 100644 --- a/drivers/staging/zcache/zcache-main.c +++ b/drivers/staging/zcache/zcache-main.c @@ -277,6 +277,33 @@ 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 *p) +{ + void *user_mem; + struct page *page = (struct page *)p; + + 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, |