Skip to content

Commit dcb4e2d

Browse files
Wanpeng Ligregkh
authored andcommitted
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>
1 parent ad3c025 commit dcb4e2d

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

drivers/staging/zcache/zcache-main.c

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -277,6 +277,32 @@ static void zcache_obj_free(struct tmem_obj *obj, struct tmem_pool *pool)
277277
kmem_cache_free(zcache_obj_cache, obj);
278278
}
279279

280+
static bool page_is_zero_filled(void *ptr)
281+
{
282+
unsigned int pos;
283+
unsigned long *page;
284+
285+
page = (unsigned long *)ptr;
286+
287+
for (pos = 0; pos < PAGE_SIZE / sizeof(*page); pos++) {
288+
if (page[pos])
289+
return false;
290+
}
291+
292+
return true;
293+
}
294+
295+
static void handle_zero_filled_page(void *page)
296+
{
297+
void *user_mem;
298+
299+
user_mem = kmap_atomic(page);
300+
memset(user_mem, 0, PAGE_SIZE);
301+
kunmap_atomic(user_mem);
302+
303+
flush_dcache_page(page);
304+
}
305+
280306
static struct tmem_hostops zcache_hostops = {
281307
.obj_alloc = zcache_obj_alloc,
282308
.obj_free = zcache_obj_free,

0 commit comments

Comments
 (0)