提交 bdcde42d 编写于 作者: W Wanpeng Li 提交者: Greg Kroah-Hartman

staging: zcache: introduce zero-filled pages handler

Introduce zero-filled pages handler to capture and handle zero pages.
Acked-by: NDan Magenheimer <dan.magenheimer@oracle.com>
Signed-off-by: NWanpeng Li <liwanp@linux.vnet.ibm.com>
Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
上级 6fd3d05a
......@@ -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,
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册