From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from psmtp.com (na3sys010amx129.postini.com [74.125.245.129]) by kanga.kvack.org (Postfix) with SMTP id E66FD6B0006 for ; Thu, 14 Mar 2013 06:09:03 -0400 (EDT) Received: from /spool/local by e23smtp08.au.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Thu, 14 Mar 2013 20:07:02 +1000 Received: from d23relay05.au.ibm.com (d23relay05.au.ibm.com [9.190.235.152]) by d23dlp02.au.ibm.com (Postfix) with ESMTP id 3FB4C2BB0053 for ; Thu, 14 Mar 2013 21:08:55 +1100 (EST) Received: from d23av02.au.ibm.com (d23av02.au.ibm.com [9.190.235.138]) by d23relay05.au.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id r2E9txHw61931568 for ; Thu, 14 Mar 2013 20:56:00 +1100 Received: from d23av02.au.ibm.com (loopback [127.0.0.1]) by d23av02.au.ibm.com (8.14.4/8.13.1/NCO v10.0 AVout) with ESMTP id r2EA8rqD025890 for ; Thu, 14 Mar 2013 21:08:53 +1100 From: Wanpeng Li Subject: [PATCH v2 0/4] zcache: Support zero-filled pages more efficiently Date: Thu, 14 Mar 2013 18:08:13 +0800 Message-Id: <1363255697-19674-1-git-send-email-liwanp@linux.vnet.ibm.com> Sender: owner-linux-mm@kvack.org List-ID: 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 Changelog: v1 -> v2: * avoid changing tmem.[ch] entirely, spotted by Dan. * don't accumulate [eph|pers]pageframe and [eph|pers]zpages for zero-filled pages, spotted by Dan * cleanup TODO list * add Dan Acked-by. Motivation: - Seth Jennings points out compress zero-filled pages with LZO(a lossless data compression algorithm) will waste memory and result in fragmentation. https://lkml.org/lkml/2012/8/14/347 - Dan Magenheimer add "Support zero-filled pages more efficiently" feature in zcache TODO list https://lkml.org/lkml/2013/2/13/503 Design: - For store page, capture zero-filled pages(evicted clean page cache pages and swap pages), but don't compress them, set pampd which store zpage address to 0x2(since 0x0 and 0x1 has already been ocuppied) to mark special zero-filled case and take advantage of tmem infrastructure to transform handle-tuple(pool id, object id, and an index) to a pampd. Twice compress zero-filled pages will contribute to one zcache_[eph|pers]_pageframes count accumulated. - For load page, traverse tmem hierachical to transform handle-tuple to pampd and identify zero-filled case by pampd equal to 0x2 when filesystem reads file pages or a page needs to be swapped in, then refill the page to zero and return. Test: dd if=/dev/zero of=zerofile bs=1MB count=500 vmtouch -t zerofile vmtouch -e zerofile formula: - fragmentation level = (zcache_[eph|pers]_pageframes * PAGE_SIZE - zcache_[eph|pers]_zbytes) * 100 / (zcache_[eph|pers]_pageframes * PAGE_SIZE) - memory zcache occupy = zcache_[eph|pers]_zbytes Result: without zero-filled awareness: - fragmentation level: 98% - memory zcache occupy: 238MB with zero-filled awareness: - fragmentation level: 0% - memory zcache occupy: 0MB Wanpeng Li (4): introduce zero-filled pages handler zero-filled pages awareness introduce zero-filled pages stat count clean TODO list drivers/staging/zcache/TODO | 3 +- drivers/staging/zcache/zcache-main.c | 119 ++++++++++++++++++++++++++++++++-- 2 files changed, 114 insertions(+), 8 deletions(-) -- 1.7.7.6 -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to majordomo@kvack.org. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: email@kvack.org From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from psmtp.com (na3sys010amx112.postini.com [74.125.245.112]) by kanga.kvack.org (Postfix) with SMTP id 1AE9E6B0037 for ; Thu, 14 Mar 2013 06:09:07 -0400 (EDT) Received: from /spool/local by e23smtp03.au.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Thu, 14 Mar 2013 20:02:25 +1000 Received: from d23relay05.au.ibm.com (d23relay05.au.ibm.com [9.190.235.152]) by d23dlp01.au.ibm.com (Postfix) with ESMTP id 58FF82CE804C for ; Thu, 14 Mar 2013 21:08:58 +1100 (EST) Received: from d23av02.au.ibm.com (d23av02.au.ibm.com [9.190.235.138]) by d23relay05.au.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id r2E9u3HN63373328 for ; Thu, 14 Mar 2013 20:56:03 +1100 Received: from d23av02.au.ibm.com (loopback [127.0.0.1]) by d23av02.au.ibm.com (8.14.4/8.13.1/NCO v10.0 AVout) with ESMTP id r2EA8vbe026004 for ; Thu, 14 Mar 2013 21:08:57 +1100 From: Wanpeng Li Subject: [PATCH v2 1/4] introduce zero filled pages handler Date: Thu, 14 Mar 2013 18:08:14 +0800 Message-Id: <1363255697-19674-2-git-send-email-liwanp@linux.vnet.ibm.com> In-Reply-To: <1363255697-19674-1-git-send-email-liwanp@linux.vnet.ibm.com> References: <1363255697-19674-1-git-send-email-liwanp@linux.vnet.ibm.com> Sender: owner-linux-mm@kvack.org List-ID: 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 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..b71e033 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_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_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, send a message with 'unsubscribe linux-mm' in the body to majordomo@kvack.org. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: email@kvack.org From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from psmtp.com (na3sys010amx147.postini.com [74.125.245.147]) by kanga.kvack.org (Postfix) with SMTP id 092BA6B0036 for ; Thu, 14 Mar 2013 06:09:06 -0400 (EDT) Received: from /spool/local by e23smtp09.au.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Thu, 14 Mar 2013 20:01:09 +1000 Received: from d23relay03.au.ibm.com (d23relay03.au.ibm.com [9.190.235.21]) by d23dlp01.au.ibm.com (Postfix) with ESMTP id 2FA8E2CE804A for ; Thu, 14 Mar 2013 21:09:00 +1100 (EST) Received: from d23av01.au.ibm.com (d23av01.au.ibm.com [9.190.234.96]) by d23relay03.au.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id r2EA8u336750596 for ; Thu, 14 Mar 2013 21:08:56 +1100 Received: from d23av01.au.ibm.com (loopback [127.0.0.1]) by d23av01.au.ibm.com (8.14.4/8.13.1/NCO v10.0 AVout) with ESMTP id r2EA8x5r010777 for ; Thu, 14 Mar 2013 21:08:59 +1100 From: Wanpeng Li Subject: [PATCH v2 2/4] zero-filled pages awareness Date: Thu, 14 Mar 2013 18:08:15 +0800 Message-Id: <1363255697-19674-3-git-send-email-liwanp@linux.vnet.ibm.com> In-Reply-To: <1363255697-19674-1-git-send-email-liwanp@linux.vnet.ibm.com> References: <1363255697-19674-1-git-send-email-liwanp@linux.vnet.ibm.com> Sender: owner-linux-mm@kvack.org List-ID: 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 Compression of zero-filled pages can unneccessarily cause internal fragmentation, and thus waste memory. This special case can be optimized. This patch captures zero-filled pages, and marks their corresponding zcache backing page entry as zero-filled. Whenever such zero-filled page is retrieved, we fill the page frame with zero. Acked-by: Dan Magenheimer Signed-off-by: Wanpeng Li --- drivers/staging/zcache/zcache-main.c | 86 +++++++++++++++++++++++++++++++-- 1 files changed, 80 insertions(+), 6 deletions(-) diff --git a/drivers/staging/zcache/zcache-main.c b/drivers/staging/zcache/zcache-main.c index b71e033..db200b4 100644 --- a/drivers/staging/zcache/zcache-main.c +++ b/drivers/staging/zcache/zcache-main.c @@ -59,6 +59,11 @@ static inline void frontswap_tmem_exclusive_gets(bool b) } #endif +/* + * mark pampd to special value in order that later + * retrieve will identify zero-filled pages + */ + /* enable (or fix code) when Seth's patches are accepted upstream */ #define zcache_writeback_enabled 0 @@ -543,7 +548,23 @@ static void *zcache_pampd_eph_create(char *data, size_t size, bool raw, { void *pampd = NULL, *cdata = data; unsigned clen = size; + bool zero_filled = false; struct page *page = (struct page *)(data), *newpage; + char *user_mem; + + user_mem = kmap_atomic(page); + + /* + * Compressing zero-filled pages will waste memory and introduce + * serious fragmentation, skip it to avoid overhead + */ + if (page_zero_filled(user_mem)) { + kunmap_atomic(user_mem); + clen = 0; + zero_filled = true; + goto got_pampd; + } + kunmap_atomic(user_mem); if (!raw) { zcache_compress(page, &cdata, &clen); @@ -592,6 +613,8 @@ got_pampd: zcache_eph_zpages_max = zcache_eph_zpages; if (ramster_enabled && raw) ramster_count_foreign_pages(true, 1); + if (zero_filled) + pampd = (void *)ZERO_FILLED; out: return pampd; } @@ -601,14 +624,31 @@ static void *zcache_pampd_pers_create(char *data, size_t size, bool raw, { void *pampd = NULL, *cdata = data; unsigned clen = size; + bool zero_filled = false; struct page *page = (struct page *)(data), *newpage; unsigned long zbud_mean_zsize; unsigned long curr_pers_zpages, total_zsize; + char *user_mem; if (data == NULL) { BUG_ON(!ramster_enabled); goto create_pampd; } + + user_mem = kmap_atomic(page); + + /* + * Compressing zero-filled pages will waste memory and introduce + * serious fragmentation, skip it to avoid overhead + */ + if (page_zero_filled(page)) { + kunmap_atomic(user_mem); + clen = 0; + zero_filled = true; + goto got_pampd; + } + kunmap_atomic(user_mem); + curr_pers_zpages = zcache_pers_zpages; /* FIXME CONFIG_RAMSTER... subtract atomic remote_pers_pages here? */ if (!raw) @@ -674,6 +714,8 @@ got_pampd: zcache_pers_zbytes_max = zcache_pers_zbytes; if (ramster_enabled && raw) ramster_count_foreign_pages(false, 1); + if (zero_filled) + pampd = (void *)ZERO_FILLED; out: return pampd; } @@ -735,7 +777,8 @@ out: */ void zcache_pampd_create_finish(void *pampd, bool eph) { - zbud_create_finish((struct zbudref *)pampd, eph); + if (pampd != (void *)ZERO_FILLED) + zbud_create_finish((struct zbudref *)pampd, eph); } /* @@ -780,6 +823,14 @@ static int zcache_pampd_get_data(char *data, size_t *sizep, bool raw, BUG_ON(preemptible()); BUG_ON(eph); /* fix later if shared pools get implemented */ BUG_ON(pampd_is_remote(pampd)); + + if (pampd == (void *)ZERO_FILLED) { + handle_zero_page(data); + if (!raw) + *sizep = PAGE_SIZE; + return 0; + } + if (raw) ret = zbud_copy_from_zbud(data, (struct zbudref *)pampd, sizep, eph); @@ -801,12 +852,23 @@ static int zcache_pampd_get_data_and_free(char *data, size_t *sizep, bool raw, struct tmem_oid *oid, uint32_t index) { int ret; - bool eph = !is_persistent(pool); + bool eph = !is_persistent(pool), zero_filled = false; struct page *page = NULL; unsigned int zsize, zpages; BUG_ON(preemptible()); BUG_ON(pampd_is_remote(pampd)); + + if (pampd == (void *)ZERO_FILLED) { + handle_zero_page(data); + zero_filled = true; + zsize = 0; + zpages = 0; + if (!raw) + *sizep = PAGE_SIZE; + goto zero_fill; + } + if (raw) ret = zbud_copy_from_zbud(data, (struct zbudref *)pampd, sizep, eph); @@ -818,6 +880,7 @@ static int zcache_pampd_get_data_and_free(char *data, size_t *sizep, bool raw, } page = zbud_free_and_delist((struct zbudref *)pampd, eph, &zsize, &zpages); +zero_fill: if (eph) { if (page) zcache_eph_pageframes = @@ -837,7 +900,7 @@ static int zcache_pampd_get_data_and_free(char *data, size_t *sizep, bool raw, } if (!is_local_client(pool->client)) ramster_count_foreign_pages(eph, -1); - if (page) + if (page && !zero_filled) zcache_free_page(page); return ret; } @@ -851,16 +914,27 @@ static void zcache_pampd_free(void *pampd, struct tmem_pool *pool, { struct page *page = NULL; unsigned int zsize, zpages; + bool zero_filled = false; BUG_ON(preemptible()); - if (pampd_is_remote(pampd)) { + + if (pampd == (void *)ZERO_FILLED) { + zero_filled = true; + zsize = 0; + zpages = 0; + } + + if (pampd_is_remote(pampd) && !zero_filled) { + BUG_ON(!ramster_enabled); pampd = ramster_pampd_free(pampd, pool, oid, index, acct); if (pampd == NULL) return; } if (is_ephemeral(pool)) { - page = zbud_free_and_delist((struct zbudref *)pampd, + if (!zero_filled) + page = zbud_free_and_delist((struct zbudref *)pampd, + true, &zsize, &zpages); if (page) zcache_eph_pageframes = @@ -883,7 +957,7 @@ static void zcache_pampd_free(void *pampd, struct tmem_pool *pool, } if (!is_local_client(pool->client)) ramster_count_foreign_pages(is_ephemeral(pool), -1); - if (page) + if (page && !zero_filled) zcache_free_page(page); } -- 1.7.7.6 -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to majordomo@kvack.org. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: email@kvack.org From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from psmtp.com (na3sys010amx157.postini.com [74.125.245.157]) by kanga.kvack.org (Postfix) with SMTP id E68206B0037 for ; Thu, 14 Mar 2013 06:09:10 -0400 (EDT) Received: from /spool/local by e23smtp05.au.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Thu, 14 Mar 2013 20:04:50 +1000 Received: from d23relay05.au.ibm.com (d23relay05.au.ibm.com [9.190.235.152]) by d23dlp01.au.ibm.com (Postfix) with ESMTP id 5923C2CE804D for ; Thu, 14 Mar 2013 21:09:04 +1100 (EST) Received: from d23av01.au.ibm.com (d23av01.au.ibm.com [9.190.234.96]) by d23relay05.au.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id r2E9u97j10551624 for ; Thu, 14 Mar 2013 20:56:09 +1100 Received: from d23av01.au.ibm.com (loopback [127.0.0.1]) by d23av01.au.ibm.com (8.14.4/8.13.1/NCO v10.0 AVout) with ESMTP id r2EA93Rr010870 for ; Thu, 14 Mar 2013 21:09:03 +1100 From: Wanpeng Li Subject: [PATCH v2 4/4] clean TODO list Date: Thu, 14 Mar 2013 18:08:17 +0800 Message-Id: <1363255697-19674-5-git-send-email-liwanp@linux.vnet.ibm.com> In-Reply-To: <1363255697-19674-1-git-send-email-liwanp@linux.vnet.ibm.com> References: <1363255697-19674-1-git-send-email-liwanp@linux.vnet.ibm.com> Sender: owner-linux-mm@kvack.org List-ID: 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 Cleanup TODO list since support zero-filled pages more efficiently has already done by this patchset. Acked-by: Dan Magenheimer Signed-off-by: Wanpeng Li --- drivers/staging/zcache/TODO | 3 +-- 1 files changed, 1 insertions(+), 2 deletions(-) diff --git a/drivers/staging/zcache/TODO b/drivers/staging/zcache/TODO index c1e26d4..9e755d3 100644 --- a/drivers/staging/zcache/TODO +++ b/drivers/staging/zcache/TODO @@ -65,5 +65,4 @@ ZCACHE FUTURE NEW FUNCTIONALITY A. Support zsmalloc as an alternative high-density allocator (See https://lkml.org/lkml/2013/1/23/511) -B. Support zero-filled pages more efficiently -C. Possibly support three zbuds per pageframe when space allows +B. Possibly support three zbuds per pageframe when space allows -- 1.7.7.6 -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to majordomo@kvack.org. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: email@kvack.org From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from psmtp.com (na3sys010amx196.postini.com [74.125.245.196]) by kanga.kvack.org (Postfix) with SMTP id 410756B003D for ; Thu, 14 Mar 2013 06:09:46 -0400 (EDT) Received: from /spool/local by e23smtp03.au.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Thu, 14 Mar 2013 20:03:07 +1000 Received: from d23relay04.au.ibm.com (d23relay04.au.ibm.com [9.190.234.120]) by d23dlp03.au.ibm.com (Postfix) with ESMTP id 3B7EE357804E for ; Thu, 14 Mar 2013 21:09:32 +1100 (EST) Received: from d23av03.au.ibm.com (d23av03.au.ibm.com [9.190.234.97]) by d23relay04.au.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id r2E9uFdc54001768 for ; Thu, 14 Mar 2013 20:56:16 +1100 Received: from d23av03.au.ibm.com (loopback [127.0.0.1]) by d23av03.au.ibm.com (8.14.4/8.13.1/NCO v10.0 AVout) with ESMTP id r2EA91lx009052 for ; Thu, 14 Mar 2013 21:09:01 +1100 From: Wanpeng Li Subject: [PATCH v2 3/4] introduce zero-filled page stat count Date: Thu, 14 Mar 2013 18:08:16 +0800 Message-Id: <1363255697-19674-4-git-send-email-liwanp@linux.vnet.ibm.com> In-Reply-To: <1363255697-19674-1-git-send-email-liwanp@linux.vnet.ibm.com> References: <1363255697-19674-1-git-send-email-liwanp@linux.vnet.ibm.com> Sender: owner-linux-mm@kvack.org List-ID: 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 Introduce zero-filled page statistics to monitor the number of zero-filled pages. Acked-by: Dan Magenheimer Signed-off-by: Wanpeng Li --- drivers/staging/zcache/zcache-main.c | 7 +++++++ 1 files changed, 7 insertions(+), 0 deletions(-) diff --git a/drivers/staging/zcache/zcache-main.c b/drivers/staging/zcache/zcache-main.c index db200b4..2091a4d 100644 --- a/drivers/staging/zcache/zcache-main.c +++ b/drivers/staging/zcache/zcache-main.c @@ -196,6 +196,7 @@ static ssize_t zcache_eph_nonactive_puts_ignored; static ssize_t zcache_pers_nonactive_puts_ignored; static ssize_t zcache_writtenback_pages; static ssize_t zcache_outstanding_writeback_pages; +static ssize_t zcache_pages_zero; #ifdef CONFIG_DEBUG_FS #include @@ -257,6 +258,7 @@ static int zcache_debugfs_init(void) zdfs("outstanding_writeback_pages", S_IRUGO, root, &zcache_outstanding_writeback_pages); zdfs("writtenback_pages", S_IRUGO, root, &zcache_writtenback_pages); + zdfs("pages_zero", S_IRUGO, root, &zcache_pages_zero); return 0; } #undef zdebugfs @@ -326,6 +328,7 @@ void zcache_dump(void) pr_info("zcache: outstanding_writeback_pages=%zd\n", zcache_outstanding_writeback_pages); pr_info("zcache: writtenback_pages=%zd\n", zcache_writtenback_pages); + pr_info("zcache: pages_zero=%zd\n", zcache_pages_zero); } #endif @@ -562,6 +565,7 @@ static void *zcache_pampd_eph_create(char *data, size_t size, bool raw, kunmap_atomic(user_mem); clen = 0; zero_filled = true; + zcache_pages_zero++; goto got_pampd; } kunmap_atomic(user_mem); @@ -645,6 +649,7 @@ static void *zcache_pampd_pers_create(char *data, size_t size, bool raw, kunmap_atomic(user_mem); clen = 0; zero_filled = true; + zcache_pages_zero++; goto got_pampd; } kunmap_atomic(user_mem); @@ -866,6 +871,7 @@ static int zcache_pampd_get_data_and_free(char *data, size_t *sizep, bool raw, zpages = 0; if (!raw) *sizep = PAGE_SIZE; + zcache_pages_zero--; goto zero_fill; } @@ -922,6 +928,7 @@ static void zcache_pampd_free(void *pampd, struct tmem_pool *pool, zero_filled = true; zsize = 0; zpages = 0; + zcache_pages_zero--; } if (pampd_is_remote(pampd) && !zero_filled) { -- 1.7.7.6 -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to majordomo@kvack.org. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: email@kvack.org From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from psmtp.com (na3sys010amx193.postini.com [74.125.245.193]) by kanga.kvack.org (Postfix) with SMTP id 4729C6B0037 for ; Sat, 16 Mar 2013 09:03:10 -0400 (EDT) Received: by mail-ve0-f178.google.com with SMTP id db10so3318886veb.9 for ; Sat, 16 Mar 2013 06:03:09 -0700 (PDT) Date: Sat, 16 Mar 2013 09:03:04 -0400 From: Konrad Rzeszutek Wilk Subject: Re: [PATCH v2 1/4] introduce zero filled pages handler Message-ID: <20130316130302.GA5987@konrad-lan.dumpdata.com> References: <1363255697-19674-1-git-send-email-liwanp@linux.vnet.ibm.com> <1363255697-19674-2-git-send-email-liwanp@linux.vnet.ibm.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1363255697-19674-2-git-send-email-liwanp@linux.vnet.ibm.com> Sender: owner-linux-mm@kvack.org List-ID: To: Wanpeng Li Cc: Greg Kroah-Hartman , Andrew Morton , Dan Magenheimer , Seth Jennings , Minchan Kim , linux-mm@kvack.org, linux-kernel@vger.kernel.org On Thu, Mar 14, 2013 at 06:08:14PM +0800, Wanpeng Li wrote: > 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..b71e033 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_zero_filled(void *ptr) Shouldn't this be 'struct page *p' ? > +{ > + unsigned int pos; > + unsigned long *page; > + > + page = (unsigned long *)ptr; That way you can avoid this casting. > + > + for (pos = 0; pos < PAGE_SIZE / sizeof(*page); pos++) { > + if (page[pos]) > + return false; Perhaps allocate a static page filled with zeros and just do memcmp? > + } > + > + return true; > +} > + > +static void handle_zero_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); This is new. Could you kindly explain why it is needed? Thanks. > +} > + > static struct tmem_hostops zcache_hostops = { > .obj_alloc = zcache_obj_alloc, > .obj_free = zcache_obj_free, > -- > 1.7.7.6 > -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to majordomo@kvack.org. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: email@kvack.org From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from psmtp.com (na3sys010amx199.postini.com [74.125.245.199]) by kanga.kvack.org (Postfix) with SMTP id 1C2576B0037 for ; Sat, 16 Mar 2013 09:06:45 -0400 (EDT) Received: by mail-ve0-f181.google.com with SMTP id d10so3267753vea.40 for ; Sat, 16 Mar 2013 06:06:44 -0700 (PDT) Date: Sat, 16 Mar 2013 09:06:39 -0400 From: Konrad Rzeszutek Wilk Subject: Re: [PATCH v2 3/4] introduce zero-filled page stat count Message-ID: <20130316130638.GB5987@konrad-lan.dumpdata.com> References: <1363255697-19674-1-git-send-email-liwanp@linux.vnet.ibm.com> <1363255697-19674-4-git-send-email-liwanp@linux.vnet.ibm.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1363255697-19674-4-git-send-email-liwanp@linux.vnet.ibm.com> Sender: owner-linux-mm@kvack.org List-ID: To: Wanpeng Li Cc: Greg Kroah-Hartman , Andrew Morton , Dan Magenheimer , Seth Jennings , Minchan Kim , linux-mm@kvack.org, linux-kernel@vger.kernel.org On Thu, Mar 14, 2013 at 06:08:16PM +0800, Wanpeng Li wrote: > Introduce zero-filled page statistics to monitor the number of > zero-filled pages. Hm, you must be using an older version of the driver. Please rebase it against Greg KH's staging tree. This is where most if not all of the DebugFS counters got moved to a different file. > > Acked-by: Dan Magenheimer > Signed-off-by: Wanpeng Li > --- > drivers/staging/zcache/zcache-main.c | 7 +++++++ > 1 files changed, 7 insertions(+), 0 deletions(-) > > diff --git a/drivers/staging/zcache/zcache-main.c b/drivers/staging/zcache/zcache-main.c > index db200b4..2091a4d 100644 > --- a/drivers/staging/zcache/zcache-main.c > +++ b/drivers/staging/zcache/zcache-main.c > @@ -196,6 +196,7 @@ static ssize_t zcache_eph_nonactive_puts_ignored; > static ssize_t zcache_pers_nonactive_puts_ignored; > static ssize_t zcache_writtenback_pages; > static ssize_t zcache_outstanding_writeback_pages; > +static ssize_t zcache_pages_zero; > > #ifdef CONFIG_DEBUG_FS > #include > @@ -257,6 +258,7 @@ static int zcache_debugfs_init(void) > zdfs("outstanding_writeback_pages", S_IRUGO, root, > &zcache_outstanding_writeback_pages); > zdfs("writtenback_pages", S_IRUGO, root, &zcache_writtenback_pages); > + zdfs("pages_zero", S_IRUGO, root, &zcache_pages_zero); > return 0; > } > #undef zdebugfs > @@ -326,6 +328,7 @@ void zcache_dump(void) > pr_info("zcache: outstanding_writeback_pages=%zd\n", > zcache_outstanding_writeback_pages); > pr_info("zcache: writtenback_pages=%zd\n", zcache_writtenback_pages); > + pr_info("zcache: pages_zero=%zd\n", zcache_pages_zero); > } > #endif > > @@ -562,6 +565,7 @@ static void *zcache_pampd_eph_create(char *data, size_t size, bool raw, > kunmap_atomic(user_mem); > clen = 0; > zero_filled = true; > + zcache_pages_zero++; > goto got_pampd; > } > kunmap_atomic(user_mem); > @@ -645,6 +649,7 @@ static void *zcache_pampd_pers_create(char *data, size_t size, bool raw, > kunmap_atomic(user_mem); > clen = 0; > zero_filled = true; > + zcache_pages_zero++; > goto got_pampd; > } > kunmap_atomic(user_mem); > @@ -866,6 +871,7 @@ static int zcache_pampd_get_data_and_free(char *data, size_t *sizep, bool raw, > zpages = 0; > if (!raw) > *sizep = PAGE_SIZE; > + zcache_pages_zero--; > goto zero_fill; > } > > @@ -922,6 +928,7 @@ static void zcache_pampd_free(void *pampd, struct tmem_pool *pool, > zero_filled = true; > zsize = 0; > zpages = 0; > + zcache_pages_zero--; > } > > if (pampd_is_remote(pampd) && !zero_filled) { > -- > 1.7.7.6 > -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to majordomo@kvack.org. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: email@kvack.org From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from psmtp.com (na3sys010amx193.postini.com [74.125.245.193]) by kanga.kvack.org (Postfix) with SMTP id 0E4146B0038 for ; Sat, 16 Mar 2013 09:07:26 -0400 (EDT) Received: by mail-ve0-f169.google.com with SMTP id 15so3346177vea.28 for ; Sat, 16 Mar 2013 06:07:26 -0700 (PDT) Date: Sat, 16 Mar 2013 09:07:21 -0400 From: Konrad Rzeszutek Wilk Subject: Re: [PATCH v2 2/4] zero-filled pages awareness Message-ID: <20130316130720.GC5987@konrad-lan.dumpdata.com> References: <1363255697-19674-1-git-send-email-liwanp@linux.vnet.ibm.com> <1363255697-19674-3-git-send-email-liwanp@linux.vnet.ibm.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1363255697-19674-3-git-send-email-liwanp@linux.vnet.ibm.com> Sender: owner-linux-mm@kvack.org List-ID: To: Wanpeng Li Cc: Greg Kroah-Hartman , Andrew Morton , Dan Magenheimer , Seth Jennings , Minchan Kim , linux-mm@kvack.org, linux-kernel@vger.kernel.org On Thu, Mar 14, 2013 at 06:08:15PM +0800, Wanpeng Li wrote: > Compression of zero-filled pages can unneccessarily cause internal > fragmentation, and thus waste memory. This special case can be > optimized. > > This patch captures zero-filled pages, and marks their corresponding > zcache backing page entry as zero-filled. Whenever such zero-filled > page is retrieved, we fill the page frame with zero. > > Acked-by: Dan Magenheimer Reviewed-by: Konrad Rzeszutek Wilk > Signed-off-by: Wanpeng Li > --- > drivers/staging/zcache/zcache-main.c | 86 +++++++++++++++++++++++++++++++-- > 1 files changed, 80 insertions(+), 6 deletions(-) > > diff --git a/drivers/staging/zcache/zcache-main.c b/drivers/staging/zcache/zcache-main.c > index b71e033..db200b4 100644 > --- a/drivers/staging/zcache/zcache-main.c > +++ b/drivers/staging/zcache/zcache-main.c > @@ -59,6 +59,11 @@ static inline void frontswap_tmem_exclusive_gets(bool b) > } > #endif > > +/* > + * mark pampd to special value in order that later > + * retrieve will identify zero-filled pages > + */ > + > /* enable (or fix code) when Seth's patches are accepted upstream */ > #define zcache_writeback_enabled 0 > > @@ -543,7 +548,23 @@ static void *zcache_pampd_eph_create(char *data, size_t size, bool raw, > { > void *pampd = NULL, *cdata = data; > unsigned clen = size; > + bool zero_filled = false; > struct page *page = (struct page *)(data), *newpage; > + char *user_mem; > + > + user_mem = kmap_atomic(page); > + > + /* > + * Compressing zero-filled pages will waste memory and introduce > + * serious fragmentation, skip it to avoid overhead > + */ > + if (page_zero_filled(user_mem)) { > + kunmap_atomic(user_mem); > + clen = 0; > + zero_filled = true; > + goto got_pampd; > + } > + kunmap_atomic(user_mem); > > if (!raw) { > zcache_compress(page, &cdata, &clen); > @@ -592,6 +613,8 @@ got_pampd: > zcache_eph_zpages_max = zcache_eph_zpages; > if (ramster_enabled && raw) > ramster_count_foreign_pages(true, 1); > + if (zero_filled) > + pampd = (void *)ZERO_FILLED; > out: > return pampd; > } > @@ -601,14 +624,31 @@ static void *zcache_pampd_pers_create(char *data, size_t size, bool raw, > { > void *pampd = NULL, *cdata = data; > unsigned clen = size; > + bool zero_filled = false; > struct page *page = (struct page *)(data), *newpage; > unsigned long zbud_mean_zsize; > unsigned long curr_pers_zpages, total_zsize; > + char *user_mem; > > if (data == NULL) { > BUG_ON(!ramster_enabled); > goto create_pampd; > } > + > + user_mem = kmap_atomic(page); > + > + /* > + * Compressing zero-filled pages will waste memory and introduce > + * serious fragmentation, skip it to avoid overhead > + */ > + if (page_zero_filled(page)) { > + kunmap_atomic(user_mem); > + clen = 0; > + zero_filled = true; > + goto got_pampd; > + } > + kunmap_atomic(user_mem); > + > curr_pers_zpages = zcache_pers_zpages; > /* FIXME CONFIG_RAMSTER... subtract atomic remote_pers_pages here? */ > if (!raw) > @@ -674,6 +714,8 @@ got_pampd: > zcache_pers_zbytes_max = zcache_pers_zbytes; > if (ramster_enabled && raw) > ramster_count_foreign_pages(false, 1); > + if (zero_filled) > + pampd = (void *)ZERO_FILLED; > out: > return pampd; > } > @@ -735,7 +777,8 @@ out: > */ > void zcache_pampd_create_finish(void *pampd, bool eph) > { > - zbud_create_finish((struct zbudref *)pampd, eph); > + if (pampd != (void *)ZERO_FILLED) > + zbud_create_finish((struct zbudref *)pampd, eph); > } > > /* > @@ -780,6 +823,14 @@ static int zcache_pampd_get_data(char *data, size_t *sizep, bool raw, > BUG_ON(preemptible()); > BUG_ON(eph); /* fix later if shared pools get implemented */ > BUG_ON(pampd_is_remote(pampd)); > + > + if (pampd == (void *)ZERO_FILLED) { > + handle_zero_page(data); > + if (!raw) > + *sizep = PAGE_SIZE; > + return 0; > + } > + > if (raw) > ret = zbud_copy_from_zbud(data, (struct zbudref *)pampd, > sizep, eph); > @@ -801,12 +852,23 @@ static int zcache_pampd_get_data_and_free(char *data, size_t *sizep, bool raw, > struct tmem_oid *oid, uint32_t index) > { > int ret; > - bool eph = !is_persistent(pool); > + bool eph = !is_persistent(pool), zero_filled = false; > struct page *page = NULL; > unsigned int zsize, zpages; > > BUG_ON(preemptible()); > BUG_ON(pampd_is_remote(pampd)); > + > + if (pampd == (void *)ZERO_FILLED) { > + handle_zero_page(data); > + zero_filled = true; > + zsize = 0; > + zpages = 0; > + if (!raw) > + *sizep = PAGE_SIZE; > + goto zero_fill; > + } > + > if (raw) > ret = zbud_copy_from_zbud(data, (struct zbudref *)pampd, > sizep, eph); > @@ -818,6 +880,7 @@ static int zcache_pampd_get_data_and_free(char *data, size_t *sizep, bool raw, > } > page = zbud_free_and_delist((struct zbudref *)pampd, eph, > &zsize, &zpages); > +zero_fill: > if (eph) { > if (page) > zcache_eph_pageframes = > @@ -837,7 +900,7 @@ static int zcache_pampd_get_data_and_free(char *data, size_t *sizep, bool raw, > } > if (!is_local_client(pool->client)) > ramster_count_foreign_pages(eph, -1); > - if (page) > + if (page && !zero_filled) > zcache_free_page(page); > return ret; > } > @@ -851,16 +914,27 @@ static void zcache_pampd_free(void *pampd, struct tmem_pool *pool, > { > struct page *page = NULL; > unsigned int zsize, zpages; > + bool zero_filled = false; > > BUG_ON(preemptible()); > - if (pampd_is_remote(pampd)) { > + > + if (pampd == (void *)ZERO_FILLED) { > + zero_filled = true; > + zsize = 0; > + zpages = 0; > + } > + > + if (pampd_is_remote(pampd) && !zero_filled) { > + > BUG_ON(!ramster_enabled); > pampd = ramster_pampd_free(pampd, pool, oid, index, acct); > if (pampd == NULL) > return; > } > if (is_ephemeral(pool)) { > - page = zbud_free_and_delist((struct zbudref *)pampd, > + if (!zero_filled) > + page = zbud_free_and_delist((struct zbudref *)pampd, > + > true, &zsize, &zpages); > if (page) > zcache_eph_pageframes = > @@ -883,7 +957,7 @@ static void zcache_pampd_free(void *pampd, struct tmem_pool *pool, > } > if (!is_local_client(pool->client)) > ramster_count_foreign_pages(is_ephemeral(pool), -1); > - if (page) > + if (page && !zero_filled) > zcache_free_page(page); > } > > -- > 1.7.7.6 > -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to majordomo@kvack.org. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: email@kvack.org From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from psmtp.com (na3sys010amx201.postini.com [74.125.245.201]) by kanga.kvack.org (Postfix) with SMTP id 5726E6B0002 for ; Sat, 16 Mar 2013 14:24:53 -0400 (EDT) MIME-Version: 1.0 Message-ID: <6041f181-67b1-4f71-bd5c-cfb48f1ddfb0@default> Date: Sat, 16 Mar 2013 11:24:20 -0700 (PDT) From: Dan Magenheimer Subject: RE: [PATCH v2 1/4] introduce zero filled pages handler References: <1363255697-19674-1-git-send-email-liwanp@linux.vnet.ibm.com> <1363255697-19674-2-git-send-email-liwanp@linux.vnet.ibm.com> <20130316130302.GA5987@konrad-lan.dumpdata.com> In-Reply-To: <20130316130302.GA5987@konrad-lan.dumpdata.com> Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: quoted-printable Sender: owner-linux-mm@kvack.org List-ID: To: Konrad Rzeszutek Wilk , Wanpeng Li Cc: Greg Kroah-Hartman , Andrew Morton , Seth Jennings , Minchan Kim , linux-mm@kvack.org, linux-kernel@vger.kernel.org > From: Konrad Rzeszutek Wilk [mailto:konrad@darnok.org] > Subject: Re: [PATCH v2 1/4] introduce zero filled pages handler >=20 > > + > > +=09for (pos =3D 0; pos < PAGE_SIZE / sizeof(*page); pos++) { > > +=09=09if (page[pos]) > > +=09=09=09return false; >=20 > Perhaps allocate a static page filled with zeros and just do memcmp? That seems like a bad idea. Why compare two different memory locations when comparing one memory location to a register will do? -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to majordomo@kvack.org. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: email@kvack.org From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from psmtp.com (na3sys010amx179.postini.com [74.125.245.179]) by kanga.kvack.org (Postfix) with SMTP id 6745B6B0005 for ; Sat, 16 Mar 2013 20:11:47 -0400 (EDT) Received: from /spool/local by e23smtp01.au.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Sun, 17 Mar 2013 10:05:25 +1000 Received: from d23relay05.au.ibm.com (d23relay05.au.ibm.com [9.190.235.152]) by d23dlp01.au.ibm.com (Postfix) with ESMTP id EBE692CE804A for ; Sun, 17 Mar 2013 11:11:39 +1100 (EST) Received: from d23av04.au.ibm.com (d23av04.au.ibm.com [9.190.235.139]) by d23relay05.au.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id r2GNwgr1983346 for ; Sun, 17 Mar 2013 10:58:42 +1100 Received: from d23av04.au.ibm.com (loopback [127.0.0.1]) by d23av04.au.ibm.com (8.14.4/8.13.1/NCO v10.0 AVout) with ESMTP id r2H0BdIw016069 for ; Sun, 17 Mar 2013 11:11:39 +1100 Date: Sun, 17 Mar 2013 08:11:38 +0800 From: Wanpeng Li Subject: Re: [PATCH v2 1/4] introduce zero filled pages handler Message-ID: <20130317001137.GB8297@hacker.(null)> Reply-To: Wanpeng Li References: <1363255697-19674-1-git-send-email-liwanp@linux.vnet.ibm.com> <1363255697-19674-2-git-send-email-liwanp@linux.vnet.ibm.com> <20130316130302.GA5987@konrad-lan.dumpdata.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20130316130302.GA5987@konrad-lan.dumpdata.com> Sender: owner-linux-mm@kvack.org List-ID: To: Konrad Rzeszutek Wilk Cc: Greg Kroah-Hartman , Andrew Morton , Dan Magenheimer , Seth Jennings , Minchan Kim , linux-mm@kvack.org, linux-kernel@vger.kernel.org On Sat, Mar 16, 2013 at 09:03:04AM -0400, Konrad Rzeszutek Wilk wrote: >On Thu, Mar 14, 2013 at 06:08:14PM +0800, Wanpeng Li wrote: >> 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..b71e033 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_zero_filled(void *ptr) > >Shouldn't this be 'struct page *p' ? >> +{ >> + unsigned int pos; >> + unsigned long *page; >> + >> + page = (unsigned long *)ptr; > >That way you can avoid this casting. Great point! I will also clean it in zram implementation. >> + >> + for (pos = 0; pos < PAGE_SIZE / sizeof(*page); pos++) { >> + if (page[pos]) >> + return false; > >Perhaps allocate a static page filled with zeros and just do memcmp? >> + } >> + >> + return true; >> +} >> + >> +static void handle_zero_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); To make sure kernel store is visiable to user space mappings of that page. > >This is new. Could you kindly explain why it is needed? Thanks. >> +} >> + >> static struct tmem_hostops zcache_hostops = { >> .obj_alloc = zcache_obj_alloc, >> .obj_free = zcache_obj_free, >> -- >> 1.7.7.6 >> -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to majordomo@kvack.org. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: email@kvack.org From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from psmtp.com (na3sys010amx115.postini.com [74.125.245.115]) by kanga.kvack.org (Postfix) with SMTP id BFDE06B0005 for ; Sat, 16 Mar 2013 20:13:24 -0400 (EDT) Received: from /spool/local by e28smtp04.in.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Sun, 17 Mar 2013 05:40:09 +0530 Received: from d28relay05.in.ibm.com (d28relay05.in.ibm.com [9.184.220.62]) by d28dlp03.in.ibm.com (Postfix) with ESMTP id D2881125805D for ; Sun, 17 Mar 2013 05:44:24 +0530 (IST) Received: from d28av01.in.ibm.com (d28av01.in.ibm.com [9.184.220.63]) by d28relay05.in.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id r2H0DFeS9109812 for ; Sun, 17 Mar 2013 05:43:15 +0530 Received: from d28av01.in.ibm.com (loopback [127.0.0.1]) by d28av01.in.ibm.com (8.14.4/8.13.1/NCO v10.0 AVout) with ESMTP id r2H0DH5e032575 for ; Sun, 17 Mar 2013 00:13:18 GMT Date: Sun, 17 Mar 2013 08:13:16 +0800 From: Wanpeng Li Subject: Re: [PATCH v2 3/4] introduce zero-filled page stat count Message-ID: <20130317001316.GC8297@hacker.(null)> Reply-To: Wanpeng Li References: <1363255697-19674-1-git-send-email-liwanp@linux.vnet.ibm.com> <1363255697-19674-4-git-send-email-liwanp@linux.vnet.ibm.com> <20130316130638.GB5987@konrad-lan.dumpdata.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20130316130638.GB5987@konrad-lan.dumpdata.com> Sender: owner-linux-mm@kvack.org List-ID: To: Konrad Rzeszutek Wilk Cc: Greg Kroah-Hartman , Andrew Morton , Dan Magenheimer , Seth Jennings , Minchan Kim , linux-mm@kvack.org, linux-kernel@vger.kernel.org On Sat, Mar 16, 2013 at 09:06:39AM -0400, Konrad Rzeszutek Wilk wrote: >On Thu, Mar 14, 2013 at 06:08:16PM +0800, Wanpeng Li wrote: >> Introduce zero-filled page statistics to monitor the number of >> zero-filled pages. > Hi Konrad, >Hm, you must be using an older version of the driver. Please >rebase it against Greg KH's staging tree. This is where most if not >all of the DebugFS counters got moved to a different file. > Sorry, I miss it. I will rebase it. :-) Regards, Wanpeng Li >> >> Acked-by: Dan Magenheimer >> Signed-off-by: Wanpeng Li >> --- >> drivers/staging/zcache/zcache-main.c | 7 +++++++ >> 1 files changed, 7 insertions(+), 0 deletions(-) >> >> diff --git a/drivers/staging/zcache/zcache-main.c b/drivers/staging/zcache/zcache-main.c >> index db200b4..2091a4d 100644 >> --- a/drivers/staging/zcache/zcache-main.c >> +++ b/drivers/staging/zcache/zcache-main.c >> @@ -196,6 +196,7 @@ static ssize_t zcache_eph_nonactive_puts_ignored; >> static ssize_t zcache_pers_nonactive_puts_ignored; >> static ssize_t zcache_writtenback_pages; >> static ssize_t zcache_outstanding_writeback_pages; >> +static ssize_t zcache_pages_zero; >> >> #ifdef CONFIG_DEBUG_FS >> #include >> @@ -257,6 +258,7 @@ static int zcache_debugfs_init(void) >> zdfs("outstanding_writeback_pages", S_IRUGO, root, >> &zcache_outstanding_writeback_pages); >> zdfs("writtenback_pages", S_IRUGO, root, &zcache_writtenback_pages); >> + zdfs("pages_zero", S_IRUGO, root, &zcache_pages_zero); >> return 0; >> } >> #undef zdebugfs >> @@ -326,6 +328,7 @@ void zcache_dump(void) >> pr_info("zcache: outstanding_writeback_pages=%zd\n", >> zcache_outstanding_writeback_pages); >> pr_info("zcache: writtenback_pages=%zd\n", zcache_writtenback_pages); >> + pr_info("zcache: pages_zero=%zd\n", zcache_pages_zero); >> } >> #endif >> >> @@ -562,6 +565,7 @@ static void *zcache_pampd_eph_create(char *data, size_t size, bool raw, >> kunmap_atomic(user_mem); >> clen = 0; >> zero_filled = true; >> + zcache_pages_zero++; >> goto got_pampd; >> } >> kunmap_atomic(user_mem); >> @@ -645,6 +649,7 @@ static void *zcache_pampd_pers_create(char *data, size_t size, bool raw, >> kunmap_atomic(user_mem); >> clen = 0; >> zero_filled = true; >> + zcache_pages_zero++; >> goto got_pampd; >> } >> kunmap_atomic(user_mem); >> @@ -866,6 +871,7 @@ static int zcache_pampd_get_data_and_free(char *data, size_t *sizep, bool raw, >> zpages = 0; >> if (!raw) >> *sizep = PAGE_SIZE; >> + zcache_pages_zero--; >> goto zero_fill; >> } >> >> @@ -922,6 +928,7 @@ static void zcache_pampd_free(void *pampd, struct tmem_pool *pool, >> zero_filled = true; >> zsize = 0; >> zpages = 0; >> + zcache_pages_zero--; >> } >> >> if (pampd_is_remote(pampd) && !zero_filled) { >> -- >> 1.7.7.6 >> -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to majordomo@kvack.org. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: email@kvack.org From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from psmtp.com (na3sys010amx205.postini.com [74.125.245.205]) by kanga.kvack.org (Postfix) with SMTP id B35BA6B0005 for ; Sun, 17 Mar 2013 08:58:55 -0400 (EDT) Received: by mail-pb0-f45.google.com with SMTP id ro8so5694154pbb.32 for ; Sun, 17 Mar 2013 05:58:54 -0700 (PDT) Message-ID: <5145BE06.8070309@gmail.com> Date: Sun, 17 Mar 2013 20:58:46 +0800 From: Ric Mason MIME-Version: 1.0 Subject: Re: [PATCH v2 3/4] introduce zero-filled page stat count References: <1363255697-19674-1-git-send-email-liwanp@linux.vnet.ibm.com> <1363255697-19674-4-git-send-email-liwanp@linux.vnet.ibm.com> <20130316130638.GB5987@konrad-lan.dumpdata.com> In-Reply-To: <20130316130638.GB5987@konrad-lan.dumpdata.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Sender: owner-linux-mm@kvack.org List-ID: To: Konrad Rzeszutek Wilk Cc: Wanpeng Li , Greg Kroah-Hartman , Andrew Morton , Dan Magenheimer , Seth Jennings , Minchan Kim , linux-mm@kvack.org, linux-kernel@vger.kernel.org Hi Konrad, On 03/16/2013 09:06 PM, Konrad Rzeszutek Wilk wrote: > On Thu, Mar 14, 2013 at 06:08:16PM +0800, Wanpeng Li wrote: >> Introduce zero-filled page statistics to monitor the number of >> zero-filled pages. > Hm, you must be using an older version of the driver. Please > rebase it against Greg KH's staging tree. This is where most if not > all of the DebugFS counters got moved to a different file. It seems that zcache debugfs in Greg's staging-next is buggy, Could you test it? > >> Acked-by: Dan Magenheimer >> Signed-off-by: Wanpeng Li >> --- >> drivers/staging/zcache/zcache-main.c | 7 +++++++ >> 1 files changed, 7 insertions(+), 0 deletions(-) >> >> diff --git a/drivers/staging/zcache/zcache-main.c b/drivers/staging/zcache/zcache-main.c >> index db200b4..2091a4d 100644 >> --- a/drivers/staging/zcache/zcache-main.c >> +++ b/drivers/staging/zcache/zcache-main.c >> @@ -196,6 +196,7 @@ static ssize_t zcache_eph_nonactive_puts_ignored; >> static ssize_t zcache_pers_nonactive_puts_ignored; >> static ssize_t zcache_writtenback_pages; >> static ssize_t zcache_outstanding_writeback_pages; >> +static ssize_t zcache_pages_zero; >> >> #ifdef CONFIG_DEBUG_FS >> #include >> @@ -257,6 +258,7 @@ static int zcache_debugfs_init(void) >> zdfs("outstanding_writeback_pages", S_IRUGO, root, >> &zcache_outstanding_writeback_pages); >> zdfs("writtenback_pages", S_IRUGO, root, &zcache_writtenback_pages); >> + zdfs("pages_zero", S_IRUGO, root, &zcache_pages_zero); >> return 0; >> } >> #undef zdebugfs >> @@ -326,6 +328,7 @@ void zcache_dump(void) >> pr_info("zcache: outstanding_writeback_pages=%zd\n", >> zcache_outstanding_writeback_pages); >> pr_info("zcache: writtenback_pages=%zd\n", zcache_writtenback_pages); >> + pr_info("zcache: pages_zero=%zd\n", zcache_pages_zero); >> } >> #endif >> >> @@ -562,6 +565,7 @@ static void *zcache_pampd_eph_create(char *data, size_t size, bool raw, >> kunmap_atomic(user_mem); >> clen = 0; >> zero_filled = true; >> + zcache_pages_zero++; >> goto got_pampd; >> } >> kunmap_atomic(user_mem); >> @@ -645,6 +649,7 @@ static void *zcache_pampd_pers_create(char *data, size_t size, bool raw, >> kunmap_atomic(user_mem); >> clen = 0; >> zero_filled = true; >> + zcache_pages_zero++; >> goto got_pampd; >> } >> kunmap_atomic(user_mem); >> @@ -866,6 +871,7 @@ static int zcache_pampd_get_data_and_free(char *data, size_t *sizep, bool raw, >> zpages = 0; >> if (!raw) >> *sizep = PAGE_SIZE; >> + zcache_pages_zero--; >> goto zero_fill; >> } >> >> @@ -922,6 +928,7 @@ static void zcache_pampd_free(void *pampd, struct tmem_pool *pool, >> zero_filled = true; >> zsize = 0; >> zpages = 0; >> + zcache_pages_zero--; >> } >> >> if (pampd_is_remote(pampd) && !zero_filled) { >> -- >> 1.7.7.6 >> > -- > To unsubscribe, send a message with 'unsubscribe linux-mm' in > the body to majordomo@kvack.org. For more info on Linux MM, > see: http://www.linux-mm.org/ . > Don't email: email@kvack.org -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to majordomo@kvack.org. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: email@kvack.org From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from psmtp.com (na3sys010amx130.postini.com [74.125.245.130]) by kanga.kvack.org (Postfix) with SMTP id AB69E6B0005 for ; Tue, 19 Mar 2013 12:41:51 -0400 (EDT) Received: by mail-we0-f169.google.com with SMTP id t11so597188wey.28 for ; Tue, 19 Mar 2013 09:41:50 -0700 (PDT) MIME-Version: 1.0 Reply-To: konrad@darnok.org In-Reply-To: <5145BE06.8070309@gmail.com> References: <1363255697-19674-1-git-send-email-liwanp@linux.vnet.ibm.com> <1363255697-19674-4-git-send-email-liwanp@linux.vnet.ibm.com> <20130316130638.GB5987@konrad-lan.dumpdata.com> <5145BE06.8070309@gmail.com> Date: Tue, 19 Mar 2013 12:41:49 -0400 Message-ID: Subject: Re: [PATCH v2 3/4] introduce zero-filled page stat count From: Konrad Rzeszutek Wilk Content-Type: text/plain; charset=ISO-8859-1 Sender: owner-linux-mm@kvack.org List-ID: To: Ric Mason Cc: Wanpeng Li , Greg Kroah-Hartman , Andrew Morton , Dan Magenheimer , Seth Jennings , Minchan Kim , linux-mm@kvack.org, linux-kernel@vger.kernel.org On Sun, Mar 17, 2013 at 8:58 AM, Ric Mason wrote: > Hi Konrad, > > On 03/16/2013 09:06 PM, Konrad Rzeszutek Wilk wrote: >> >> On Thu, Mar 14, 2013 at 06:08:16PM +0800, Wanpeng Li wrote: >>> >>> Introduce zero-filled page statistics to monitor the number of >>> zero-filled pages. >> >> Hm, you must be using an older version of the driver. Please >> rebase it against Greg KH's staging tree. This is where most if not >> all of the DebugFS counters got moved to a different file. > > > It seems that zcache debugfs in Greg's staging-next is buggy, Could you test > it? > Could you email me what the issue you are seeing? -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to majordomo@kvack.org. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: email@kvack.org From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from psmtp.com (na3sys010amx183.postini.com [74.125.245.183]) by kanga.kvack.org (Postfix) with SMTP id 180A16B0005 for ; Tue, 19 Mar 2013 12:44:24 -0400 (EDT) Received: by mail-wg0-f44.google.com with SMTP id dr12so548940wgb.35 for ; Tue, 19 Mar 2013 09:44:22 -0700 (PDT) MIME-Version: 1.0 Reply-To: konrad@darnok.org In-Reply-To: <6041f181-67b1-4f71-bd5c-cfb48f1ddfb0@default> References: <1363255697-19674-1-git-send-email-liwanp@linux.vnet.ibm.com> <1363255697-19674-2-git-send-email-liwanp@linux.vnet.ibm.com> <20130316130302.GA5987@konrad-lan.dumpdata.com> <6041f181-67b1-4f71-bd5c-cfb48f1ddfb0@default> Date: Tue, 19 Mar 2013 12:44:22 -0400 Message-ID: Subject: Re: [PATCH v2 1/4] introduce zero filled pages handler From: Konrad Rzeszutek Wilk Content-Type: text/plain; charset=ISO-8859-1 Sender: owner-linux-mm@kvack.org List-ID: To: Dan Magenheimer Cc: Wanpeng Li , Greg Kroah-Hartman , Andrew Morton , Seth Jennings , Minchan Kim , linux-mm@kvack.org, linux-kernel@vger.kernel.org On Sat, Mar 16, 2013 at 2:24 PM, Dan Magenheimer wrote: >> From: Konrad Rzeszutek Wilk [mailto:konrad@darnok.org] >> Subject: Re: [PATCH v2 1/4] introduce zero filled pages handler >> >> > + >> > + for (pos = 0; pos < PAGE_SIZE / sizeof(*page); pos++) { >> > + if (page[pos]) >> > + return false; >> >> Perhaps allocate a static page filled with zeros and just do memcmp? > > That seems like a bad idea. Why compare two different > memory locations when comparing one memory location > to a register will do? > Good point. I was hoping there was an fast memcmp that would do fancy SSE registers. But it is memory against memory instead of registers. Perhaps a cunning trick would be to check (as a shortcircuit) check against 'empty_zero_page' and if that check fails, then try to do the check for each byte in the code? > -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to majordomo@kvack.org. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: email@kvack.org From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from psmtp.com (na3sys010amx167.postini.com [74.125.245.167]) by kanga.kvack.org (Postfix) with SMTP id 540836B0005 for ; Tue, 19 Mar 2013 19:31:56 -0400 (EDT) Received: by mail-pd0-f177.google.com with SMTP id y14so351541pdi.8 for ; Tue, 19 Mar 2013 16:31:55 -0700 (PDT) Message-ID: <5148F565.7060809@gmail.com> Date: Wed, 20 Mar 2013 07:31:49 +0800 From: Ric Mason MIME-Version: 1.0 Subject: Re: [PATCH v2 3/4] introduce zero-filled page stat count References: <1363255697-19674-1-git-send-email-liwanp@linux.vnet.ibm.com> <1363255697-19674-4-git-send-email-liwanp@linux.vnet.ibm.com> <20130316130638.GB5987@konrad-lan.dumpdata.com> <5145BE06.8070309@gmail.com> In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Sender: owner-linux-mm@kvack.org List-ID: To: konrad@darnok.org Cc: Wanpeng Li , Greg Kroah-Hartman , Andrew Morton , Dan Magenheimer , Seth Jennings , Minchan Kim , linux-mm@kvack.org, linux-kernel@vger.kernel.org On 03/20/2013 12:41 AM, Konrad Rzeszutek Wilk wrote: > On Sun, Mar 17, 2013 at 8:58 AM, Ric Mason wrote: >> Hi Konrad, >> >> On 03/16/2013 09:06 PM, Konrad Rzeszutek Wilk wrote: >>> On Thu, Mar 14, 2013 at 06:08:16PM +0800, Wanpeng Li wrote: >>>> Introduce zero-filled page statistics to monitor the number of >>>> zero-filled pages. >>> Hm, you must be using an older version of the driver. Please >>> rebase it against Greg KH's staging tree. This is where most if not >>> all of the DebugFS counters got moved to a different file. >> >> It seems that zcache debugfs in Greg's staging-next is buggy, Could you test >> it? >> > Could you email me what the issue you are seeing? They have already fixed in Wanpeng's patchset v4. -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to majordomo@kvack.org. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: email@kvack.org From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from psmtp.com (na3sys010amx174.postini.com [74.125.245.174]) by kanga.kvack.org (Postfix) with SMTP id B05136B0005 for ; Wed, 20 Mar 2013 06:22:21 -0400 (EDT) Received: from /spool/local by e28smtp08.in.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Wed, 20 Mar 2013 15:47:43 +0530 Received: from d28relay03.in.ibm.com (d28relay03.in.ibm.com [9.184.220.60]) by d28dlp02.in.ibm.com (Postfix) with ESMTP id 841AA3940065 for ; Wed, 20 Mar 2013 15:52:15 +0530 (IST) Received: from d28av02.in.ibm.com (d28av02.in.ibm.com [9.184.220.64]) by d28relay03.in.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id r2KAM9Hd3408304 for ; Wed, 20 Mar 2013 15:52:10 +0530 Received: from d28av02.in.ibm.com (loopback [127.0.0.1]) by d28av02.in.ibm.com (8.14.4/8.13.1/NCO v10.0 AVout) with ESMTP id r2KAMDQZ018379 for ; Wed, 20 Mar 2013 21:22:14 +1100 Date: Wed, 20 Mar 2013 18:22:10 +0800 From: Wanpeng Li Subject: Re: [PATCH v2 3/4] introduce zero-filled page stat count Message-ID: <20130320102210.GA18262@hacker.(null)> Reply-To: Wanpeng Li References: <1363255697-19674-1-git-send-email-liwanp@linux.vnet.ibm.com> <1363255697-19674-4-git-send-email-liwanp@linux.vnet.ibm.com> <20130316130638.GB5987@konrad-lan.dumpdata.com> <5145BE06.8070309@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Sender: owner-linux-mm@kvack.org List-ID: To: Konrad Rzeszutek Wilk Cc: Greg Kroah-Hartman , Andrew Morton , Dan Magenheimer , Seth Jennings , Minchan Kim , linux-mm@kvack.org, linux-kernel@vger.kernel.org On Tue, Mar 19, 2013 at 12:41:49PM -0400, Konrad Rzeszutek Wilk wrote: >On Sun, Mar 17, 2013 at 8:58 AM, Ric Mason wrote: >> Hi Konrad, >> >> On 03/16/2013 09:06 PM, Konrad Rzeszutek Wilk wrote: >>> >>> On Thu, Mar 14, 2013 at 06:08:16PM +0800, Wanpeng Li wrote: >>>> >>>> Introduce zero-filled page statistics to monitor the number of >>>> zero-filled pages. >>> >>> Hm, you must be using an older version of the driver. Please >>> rebase it against Greg KH's staging tree. This is where most if not >>> all of the DebugFS counters got moved to a different file. >> >> >> It seems that zcache debugfs in Greg's staging-next is buggy, Could you test >> it? >> >Could you email me what the issue you are seeing? Hi Konrad, I think I have already fix them for you in my patchset [PATCH v4 0/8], could you review 3/8~6/8, thanks. :-) Regards, Wanpeng Li -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to majordomo@kvack.org. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: email@kvack.org From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from psmtp.com (na3sys010amx114.postini.com [74.125.245.114]) by kanga.kvack.org (Postfix) with SMTP id 448CD6B00A1 for ; Mon, 25 Mar 2013 15:08:03 -0400 (EDT) MIME-Version: 1.0 Message-ID: <80f208d0-c0e9-4d38-9085-99866f7ee5d7@default> Date: Mon, 25 Mar 2013 12:07:38 -0700 (PDT) From: Dan Magenheimer Subject: RE: [PATCH v2 1/4] introduce zero filled pages handler References: <1363255697-19674-1-git-send-email-liwanp@linux.vnet.ibm.com> <1363255697-19674-2-git-send-email-liwanp@linux.vnet.ibm.com> <20130316130302.GA5987@konrad-lan.dumpdata.com> <6041f181-67b1-4f71-bd5c-cfb48f1ddfb0@default> In-Reply-To: Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: quoted-printable Sender: owner-linux-mm@kvack.org List-ID: To: konrad@darnok.org, Konrad Wilk Cc: Wanpeng Li , Greg Kroah-Hartman , Andrew Morton , Seth Jennings , Minchan Kim , linux-mm@kvack.org, linux-kernel@vger.kernel.org > From: Konrad Rzeszutek Wilk [mailto:konrad@darnok.org] > Sent: Tuesday, March 19, 2013 10:44 AM > To: Dan Magenheimer > Cc: Wanpeng Li; Greg Kroah-Hartman; Andrew Morton; Seth Jennings; Minchan= Kim; linux-mm@kvack.org; > linux-kernel@vger.kernel.org > Subject: Re: [PATCH v2 1/4] introduce zero filled pages handler >=20 > On Sat, Mar 16, 2013 at 2:24 PM, Dan Magenheimer > wrote: > >> From: Konrad Rzeszutek Wilk [mailto:konrad@darnok.org] > >> Subject: Re: [PATCH v2 1/4] introduce zero filled pages handler > >> > >> > + > >> > + for (pos =3D 0; pos < PAGE_SIZE / sizeof(*page); pos++) { > >> > + if (page[pos]) > >> > + return false; > >> > >> Perhaps allocate a static page filled with zeros and just do memcmp? > > > > That seems like a bad idea. Why compare two different > > memory locations when comparing one memory location > > to a register will do? >=20 > Good point. I was hoping there was an fast memcmp that would > do fancy SSE registers. But it is memory against memory instead of > registers. >=20 > Perhaps a cunning trick would be to check (as a shortcircuit) > check against 'empty_zero_page' and if that check fails, then try > to do the check for each byte in the code? Curious about this, I added some code to check for this case. In my test run, the conditional "if (page =3D=3D ZERO_PAGE(0))" was never true, for >200000 pages passed through frontswap that were zero-filled. My test run is certainly not conclusive, but perhaps some other code in the swap subsystem disqualifies ZERO_PAGE as a candidate for swapping? Or maybe it is accessed frequently enough that it never falls out of the active-anonymous page queue? Dan P.S. In arch/x86/include/asm/pgtable.h: #define ZERO_PAGE(vaddr) (virt_to_page(empty_zero_page)) -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to majordomo@kvack.org. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: email@kvack.org From mboxrd@z Thu Jan 1 00:00:00 1970 From: Wanpeng Li Subject: Re: [PATCH v2 1/4] introduce zero filled pages handler Date: Sun, 17 Mar 2013 08:11:38 +0800 Message-ID: <29667.5151134425$1363479136@news.gmane.org> References: <1363255697-19674-1-git-send-email-liwanp@linux.vnet.ibm.com> <1363255697-19674-2-git-send-email-liwanp@linux.vnet.ibm.com> <20130316130302.GA5987@konrad-lan.dumpdata.com> Reply-To: Wanpeng Li Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Return-path: Received: from kanga.kvack.org ([205.233.56.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1UH1Cu-0006x6-Br for glkm-linux-mm-2@m.gmane.org; Sun, 17 Mar 2013 01:12:12 +0100 Received: from psmtp.com (na3sys010amx179.postini.com [74.125.245.179]) by kanga.kvack.org (Postfix) with SMTP id 6745B6B0005 for ; Sat, 16 Mar 2013 20:11:47 -0400 (EDT) Received: from /spool/local by e23smtp01.au.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Sun, 17 Mar 2013 10:05:25 +1000 Received: from d23relay05.au.ibm.com (d23relay05.au.ibm.com [9.190.235.152]) by d23dlp01.au.ibm.com (Postfix) with ESMTP id EBE692CE804A for ; Sun, 17 Mar 2013 11:11:39 +1100 (EST) Received: from d23av04.au.ibm.com (d23av04.au.ibm.com [9.190.235.139]) by d23relay05.au.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id r2GNwgr1983346 for ; Sun, 17 Mar 2013 10:58:42 +1100 Received: from d23av04.au.ibm.com (loopback [127.0.0.1]) by d23av04.au.ibm.com (8.14.4/8.13.1/NCO v10.0 AVout) with ESMTP id r2H0BdIw016069 for ; Sun, 17 Mar 2013 11:11:39 +1100 Content-Disposition: inline In-Reply-To: <20130316130302.GA5987@konrad-lan.dumpdata.com> Sender: owner-linux-mm@kvack.org List-ID: To: Konrad Rzeszutek Wilk Cc: Greg Kroah-Hartman , Andrew Morton , Dan Magenheimer , Seth Jennings , Minchan Kim , linux-mm@kvack.org, linux-kernel@vger.kernel.org On Sat, Mar 16, 2013 at 09:03:04AM -0400, Konrad Rzeszutek Wilk wrote: >On Thu, Mar 14, 2013 at 06:08:14PM +0800, Wanpeng Li wrote: >> 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..b71e033 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_zero_filled(void *ptr) > >Shouldn't this be 'struct page *p' ? >> +{ >> + unsigned int pos; >> + unsigned long *page; >> + >> + page = (unsigned long *)ptr; > >That way you can avoid this casting. Great point! I will also clean it in zram implementation. >> + >> + for (pos = 0; pos < PAGE_SIZE / sizeof(*page); pos++) { >> + if (page[pos]) >> + return false; > >Perhaps allocate a static page filled with zeros and just do memcmp? >> + } >> + >> + return true; >> +} >> + >> +static void handle_zero_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); To make sure kernel store is visiable to user space mappings of that page. > >This is new. Could you kindly explain why it is needed? Thanks. >> +} >> + >> static struct tmem_hostops zcache_hostops = { >> .obj_alloc = zcache_obj_alloc, >> .obj_free = zcache_obj_free, >> -- >> 1.7.7.6 >> -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to majordomo@kvack.org. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: email@kvack.org From mboxrd@z Thu Jan 1 00:00:00 1970 From: Wanpeng Li Subject: Re: [PATCH v2 3/4] introduce zero-filled page stat count Date: Sun, 17 Mar 2013 08:13:16 +0800 Message-ID: <2781.87098815597$1363479234@news.gmane.org> References: <1363255697-19674-1-git-send-email-liwanp@linux.vnet.ibm.com> <1363255697-19674-4-git-send-email-liwanp@linux.vnet.ibm.com> <20130316130638.GB5987@konrad-lan.dumpdata.com> Reply-To: Wanpeng Li Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Return-path: Received: from kanga.kvack.org ([205.233.56.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1UH1EU-0008VL-SX for glkm-linux-mm-2@m.gmane.org; Sun, 17 Mar 2013 01:13:51 +0100 Received: from psmtp.com (na3sys010amx115.postini.com [74.125.245.115]) by kanga.kvack.org (Postfix) with SMTP id BFDE06B0005 for ; Sat, 16 Mar 2013 20:13:24 -0400 (EDT) Received: from /spool/local by e28smtp04.in.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Sun, 17 Mar 2013 05:40:09 +0530 Received: from d28relay05.in.ibm.com (d28relay05.in.ibm.com [9.184.220.62]) by d28dlp03.in.ibm.com (Postfix) with ESMTP id D2881125805D for ; Sun, 17 Mar 2013 05:44:24 +0530 (IST) Received: from d28av01.in.ibm.com (d28av01.in.ibm.com [9.184.220.63]) by d28relay05.in.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id r2H0DFeS9109812 for ; Sun, 17 Mar 2013 05:43:15 +0530 Received: from d28av01.in.ibm.com (loopback [127.0.0.1]) by d28av01.in.ibm.com (8.14.4/8.13.1/NCO v10.0 AVout) with ESMTP id r2H0DH5e032575 for ; Sun, 17 Mar 2013 00:13:18 GMT Content-Disposition: inline In-Reply-To: <20130316130638.GB5987@konrad-lan.dumpdata.com> Sender: owner-linux-mm@kvack.org List-ID: To: Konrad Rzeszutek Wilk Cc: Greg Kroah-Hartman , Andrew Morton , Dan Magenheimer , Seth Jennings , Minchan Kim , linux-mm@kvack.org, linux-kernel@vger.kernel.org On Sat, Mar 16, 2013 at 09:06:39AM -0400, Konrad Rzeszutek Wilk wrote: >On Thu, Mar 14, 2013 at 06:08:16PM +0800, Wanpeng Li wrote: >> Introduce zero-filled page statistics to monitor the number of >> zero-filled pages. > Hi Konrad, >Hm, you must be using an older version of the driver. Please >rebase it against Greg KH's staging tree. This is where most if not >all of the DebugFS counters got moved to a different file. > Sorry, I miss it. I will rebase it. :-) Regards, Wanpeng Li >> >> Acked-by: Dan Magenheimer >> Signed-off-by: Wanpeng Li >> --- >> drivers/staging/zcache/zcache-main.c | 7 +++++++ >> 1 files changed, 7 insertions(+), 0 deletions(-) >> >> diff --git a/drivers/staging/zcache/zcache-main.c b/drivers/staging/zcache/zcache-main.c >> index db200b4..2091a4d 100644 >> --- a/drivers/staging/zcache/zcache-main.c >> +++ b/drivers/staging/zcache/zcache-main.c >> @@ -196,6 +196,7 @@ static ssize_t zcache_eph_nonactive_puts_ignored; >> static ssize_t zcache_pers_nonactive_puts_ignored; >> static ssize_t zcache_writtenback_pages; >> static ssize_t zcache_outstanding_writeback_pages; >> +static ssize_t zcache_pages_zero; >> >> #ifdef CONFIG_DEBUG_FS >> #include >> @@ -257,6 +258,7 @@ static int zcache_debugfs_init(void) >> zdfs("outstanding_writeback_pages", S_IRUGO, root, >> &zcache_outstanding_writeback_pages); >> zdfs("writtenback_pages", S_IRUGO, root, &zcache_writtenback_pages); >> + zdfs("pages_zero", S_IRUGO, root, &zcache_pages_zero); >> return 0; >> } >> #undef zdebugfs >> @@ -326,6 +328,7 @@ void zcache_dump(void) >> pr_info("zcache: outstanding_writeback_pages=%zd\n", >> zcache_outstanding_writeback_pages); >> pr_info("zcache: writtenback_pages=%zd\n", zcache_writtenback_pages); >> + pr_info("zcache: pages_zero=%zd\n", zcache_pages_zero); >> } >> #endif >> >> @@ -562,6 +565,7 @@ static void *zcache_pampd_eph_create(char *data, size_t size, bool raw, >> kunmap_atomic(user_mem); >> clen = 0; >> zero_filled = true; >> + zcache_pages_zero++; >> goto got_pampd; >> } >> kunmap_atomic(user_mem); >> @@ -645,6 +649,7 @@ static void *zcache_pampd_pers_create(char *data, size_t size, bool raw, >> kunmap_atomic(user_mem); >> clen = 0; >> zero_filled = true; >> + zcache_pages_zero++; >> goto got_pampd; >> } >> kunmap_atomic(user_mem); >> @@ -866,6 +871,7 @@ static int zcache_pampd_get_data_and_free(char *data, size_t *sizep, bool raw, >> zpages = 0; >> if (!raw) >> *sizep = PAGE_SIZE; >> + zcache_pages_zero--; >> goto zero_fill; >> } >> >> @@ -922,6 +928,7 @@ static void zcache_pampd_free(void *pampd, struct tmem_pool *pool, >> zero_filled = true; >> zsize = 0; >> zpages = 0; >> + zcache_pages_zero--; >> } >> >> if (pampd_is_remote(pampd) && !zero_filled) { >> -- >> 1.7.7.6 >> -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to majordomo@kvack.org. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: email@kvack.org From mboxrd@z Thu Jan 1 00:00:00 1970 From: Wanpeng Li Subject: Re: [PATCH v2 3/4] introduce zero-filled page stat count Date: Wed, 20 Mar 2013 18:22:10 +0800 Message-ID: <39472.107232041$1363774974@news.gmane.org> References: <1363255697-19674-1-git-send-email-liwanp@linux.vnet.ibm.com> <1363255697-19674-4-git-send-email-liwanp@linux.vnet.ibm.com> <20130316130638.GB5987@konrad-lan.dumpdata.com> <5145BE06.8070309@gmail.com> Reply-To: Wanpeng Li Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Return-path: Received: from kanga.kvack.org ([205.233.56.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1UIGAR-0004M4-H6 for glkm-linux-mm-2@m.gmane.org; Wed, 20 Mar 2013 11:22:47 +0100 Received: from psmtp.com (na3sys010amx174.postini.com [74.125.245.174]) by kanga.kvack.org (Postfix) with SMTP id B05136B0005 for ; Wed, 20 Mar 2013 06:22:21 -0400 (EDT) Received: from /spool/local by e28smtp08.in.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Wed, 20 Mar 2013 15:47:43 +0530 Received: from d28relay03.in.ibm.com (d28relay03.in.ibm.com [9.184.220.60]) by d28dlp02.in.ibm.com (Postfix) with ESMTP id 841AA3940065 for ; Wed, 20 Mar 2013 15:52:15 +0530 (IST) Received: from d28av02.in.ibm.com (d28av02.in.ibm.com [9.184.220.64]) by d28relay03.in.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id r2KAM9Hd3408304 for ; Wed, 20 Mar 2013 15:52:10 +0530 Received: from d28av02.in.ibm.com (loopback [127.0.0.1]) by d28av02.in.ibm.com (8.14.4/8.13.1/NCO v10.0 AVout) with ESMTP id r2KAMDQZ018379 for ; Wed, 20 Mar 2013 21:22:14 +1100 Content-Disposition: inline In-Reply-To: Sender: owner-linux-mm@kvack.org List-ID: Cc: Greg Kroah-Hartman , Andrew Morton , Dan Magenheimer , Seth Jennings , Konrad Rzeszutek Wilk , Minchan Kim , linux-mm@kvack.org, linux-kernel@vger.kernel.org On Tue, Mar 19, 2013 at 12:41:49PM -0400, Konrad Rzeszutek Wilk wrote: >On Sun, Mar 17, 2013 at 8:58 AM, Ric Mason wrote: >> Hi Konrad, >> >> On 03/16/2013 09:06 PM, Konrad Rzeszutek Wilk wrote: >>> >>> On Thu, Mar 14, 2013 at 06:08:16PM +0800, Wanpeng Li wrote: >>>> >>>> Introduce zero-filled page statistics to monitor the number of >>>> zero-filled pages. >>> >>> Hm, you must be using an older version of the driver. Please >>> rebase it against Greg KH's staging tree. This is where most if not >>> all of the DebugFS counters got moved to a different file. >> >> >> It seems that zcache debugfs in Greg's staging-next is buggy, Could you test >> it? >> >Could you email me what the issue you are seeing? Hi Konrad, I think I have already fix them for you in my patchset [PATCH v4 0/8], could you review 3/8~6/8, thanks. :-) Regards, Wanpeng Li -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to majordomo@kvack.org. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: email@kvack.org From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756624Ab3CNKJG (ORCPT ); Thu, 14 Mar 2013 06:09:06 -0400 Received: from e23smtp09.au.ibm.com ([202.81.31.142]:60559 "EHLO e23smtp09.au.ibm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755566Ab3CNKJE (ORCPT ); Thu, 14 Mar 2013 06:09:04 -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 v2 0/4] zcache: Support zero-filled pages more efficiently Date: Thu, 14 Mar 2013 18:08:13 +0800 Message-Id: <1363255697-19674-1-git-send-email-liwanp@linux.vnet.ibm.com> X-Mailer: git-send-email 1.7.5.4 X-Content-Scanned: Fidelis XPS MAILER x-cbid: 13031410-3568-0000-0000-0000034A0199 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Changelog: v1 -> v2: * avoid changing tmem.[ch] entirely, spotted by Dan. * don't accumulate [eph|pers]pageframe and [eph|pers]zpages for zero-filled pages, spotted by Dan * cleanup TODO list * add Dan Acked-by. Motivation: - Seth Jennings points out compress zero-filled pages with LZO(a lossless data compression algorithm) will waste memory and result in fragmentation. https://lkml.org/lkml/2012/8/14/347 - Dan Magenheimer add "Support zero-filled pages more efficiently" feature in zcache TODO list https://lkml.org/lkml/2013/2/13/503 Design: - For store page, capture zero-filled pages(evicted clean page cache pages and swap pages), but don't compress them, set pampd which store zpage address to 0x2(since 0x0 and 0x1 has already been ocuppied) to mark special zero-filled case and take advantage of tmem infrastructure to transform handle-tuple(pool id, object id, and an index) to a pampd. Twice compress zero-filled pages will contribute to one zcache_[eph|pers]_pageframes count accumulated. - For load page, traverse tmem hierachical to transform handle-tuple to pampd and identify zero-filled case by pampd equal to 0x2 when filesystem reads file pages or a page needs to be swapped in, then refill the page to zero and return. Test: dd if=/dev/zero of=zerofile bs=1MB count=500 vmtouch -t zerofile vmtouch -e zerofile formula: - fragmentation level = (zcache_[eph|pers]_pageframes * PAGE_SIZE - zcache_[eph|pers]_zbytes) * 100 / (zcache_[eph|pers]_pageframes * PAGE_SIZE) - memory zcache occupy = zcache_[eph|pers]_zbytes Result: without zero-filled awareness: - fragmentation level: 98% - memory zcache occupy: 238MB with zero-filled awareness: - fragmentation level: 0% - memory zcache occupy: 0MB Wanpeng Li (4): introduce zero-filled pages handler zero-filled pages awareness introduce zero-filled pages stat count clean TODO list drivers/staging/zcache/TODO | 3 +- drivers/staging/zcache/zcache-main.c | 119 ++++++++++++++++++++++++++++++++-- 2 files changed, 114 insertions(+), 8 deletions(-) -- 1.7.7.6 From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756655Ab3CNKJM (ORCPT ); Thu, 14 Mar 2013 06:09:12 -0400 Received: from e23smtp01.au.ibm.com ([202.81.31.143]:58475 "EHLO e23smtp01.au.ibm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756635Ab3CNKJK (ORCPT ); Thu, 14 Mar 2013 06:09:10 -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 v2 4/4] clean TODO list Date: Thu, 14 Mar 2013 18:08:17 +0800 Message-Id: <1363255697-19674-5-git-send-email-liwanp@linux.vnet.ibm.com> X-Mailer: git-send-email 1.7.5.4 In-Reply-To: <1363255697-19674-1-git-send-email-liwanp@linux.vnet.ibm.com> References: <1363255697-19674-1-git-send-email-liwanp@linux.vnet.ibm.com> X-Content-Scanned: Fidelis XPS MAILER x-cbid: 13031410-1618-0000-0000-000003814C8E Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Cleanup TODO list since support zero-filled pages more efficiently has already done by this patchset. Acked-by: Dan Magenheimer Signed-off-by: Wanpeng Li --- drivers/staging/zcache/TODO | 3 +-- 1 files changed, 1 insertions(+), 2 deletions(-) diff --git a/drivers/staging/zcache/TODO b/drivers/staging/zcache/TODO index c1e26d4..9e755d3 100644 --- a/drivers/staging/zcache/TODO +++ b/drivers/staging/zcache/TODO @@ -65,5 +65,4 @@ ZCACHE FUTURE NEW FUNCTIONALITY A. Support zsmalloc as an alternative high-density allocator (See https://lkml.org/lkml/2013/1/23/511) -B. Support zero-filled pages more efficiently -C. Possibly support three zbuds per pageframe when space allows +B. Possibly support three zbuds per pageframe when space allows -- 1.7.7.6 From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756672Ab3CNKJT (ORCPT ); Thu, 14 Mar 2013 06:09:19 -0400 Received: from e23smtp07.au.ibm.com ([202.81.31.140]:33426 "EHLO e23smtp07.au.ibm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755566Ab3CNKJJ (ORCPT ); Thu, 14 Mar 2013 06:09:09 -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 v2 3/4] introduce zero-filled page stat count Date: Thu, 14 Mar 2013 18:08:16 +0800 Message-Id: <1363255697-19674-4-git-send-email-liwanp@linux.vnet.ibm.com> X-Mailer: git-send-email 1.7.5.4 In-Reply-To: <1363255697-19674-1-git-send-email-liwanp@linux.vnet.ibm.com> References: <1363255697-19674-1-git-send-email-liwanp@linux.vnet.ibm.com> X-Content-Scanned: Fidelis XPS MAILER x-cbid: 13031410-0260-0000-0000-000002AABE0B Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Introduce zero-filled page statistics to monitor the number of zero-filled pages. Acked-by: Dan Magenheimer Signed-off-by: Wanpeng Li --- drivers/staging/zcache/zcache-main.c | 7 +++++++ 1 files changed, 7 insertions(+), 0 deletions(-) diff --git a/drivers/staging/zcache/zcache-main.c b/drivers/staging/zcache/zcache-main.c index db200b4..2091a4d 100644 --- a/drivers/staging/zcache/zcache-main.c +++ b/drivers/staging/zcache/zcache-main.c @@ -196,6 +196,7 @@ static ssize_t zcache_eph_nonactive_puts_ignored; static ssize_t zcache_pers_nonactive_puts_ignored; static ssize_t zcache_writtenback_pages; static ssize_t zcache_outstanding_writeback_pages; +static ssize_t zcache_pages_zero; #ifdef CONFIG_DEBUG_FS #include @@ -257,6 +258,7 @@ static int zcache_debugfs_init(void) zdfs("outstanding_writeback_pages", S_IRUGO, root, &zcache_outstanding_writeback_pages); zdfs("writtenback_pages", S_IRUGO, root, &zcache_writtenback_pages); + zdfs("pages_zero", S_IRUGO, root, &zcache_pages_zero); return 0; } #undef zdebugfs @@ -326,6 +328,7 @@ void zcache_dump(void) pr_info("zcache: outstanding_writeback_pages=%zd\n", zcache_outstanding_writeback_pages); pr_info("zcache: writtenback_pages=%zd\n", zcache_writtenback_pages); + pr_info("zcache: pages_zero=%zd\n", zcache_pages_zero); } #endif @@ -562,6 +565,7 @@ static void *zcache_pampd_eph_create(char *data, size_t size, bool raw, kunmap_atomic(user_mem); clen = 0; zero_filled = true; + zcache_pages_zero++; goto got_pampd; } kunmap_atomic(user_mem); @@ -645,6 +649,7 @@ static void *zcache_pampd_pers_create(char *data, size_t size, bool raw, kunmap_atomic(user_mem); clen = 0; zero_filled = true; + zcache_pages_zero++; goto got_pampd; } kunmap_atomic(user_mem); @@ -866,6 +871,7 @@ static int zcache_pampd_get_data_and_free(char *data, size_t *sizep, bool raw, zpages = 0; if (!raw) *sizep = PAGE_SIZE; + zcache_pages_zero--; goto zero_fill; } @@ -922,6 +928,7 @@ static void zcache_pampd_free(void *pampd, struct tmem_pool *pool, zero_filled = true; zsize = 0; zpages = 0; + zcache_pages_zero--; } if (pampd_is_remote(pampd) && !zero_filled) { -- 1.7.7.6 From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756697Ab3CNKJZ (ORCPT ); Thu, 14 Mar 2013 06:09:25 -0400 Received: from e23smtp06.au.ibm.com ([202.81.31.148]:33819 "EHLO e23smtp06.au.ibm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756676Ab3CNKJW (ORCPT ); Thu, 14 Mar 2013 06:09:22 -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 v2 2/4] zero-filled pages awareness Date: Thu, 14 Mar 2013 18:08:15 +0800 Message-Id: <1363255697-19674-3-git-send-email-liwanp@linux.vnet.ibm.com> X-Mailer: git-send-email 1.7.5.4 In-Reply-To: <1363255697-19674-1-git-send-email-liwanp@linux.vnet.ibm.com> References: <1363255697-19674-1-git-send-email-liwanp@linux.vnet.ibm.com> X-Content-Scanned: Fidelis XPS MAILER x-cbid: 13031410-7014-0000-0000-000002B6E9B3 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Compression of zero-filled pages can unneccessarily cause internal fragmentation, and thus waste memory. This special case can be optimized. This patch captures zero-filled pages, and marks their corresponding zcache backing page entry as zero-filled. Whenever such zero-filled page is retrieved, we fill the page frame with zero. Acked-by: Dan Magenheimer Signed-off-by: Wanpeng Li --- drivers/staging/zcache/zcache-main.c | 86 +++++++++++++++++++++++++++++++-- 1 files changed, 80 insertions(+), 6 deletions(-) diff --git a/drivers/staging/zcache/zcache-main.c b/drivers/staging/zcache/zcache-main.c index b71e033..db200b4 100644 --- a/drivers/staging/zcache/zcache-main.c +++ b/drivers/staging/zcache/zcache-main.c @@ -59,6 +59,11 @@ static inline void frontswap_tmem_exclusive_gets(bool b) } #endif +/* + * mark pampd to special value in order that later + * retrieve will identify zero-filled pages + */ + /* enable (or fix code) when Seth's patches are accepted upstream */ #define zcache_writeback_enabled 0 @@ -543,7 +548,23 @@ static void *zcache_pampd_eph_create(char *data, size_t size, bool raw, { void *pampd = NULL, *cdata = data; unsigned clen = size; + bool zero_filled = false; struct page *page = (struct page *)(data), *newpage; + char *user_mem; + + user_mem = kmap_atomic(page); + + /* + * Compressing zero-filled pages will waste memory and introduce + * serious fragmentation, skip it to avoid overhead + */ + if (page_zero_filled(user_mem)) { + kunmap_atomic(user_mem); + clen = 0; + zero_filled = true; + goto got_pampd; + } + kunmap_atomic(user_mem); if (!raw) { zcache_compress(page, &cdata, &clen); @@ -592,6 +613,8 @@ got_pampd: zcache_eph_zpages_max = zcache_eph_zpages; if (ramster_enabled && raw) ramster_count_foreign_pages(true, 1); + if (zero_filled) + pampd = (void *)ZERO_FILLED; out: return pampd; } @@ -601,14 +624,31 @@ static void *zcache_pampd_pers_create(char *data, size_t size, bool raw, { void *pampd = NULL, *cdata = data; unsigned clen = size; + bool zero_filled = false; struct page *page = (struct page *)(data), *newpage; unsigned long zbud_mean_zsize; unsigned long curr_pers_zpages, total_zsize; + char *user_mem; if (data == NULL) { BUG_ON(!ramster_enabled); goto create_pampd; } + + user_mem = kmap_atomic(page); + + /* + * Compressing zero-filled pages will waste memory and introduce + * serious fragmentation, skip it to avoid overhead + */ + if (page_zero_filled(page)) { + kunmap_atomic(user_mem); + clen = 0; + zero_filled = true; + goto got_pampd; + } + kunmap_atomic(user_mem); + curr_pers_zpages = zcache_pers_zpages; /* FIXME CONFIG_RAMSTER... subtract atomic remote_pers_pages here? */ if (!raw) @@ -674,6 +714,8 @@ got_pampd: zcache_pers_zbytes_max = zcache_pers_zbytes; if (ramster_enabled && raw) ramster_count_foreign_pages(false, 1); + if (zero_filled) + pampd = (void *)ZERO_FILLED; out: return pampd; } @@ -735,7 +777,8 @@ out: */ void zcache_pampd_create_finish(void *pampd, bool eph) { - zbud_create_finish((struct zbudref *)pampd, eph); + if (pampd != (void *)ZERO_FILLED) + zbud_create_finish((struct zbudref *)pampd, eph); } /* @@ -780,6 +823,14 @@ static int zcache_pampd_get_data(char *data, size_t *sizep, bool raw, BUG_ON(preemptible()); BUG_ON(eph); /* fix later if shared pools get implemented */ BUG_ON(pampd_is_remote(pampd)); + + if (pampd == (void *)ZERO_FILLED) { + handle_zero_page(data); + if (!raw) + *sizep = PAGE_SIZE; + return 0; + } + if (raw) ret = zbud_copy_from_zbud(data, (struct zbudref *)pampd, sizep, eph); @@ -801,12 +852,23 @@ static int zcache_pampd_get_data_and_free(char *data, size_t *sizep, bool raw, struct tmem_oid *oid, uint32_t index) { int ret; - bool eph = !is_persistent(pool); + bool eph = !is_persistent(pool), zero_filled = false; struct page *page = NULL; unsigned int zsize, zpages; BUG_ON(preemptible()); BUG_ON(pampd_is_remote(pampd)); + + if (pampd == (void *)ZERO_FILLED) { + handle_zero_page(data); + zero_filled = true; + zsize = 0; + zpages = 0; + if (!raw) + *sizep = PAGE_SIZE; + goto zero_fill; + } + if (raw) ret = zbud_copy_from_zbud(data, (struct zbudref *)pampd, sizep, eph); @@ -818,6 +880,7 @@ static int zcache_pampd_get_data_and_free(char *data, size_t *sizep, bool raw, } page = zbud_free_and_delist((struct zbudref *)pampd, eph, &zsize, &zpages); +zero_fill: if (eph) { if (page) zcache_eph_pageframes = @@ -837,7 +900,7 @@ static int zcache_pampd_get_data_and_free(char *data, size_t *sizep, bool raw, } if (!is_local_client(pool->client)) ramster_count_foreign_pages(eph, -1); - if (page) + if (page && !zero_filled) zcache_free_page(page); return ret; } @@ -851,16 +914,27 @@ static void zcache_pampd_free(void *pampd, struct tmem_pool *pool, { struct page *page = NULL; unsigned int zsize, zpages; + bool zero_filled = false; BUG_ON(preemptible()); - if (pampd_is_remote(pampd)) { + + if (pampd == (void *)ZERO_FILLED) { + zero_filled = true; + zsize = 0; + zpages = 0; + } + + if (pampd_is_remote(pampd) && !zero_filled) { + BUG_ON(!ramster_enabled); pampd = ramster_pampd_free(pampd, pool, oid, index, acct); if (pampd == NULL) return; } if (is_ephemeral(pool)) { - page = zbud_free_and_delist((struct zbudref *)pampd, + if (!zero_filled) + page = zbud_free_and_delist((struct zbudref *)pampd, + true, &zsize, &zpages); if (page) zcache_eph_pageframes = @@ -883,7 +957,7 @@ static void zcache_pampd_free(void *pampd, struct tmem_pool *pool, } if (!is_local_client(pool->client)) ramster_count_foreign_pages(is_ephemeral(pool), -1); - if (page) + if (page && !zero_filled) zcache_free_page(page); } -- 1.7.7.6 From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756708Ab3CNKJ4 (ORCPT ); Thu, 14 Mar 2013 06:09:56 -0400 Received: from e23smtp09.au.ibm.com ([202.81.31.142]:60622 "EHLO e23smtp09.au.ibm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755281Ab3CNKJy (ORCPT ); Thu, 14 Mar 2013 06:09:54 -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 v2 1/4] introduce zero filled pages handler Date: Thu, 14 Mar 2013 18:08:14 +0800 Message-Id: <1363255697-19674-2-git-send-email-liwanp@linux.vnet.ibm.com> X-Mailer: git-send-email 1.7.5.4 In-Reply-To: <1363255697-19674-1-git-send-email-liwanp@linux.vnet.ibm.com> References: <1363255697-19674-1-git-send-email-liwanp@linux.vnet.ibm.com> x-cbid: 13031410-3568-0000-0000-0000034A01D3 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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..b71e033 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_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_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 From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932394Ab3CPNDL (ORCPT ); Sat, 16 Mar 2013 09:03:11 -0400 Received: from mail-vb0-f49.google.com ([209.85.212.49]:43844 "EHLO mail-vb0-f49.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755710Ab3CPNDK (ORCPT ); Sat, 16 Mar 2013 09:03:10 -0400 Date: Sat, 16 Mar 2013 09:03:04 -0400 From: Konrad Rzeszutek Wilk To: Wanpeng Li Cc: Greg Kroah-Hartman , Andrew Morton , Dan Magenheimer , Seth Jennings , Minchan Kim , linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v2 1/4] introduce zero filled pages handler Message-ID: <20130316130302.GA5987@konrad-lan.dumpdata.com> References: <1363255697-19674-1-git-send-email-liwanp@linux.vnet.ibm.com> <1363255697-19674-2-git-send-email-liwanp@linux.vnet.ibm.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1363255697-19674-2-git-send-email-liwanp@linux.vnet.ibm.com> User-Agent: Mutt/1.5.21 (2010-09-15) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Mar 14, 2013 at 06:08:14PM +0800, Wanpeng Li wrote: > 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..b71e033 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_zero_filled(void *ptr) Shouldn't this be 'struct page *p' ? > +{ > + unsigned int pos; > + unsigned long *page; > + > + page = (unsigned long *)ptr; That way you can avoid this casting. > + > + for (pos = 0; pos < PAGE_SIZE / sizeof(*page); pos++) { > + if (page[pos]) > + return false; Perhaps allocate a static page filled with zeros and just do memcmp? > + } > + > + return true; > +} > + > +static void handle_zero_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); This is new. Could you kindly explain why it is needed? Thanks. > +} > + > static struct tmem_hostops zcache_hostops = { > .obj_alloc = zcache_obj_alloc, > .obj_free = zcache_obj_free, > -- > 1.7.7.6 > From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755769Ab3CPNGr (ORCPT ); Sat, 16 Mar 2013 09:06:47 -0400 Received: from mail-vc0-f177.google.com ([209.85.220.177]:37782 "EHLO mail-vc0-f177.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755593Ab3CPNGp (ORCPT ); Sat, 16 Mar 2013 09:06:45 -0400 Date: Sat, 16 Mar 2013 09:06:39 -0400 From: Konrad Rzeszutek Wilk To: Wanpeng Li Cc: Greg Kroah-Hartman , Andrew Morton , Dan Magenheimer , Seth Jennings , Minchan Kim , linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v2 3/4] introduce zero-filled page stat count Message-ID: <20130316130638.GB5987@konrad-lan.dumpdata.com> References: <1363255697-19674-1-git-send-email-liwanp@linux.vnet.ibm.com> <1363255697-19674-4-git-send-email-liwanp@linux.vnet.ibm.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1363255697-19674-4-git-send-email-liwanp@linux.vnet.ibm.com> User-Agent: Mutt/1.5.21 (2010-09-15) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Mar 14, 2013 at 06:08:16PM +0800, Wanpeng Li wrote: > Introduce zero-filled page statistics to monitor the number of > zero-filled pages. Hm, you must be using an older version of the driver. Please rebase it against Greg KH's staging tree. This is where most if not all of the DebugFS counters got moved to a different file. > > Acked-by: Dan Magenheimer > Signed-off-by: Wanpeng Li > --- > drivers/staging/zcache/zcache-main.c | 7 +++++++ > 1 files changed, 7 insertions(+), 0 deletions(-) > > diff --git a/drivers/staging/zcache/zcache-main.c b/drivers/staging/zcache/zcache-main.c > index db200b4..2091a4d 100644 > --- a/drivers/staging/zcache/zcache-main.c > +++ b/drivers/staging/zcache/zcache-main.c > @@ -196,6 +196,7 @@ static ssize_t zcache_eph_nonactive_puts_ignored; > static ssize_t zcache_pers_nonactive_puts_ignored; > static ssize_t zcache_writtenback_pages; > static ssize_t zcache_outstanding_writeback_pages; > +static ssize_t zcache_pages_zero; > > #ifdef CONFIG_DEBUG_FS > #include > @@ -257,6 +258,7 @@ static int zcache_debugfs_init(void) > zdfs("outstanding_writeback_pages", S_IRUGO, root, > &zcache_outstanding_writeback_pages); > zdfs("writtenback_pages", S_IRUGO, root, &zcache_writtenback_pages); > + zdfs("pages_zero", S_IRUGO, root, &zcache_pages_zero); > return 0; > } > #undef zdebugfs > @@ -326,6 +328,7 @@ void zcache_dump(void) > pr_info("zcache: outstanding_writeback_pages=%zd\n", > zcache_outstanding_writeback_pages); > pr_info("zcache: writtenback_pages=%zd\n", zcache_writtenback_pages); > + pr_info("zcache: pages_zero=%zd\n", zcache_pages_zero); > } > #endif > > @@ -562,6 +565,7 @@ static void *zcache_pampd_eph_create(char *data, size_t size, bool raw, > kunmap_atomic(user_mem); > clen = 0; > zero_filled = true; > + zcache_pages_zero++; > goto got_pampd; > } > kunmap_atomic(user_mem); > @@ -645,6 +649,7 @@ static void *zcache_pampd_pers_create(char *data, size_t size, bool raw, > kunmap_atomic(user_mem); > clen = 0; > zero_filled = true; > + zcache_pages_zero++; > goto got_pampd; > } > kunmap_atomic(user_mem); > @@ -866,6 +871,7 @@ static int zcache_pampd_get_data_and_free(char *data, size_t *sizep, bool raw, > zpages = 0; > if (!raw) > *sizep = PAGE_SIZE; > + zcache_pages_zero--; > goto zero_fill; > } > > @@ -922,6 +928,7 @@ static void zcache_pampd_free(void *pampd, struct tmem_pool *pool, > zero_filled = true; > zsize = 0; > zpages = 0; > + zcache_pages_zero--; > } > > if (pampd_is_remote(pampd) && !zero_filled) { > -- > 1.7.7.6 > From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755788Ab3CPNH3 (ORCPT ); Sat, 16 Mar 2013 09:07:29 -0400 Received: from mail-ve0-f177.google.com ([209.85.128.177]:41600 "EHLO mail-ve0-f177.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755711Ab3CPNH1 (ORCPT ); Sat, 16 Mar 2013 09:07:27 -0400 Date: Sat, 16 Mar 2013 09:07:21 -0400 From: Konrad Rzeszutek Wilk To: Wanpeng Li Cc: Greg Kroah-Hartman , Andrew Morton , Dan Magenheimer , Seth Jennings , Minchan Kim , linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v2 2/4] zero-filled pages awareness Message-ID: <20130316130720.GC5987@konrad-lan.dumpdata.com> References: <1363255697-19674-1-git-send-email-liwanp@linux.vnet.ibm.com> <1363255697-19674-3-git-send-email-liwanp@linux.vnet.ibm.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1363255697-19674-3-git-send-email-liwanp@linux.vnet.ibm.com> User-Agent: Mutt/1.5.21 (2010-09-15) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Mar 14, 2013 at 06:08:15PM +0800, Wanpeng Li wrote: > Compression of zero-filled pages can unneccessarily cause internal > fragmentation, and thus waste memory. This special case can be > optimized. > > This patch captures zero-filled pages, and marks their corresponding > zcache backing page entry as zero-filled. Whenever such zero-filled > page is retrieved, we fill the page frame with zero. > > Acked-by: Dan Magenheimer Reviewed-by: Konrad Rzeszutek Wilk > Signed-off-by: Wanpeng Li > --- > drivers/staging/zcache/zcache-main.c | 86 +++++++++++++++++++++++++++++++-- > 1 files changed, 80 insertions(+), 6 deletions(-) > > diff --git a/drivers/staging/zcache/zcache-main.c b/drivers/staging/zcache/zcache-main.c > index b71e033..db200b4 100644 > --- a/drivers/staging/zcache/zcache-main.c > +++ b/drivers/staging/zcache/zcache-main.c > @@ -59,6 +59,11 @@ static inline void frontswap_tmem_exclusive_gets(bool b) > } > #endif > > +/* > + * mark pampd to special value in order that later > + * retrieve will identify zero-filled pages > + */ > + > /* enable (or fix code) when Seth's patches are accepted upstream */ > #define zcache_writeback_enabled 0 > > @@ -543,7 +548,23 @@ static void *zcache_pampd_eph_create(char *data, size_t size, bool raw, > { > void *pampd = NULL, *cdata = data; > unsigned clen = size; > + bool zero_filled = false; > struct page *page = (struct page *)(data), *newpage; > + char *user_mem; > + > + user_mem = kmap_atomic(page); > + > + /* > + * Compressing zero-filled pages will waste memory and introduce > + * serious fragmentation, skip it to avoid overhead > + */ > + if (page_zero_filled(user_mem)) { > + kunmap_atomic(user_mem); > + clen = 0; > + zero_filled = true; > + goto got_pampd; > + } > + kunmap_atomic(user_mem); > > if (!raw) { > zcache_compress(page, &cdata, &clen); > @@ -592,6 +613,8 @@ got_pampd: > zcache_eph_zpages_max = zcache_eph_zpages; > if (ramster_enabled && raw) > ramster_count_foreign_pages(true, 1); > + if (zero_filled) > + pampd = (void *)ZERO_FILLED; > out: > return pampd; > } > @@ -601,14 +624,31 @@ static void *zcache_pampd_pers_create(char *data, size_t size, bool raw, > { > void *pampd = NULL, *cdata = data; > unsigned clen = size; > + bool zero_filled = false; > struct page *page = (struct page *)(data), *newpage; > unsigned long zbud_mean_zsize; > unsigned long curr_pers_zpages, total_zsize; > + char *user_mem; > > if (data == NULL) { > BUG_ON(!ramster_enabled); > goto create_pampd; > } > + > + user_mem = kmap_atomic(page); > + > + /* > + * Compressing zero-filled pages will waste memory and introduce > + * serious fragmentation, skip it to avoid overhead > + */ > + if (page_zero_filled(page)) { > + kunmap_atomic(user_mem); > + clen = 0; > + zero_filled = true; > + goto got_pampd; > + } > + kunmap_atomic(user_mem); > + > curr_pers_zpages = zcache_pers_zpages; > /* FIXME CONFIG_RAMSTER... subtract atomic remote_pers_pages here? */ > if (!raw) > @@ -674,6 +714,8 @@ got_pampd: > zcache_pers_zbytes_max = zcache_pers_zbytes; > if (ramster_enabled && raw) > ramster_count_foreign_pages(false, 1); > + if (zero_filled) > + pampd = (void *)ZERO_FILLED; > out: > return pampd; > } > @@ -735,7 +777,8 @@ out: > */ > void zcache_pampd_create_finish(void *pampd, bool eph) > { > - zbud_create_finish((struct zbudref *)pampd, eph); > + if (pampd != (void *)ZERO_FILLED) > + zbud_create_finish((struct zbudref *)pampd, eph); > } > > /* > @@ -780,6 +823,14 @@ static int zcache_pampd_get_data(char *data, size_t *sizep, bool raw, > BUG_ON(preemptible()); > BUG_ON(eph); /* fix later if shared pools get implemented */ > BUG_ON(pampd_is_remote(pampd)); > + > + if (pampd == (void *)ZERO_FILLED) { > + handle_zero_page(data); > + if (!raw) > + *sizep = PAGE_SIZE; > + return 0; > + } > + > if (raw) > ret = zbud_copy_from_zbud(data, (struct zbudref *)pampd, > sizep, eph); > @@ -801,12 +852,23 @@ static int zcache_pampd_get_data_and_free(char *data, size_t *sizep, bool raw, > struct tmem_oid *oid, uint32_t index) > { > int ret; > - bool eph = !is_persistent(pool); > + bool eph = !is_persistent(pool), zero_filled = false; > struct page *page = NULL; > unsigned int zsize, zpages; > > BUG_ON(preemptible()); > BUG_ON(pampd_is_remote(pampd)); > + > + if (pampd == (void *)ZERO_FILLED) { > + handle_zero_page(data); > + zero_filled = true; > + zsize = 0; > + zpages = 0; > + if (!raw) > + *sizep = PAGE_SIZE; > + goto zero_fill; > + } > + > if (raw) > ret = zbud_copy_from_zbud(data, (struct zbudref *)pampd, > sizep, eph); > @@ -818,6 +880,7 @@ static int zcache_pampd_get_data_and_free(char *data, size_t *sizep, bool raw, > } > page = zbud_free_and_delist((struct zbudref *)pampd, eph, > &zsize, &zpages); > +zero_fill: > if (eph) { > if (page) > zcache_eph_pageframes = > @@ -837,7 +900,7 @@ static int zcache_pampd_get_data_and_free(char *data, size_t *sizep, bool raw, > } > if (!is_local_client(pool->client)) > ramster_count_foreign_pages(eph, -1); > - if (page) > + if (page && !zero_filled) > zcache_free_page(page); > return ret; > } > @@ -851,16 +914,27 @@ static void zcache_pampd_free(void *pampd, struct tmem_pool *pool, > { > struct page *page = NULL; > unsigned int zsize, zpages; > + bool zero_filled = false; > > BUG_ON(preemptible()); > - if (pampd_is_remote(pampd)) { > + > + if (pampd == (void *)ZERO_FILLED) { > + zero_filled = true; > + zsize = 0; > + zpages = 0; > + } > + > + if (pampd_is_remote(pampd) && !zero_filled) { > + > BUG_ON(!ramster_enabled); > pampd = ramster_pampd_free(pampd, pool, oid, index, acct); > if (pampd == NULL) > return; > } > if (is_ephemeral(pool)) { > - page = zbud_free_and_delist((struct zbudref *)pampd, > + if (!zero_filled) > + page = zbud_free_and_delist((struct zbudref *)pampd, > + > true, &zsize, &zpages); > if (page) > zcache_eph_pageframes = > @@ -883,7 +957,7 @@ static void zcache_pampd_free(void *pampd, struct tmem_pool *pool, > } > if (!is_local_client(pool->client)) > ramster_count_foreign_pages(is_ephemeral(pool), -1); > - if (page) > + if (page && !zero_filled) > zcache_free_page(page); > } > > -- > 1.7.7.6 > From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755989Ab3CPSY7 (ORCPT ); Sat, 16 Mar 2013 14:24:59 -0400 Received: from userp1040.oracle.com ([156.151.31.81]:37470 "EHLO userp1040.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753311Ab3CPSY5 convert rfc822-to-8bit (ORCPT ); Sat, 16 Mar 2013 14:24:57 -0400 MIME-Version: 1.0 Message-ID: <6041f181-67b1-4f71-bd5c-cfb48f1ddfb0@default> Date: Sat, 16 Mar 2013 11:24:20 -0700 (PDT) From: Dan Magenheimer To: Konrad Rzeszutek Wilk , Wanpeng Li Cc: Greg Kroah-Hartman , Andrew Morton , Seth Jennings , Minchan Kim , linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: RE: [PATCH v2 1/4] introduce zero filled pages handler References: <1363255697-19674-1-git-send-email-liwanp@linux.vnet.ibm.com> <1363255697-19674-2-git-send-email-liwanp@linux.vnet.ibm.com> <20130316130302.GA5987@konrad-lan.dumpdata.com> In-Reply-To: <20130316130302.GA5987@konrad-lan.dumpdata.com> X-Priority: 3 X-Mailer: Oracle Beehive Extensions for Outlook 2.0.1.7 (607090) [OL 12.0.6668.5000 (x86)] Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 8BIT X-Source-IP: ucsinet21.oracle.com [156.151.31.93] Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org > From: Konrad Rzeszutek Wilk [mailto:konrad@darnok.org] > Subject: Re: [PATCH v2 1/4] introduce zero filled pages handler > > > + > > + for (pos = 0; pos < PAGE_SIZE / sizeof(*page); pos++) { > > + if (page[pos]) > > + return false; > > Perhaps allocate a static page filled with zeros and just do memcmp? That seems like a bad idea. Why compare two different memory locations when comparing one memory location to a register will do? From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756125Ab3CQM67 (ORCPT ); Sun, 17 Mar 2013 08:58:59 -0400 Received: from mail-pb0-f47.google.com ([209.85.160.47]:42425 "EHLO mail-pb0-f47.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752678Ab3CQM6z (ORCPT ); Sun, 17 Mar 2013 08:58:55 -0400 Message-ID: <5145BE06.8070309@gmail.com> Date: Sun, 17 Mar 2013 20:58:46 +0800 From: Ric Mason User-Agent: Mozilla/5.0 (X11; Linux i686; rv:17.0) Gecko/20130308 Thunderbird/17.0.4 MIME-Version: 1.0 To: Konrad Rzeszutek Wilk CC: Wanpeng Li , Greg Kroah-Hartman , Andrew Morton , Dan Magenheimer , Seth Jennings , Minchan Kim , linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v2 3/4] introduce zero-filled page stat count References: <1363255697-19674-1-git-send-email-liwanp@linux.vnet.ibm.com> <1363255697-19674-4-git-send-email-liwanp@linux.vnet.ibm.com> <20130316130638.GB5987@konrad-lan.dumpdata.com> In-Reply-To: <20130316130638.GB5987@konrad-lan.dumpdata.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Konrad, On 03/16/2013 09:06 PM, Konrad Rzeszutek Wilk wrote: > On Thu, Mar 14, 2013 at 06:08:16PM +0800, Wanpeng Li wrote: >> Introduce zero-filled page statistics to monitor the number of >> zero-filled pages. > Hm, you must be using an older version of the driver. Please > rebase it against Greg KH's staging tree. This is where most if not > all of the DebugFS counters got moved to a different file. It seems that zcache debugfs in Greg's staging-next is buggy, Could you test it? > >> Acked-by: Dan Magenheimer >> Signed-off-by: Wanpeng Li >> --- >> drivers/staging/zcache/zcache-main.c | 7 +++++++ >> 1 files changed, 7 insertions(+), 0 deletions(-) >> >> diff --git a/drivers/staging/zcache/zcache-main.c b/drivers/staging/zcache/zcache-main.c >> index db200b4..2091a4d 100644 >> --- a/drivers/staging/zcache/zcache-main.c >> +++ b/drivers/staging/zcache/zcache-main.c >> @@ -196,6 +196,7 @@ static ssize_t zcache_eph_nonactive_puts_ignored; >> static ssize_t zcache_pers_nonactive_puts_ignored; >> static ssize_t zcache_writtenback_pages; >> static ssize_t zcache_outstanding_writeback_pages; >> +static ssize_t zcache_pages_zero; >> >> #ifdef CONFIG_DEBUG_FS >> #include >> @@ -257,6 +258,7 @@ static int zcache_debugfs_init(void) >> zdfs("outstanding_writeback_pages", S_IRUGO, root, >> &zcache_outstanding_writeback_pages); >> zdfs("writtenback_pages", S_IRUGO, root, &zcache_writtenback_pages); >> + zdfs("pages_zero", S_IRUGO, root, &zcache_pages_zero); >> return 0; >> } >> #undef zdebugfs >> @@ -326,6 +328,7 @@ void zcache_dump(void) >> pr_info("zcache: outstanding_writeback_pages=%zd\n", >> zcache_outstanding_writeback_pages); >> pr_info("zcache: writtenback_pages=%zd\n", zcache_writtenback_pages); >> + pr_info("zcache: pages_zero=%zd\n", zcache_pages_zero); >> } >> #endif >> >> @@ -562,6 +565,7 @@ static void *zcache_pampd_eph_create(char *data, size_t size, bool raw, >> kunmap_atomic(user_mem); >> clen = 0; >> zero_filled = true; >> + zcache_pages_zero++; >> goto got_pampd; >> } >> kunmap_atomic(user_mem); >> @@ -645,6 +649,7 @@ static void *zcache_pampd_pers_create(char *data, size_t size, bool raw, >> kunmap_atomic(user_mem); >> clen = 0; >> zero_filled = true; >> + zcache_pages_zero++; >> goto got_pampd; >> } >> kunmap_atomic(user_mem); >> @@ -866,6 +871,7 @@ static int zcache_pampd_get_data_and_free(char *data, size_t *sizep, bool raw, >> zpages = 0; >> if (!raw) >> *sizep = PAGE_SIZE; >> + zcache_pages_zero--; >> goto zero_fill; >> } >> >> @@ -922,6 +928,7 @@ static void zcache_pampd_free(void *pampd, struct tmem_pool *pool, >> zero_filled = true; >> zsize = 0; >> zpages = 0; >> + zcache_pages_zero--; >> } >> >> if (pampd_is_remote(pampd) && !zero_filled) { >> -- >> 1.7.7.6 >> > -- > To unsubscribe, send a message with 'unsubscribe linux-mm' in > the body to majordomo@kvack.org. For more info on Linux MM, > see: http://www.linux-mm.org/ . > Don't email: email@kvack.org From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933151Ab3CSQlx (ORCPT ); Tue, 19 Mar 2013 12:41:53 -0400 Received: from mail-wi0-f171.google.com ([209.85.212.171]:43236 "EHLO mail-wi0-f171.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756996Ab3CSQlv (ORCPT ); Tue, 19 Mar 2013 12:41:51 -0400 MIME-Version: 1.0 Reply-To: konrad@darnok.org In-Reply-To: <5145BE06.8070309@gmail.com> References: <1363255697-19674-1-git-send-email-liwanp@linux.vnet.ibm.com> <1363255697-19674-4-git-send-email-liwanp@linux.vnet.ibm.com> <20130316130638.GB5987@konrad-lan.dumpdata.com> <5145BE06.8070309@gmail.com> Date: Tue, 19 Mar 2013 12:41:49 -0400 X-Google-Sender-Auth: AK_xzE0rjFa2qWGz9zVputyTneM Message-ID: Subject: Re: [PATCH v2 3/4] introduce zero-filled page stat count From: Konrad Rzeszutek Wilk To: Ric Mason Cc: Wanpeng Li , Greg Kroah-Hartman , Andrew Morton , Dan Magenheimer , Seth Jennings , Minchan Kim , linux-mm@kvack.org, linux-kernel@vger.kernel.org Content-Type: text/plain; charset=ISO-8859-1 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sun, Mar 17, 2013 at 8:58 AM, Ric Mason wrote: > Hi Konrad, > > On 03/16/2013 09:06 PM, Konrad Rzeszutek Wilk wrote: >> >> On Thu, Mar 14, 2013 at 06:08:16PM +0800, Wanpeng Li wrote: >>> >>> Introduce zero-filled page statistics to monitor the number of >>> zero-filled pages. >> >> Hm, you must be using an older version of the driver. Please >> rebase it against Greg KH's staging tree. This is where most if not >> all of the DebugFS counters got moved to a different file. > > > It seems that zcache debugfs in Greg's staging-next is buggy, Could you test > it? > Could you email me what the issue you are seeing? From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1757187Ab3CSQoY (ORCPT ); Tue, 19 Mar 2013 12:44:24 -0400 Received: from mail-wi0-f181.google.com ([209.85.212.181]:40034 "EHLO mail-wi0-f181.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1757097Ab3CSQoX (ORCPT ); Tue, 19 Mar 2013 12:44:23 -0400 MIME-Version: 1.0 Reply-To: konrad@darnok.org In-Reply-To: <6041f181-67b1-4f71-bd5c-cfb48f1ddfb0@default> References: <1363255697-19674-1-git-send-email-liwanp@linux.vnet.ibm.com> <1363255697-19674-2-git-send-email-liwanp@linux.vnet.ibm.com> <20130316130302.GA5987@konrad-lan.dumpdata.com> <6041f181-67b1-4f71-bd5c-cfb48f1ddfb0@default> Date: Tue, 19 Mar 2013 12:44:22 -0400 X-Google-Sender-Auth: _PZ5MIBa8xXSl6N9eXZVJ-5tlRc Message-ID: Subject: Re: [PATCH v2 1/4] introduce zero filled pages handler From: Konrad Rzeszutek Wilk To: Dan Magenheimer Cc: Wanpeng Li , Greg Kroah-Hartman , Andrew Morton , Seth Jennings , Minchan Kim , linux-mm@kvack.org, linux-kernel@vger.kernel.org Content-Type: text/plain; charset=ISO-8859-1 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sat, Mar 16, 2013 at 2:24 PM, Dan Magenheimer wrote: >> From: Konrad Rzeszutek Wilk [mailto:konrad@darnok.org] >> Subject: Re: [PATCH v2 1/4] introduce zero filled pages handler >> >> > + >> > + for (pos = 0; pos < PAGE_SIZE / sizeof(*page); pos++) { >> > + if (page[pos]) >> > + return false; >> >> Perhaps allocate a static page filled with zeros and just do memcmp? > > That seems like a bad idea. Why compare two different > memory locations when comparing one memory location > to a register will do? > Good point. I was hoping there was an fast memcmp that would do fancy SSE registers. But it is memory against memory instead of registers. Perhaps a cunning trick would be to check (as a shortcircuit) check against 'empty_zero_page' and if that check fails, then try to do the check for each byte in the code? > From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S934351Ab3CSXio (ORCPT ); Tue, 19 Mar 2013 19:38:44 -0400 Received: from mail-pb0-f53.google.com ([209.85.160.53]:50373 "EHLO mail-pb0-f53.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1757276Ab3CSXin (ORCPT ); Tue, 19 Mar 2013 19:38:43 -0400 Message-ID: <5148F565.7060809@gmail.com> Date: Wed, 20 Mar 2013 07:31:49 +0800 From: Ric Mason User-Agent: Mozilla/5.0 (X11; Linux i686; rv:17.0) Gecko/20130308 Thunderbird/17.0.4 MIME-Version: 1.0 To: konrad@darnok.org CC: Wanpeng Li , Greg Kroah-Hartman , Andrew Morton , Dan Magenheimer , Seth Jennings , Minchan Kim , linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v2 3/4] introduce zero-filled page stat count References: <1363255697-19674-1-git-send-email-liwanp@linux.vnet.ibm.com> <1363255697-19674-4-git-send-email-liwanp@linux.vnet.ibm.com> <20130316130638.GB5987@konrad-lan.dumpdata.com> <5145BE06.8070309@gmail.com> In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 03/20/2013 12:41 AM, Konrad Rzeszutek Wilk wrote: > On Sun, Mar 17, 2013 at 8:58 AM, Ric Mason wrote: >> Hi Konrad, >> >> On 03/16/2013 09:06 PM, Konrad Rzeszutek Wilk wrote: >>> On Thu, Mar 14, 2013 at 06:08:16PM +0800, Wanpeng Li wrote: >>>> Introduce zero-filled page statistics to monitor the number of >>>> zero-filled pages. >>> Hm, you must be using an older version of the driver. Please >>> rebase it against Greg KH's staging tree. This is where most if not >>> all of the DebugFS counters got moved to a different file. >> >> It seems that zcache debugfs in Greg's staging-next is buggy, Could you test >> it? >> > Could you email me what the issue you are seeing? They have already fixed in Wanpeng's patchset v4. From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1758857Ab3CYTIW (ORCPT ); Mon, 25 Mar 2013 15:08:22 -0400 Received: from aserp1040.oracle.com ([141.146.126.69]:27145 "EHLO aserp1040.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1758811Ab3CYTIV convert rfc822-to-8bit (ORCPT ); Mon, 25 Mar 2013 15:08:21 -0400 MIME-Version: 1.0 Message-ID: <80f208d0-c0e9-4d38-9085-99866f7ee5d7@default> Date: Mon, 25 Mar 2013 12:07:38 -0700 (PDT) From: Dan Magenheimer To: konrad@darnok.org, Konrad Wilk Cc: Wanpeng Li , Greg Kroah-Hartman , Andrew Morton , Seth Jennings , Minchan Kim , linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: RE: [PATCH v2 1/4] introduce zero filled pages handler References: <1363255697-19674-1-git-send-email-liwanp@linux.vnet.ibm.com> <1363255697-19674-2-git-send-email-liwanp@linux.vnet.ibm.com> <20130316130302.GA5987@konrad-lan.dumpdata.com> <6041f181-67b1-4f71-bd5c-cfb48f1ddfb0@default> In-Reply-To: X-Priority: 3 X-Mailer: Oracle Beehive Extensions for Outlook 2.0.1.7 (607090) [OL 12.0.6668.5000 (x86)] Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 8BIT X-Source-IP: ucsinet21.oracle.com [156.151.31.93] Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org > From: Konrad Rzeszutek Wilk [mailto:konrad@darnok.org] > Sent: Tuesday, March 19, 2013 10:44 AM > To: Dan Magenheimer > Cc: Wanpeng Li; Greg Kroah-Hartman; Andrew Morton; Seth Jennings; Minchan Kim; linux-mm@kvack.org; > linux-kernel@vger.kernel.org > Subject: Re: [PATCH v2 1/4] introduce zero filled pages handler > > On Sat, Mar 16, 2013 at 2:24 PM, Dan Magenheimer > wrote: > >> From: Konrad Rzeszutek Wilk [mailto:konrad@darnok.org] > >> Subject: Re: [PATCH v2 1/4] introduce zero filled pages handler > >> > >> > + > >> > + for (pos = 0; pos < PAGE_SIZE / sizeof(*page); pos++) { > >> > + if (page[pos]) > >> > + return false; > >> > >> Perhaps allocate a static page filled with zeros and just do memcmp? > > > > That seems like a bad idea. Why compare two different > > memory locations when comparing one memory location > > to a register will do? > > Good point. I was hoping there was an fast memcmp that would > do fancy SSE registers. But it is memory against memory instead of > registers. > > Perhaps a cunning trick would be to check (as a shortcircuit) > check against 'empty_zero_page' and if that check fails, then try > to do the check for each byte in the code? Curious about this, I added some code to check for this case. In my test run, the conditional "if (page == ZERO_PAGE(0))" was never true, for >200000 pages passed through frontswap that were zero-filled. My test run is certainly not conclusive, but perhaps some other code in the swap subsystem disqualifies ZERO_PAGE as a candidate for swapping? Or maybe it is accessed frequently enough that it never falls out of the active-anonymous page queue? Dan P.S. In arch/x86/include/asm/pgtable.h: #define ZERO_PAGE(vaddr) (virt_to_page(empty_zero_page))