Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753496Ab3COCfP (ORCPT ); Thu, 14 Mar 2013 22:35:15 -0400 Received: from e23smtp09.au.ibm.com ([202.81.31.142]:50229 "EHLO e23smtp09.au.ibm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753130Ab3COCfL (ORCPT ); Thu, 14 Mar 2013 22:35:11 -0400 From: Wanpeng Li To: Greg Kroah-Hartman , Andrew Morton Cc: Dan Magenheimer , Seth Jennings , Konrad Rzeszutek Wilk , Minchan Kim , linux-mm@kvack.org, linux-kernel@vger.kernel.org, Wanpeng Li Subject: [PATCH v3 1/5] introduce zero filled pages handler Date: Fri, 15 Mar 2013 10:34:16 +0800 Message-Id: <1363314860-22731-2-git-send-email-liwanp@linux.vnet.ibm.com> X-Mailer: git-send-email 1.7.5.4 In-Reply-To: <1363314860-22731-1-git-send-email-liwanp@linux.vnet.ibm.com> References: <1363314860-22731-1-git-send-email-liwanp@linux.vnet.ibm.com> X-Content-Scanned: Fidelis XPS MAILER x-cbid: 13031502-3568-0000-0000-0000034AE702 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1468 Lines: 53 Introduce zero-filled pages handler to capture and handle zero pages. Acked-by: Dan Magenheimer Signed-off-by: Wanpeng Li --- 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 majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/