Skip to contentSkip to conversation

staging: zcache: Support zero-filled pages more efficiently

PATCH In review Wanpeng Li 4 participants 17 messages Apr 3, 2013 – Apr 10, 2013 1 message not in the archive

Subsystems (2)
lore
Share & tools
lore

Wanpeng Li

author
#0 lore raw

v6 cover staging: zcache: Support zero-filled pages more efficiently

Changelog:
v5 -> v6:
* shove variables in debug.c and in debug.h just have an extern, spotted by Konrad
* update patch description, spotted by Konrad
v4 -> v5:
* fix compile error, reported by Fengguang, Geert
* add check for !is_ephemeral(pool), spotted by Bob
v3 -> v4:
* handle duplication in page_is_zero_filled, spotted by Bob
* fix zcache writeback in dubugfs
* fix pers_pageframes|_max isn't exported in debugfs
* fix static variable defined in debug.h but used in multiple C files
* rebase on Greg's staging-next
v2 -> v3:
* increment/decrement zcache_[eph|pers]_zpages for zero-filled pages, spotted by Dan
* replace "zero" or "zero page" by "zero_filled_page", spotted by Dan
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 (3):
staging: zcache: fix static variables defined in debug.h but used in
mutiple C files
staging: zcache: introduce zero-filled page stat count
staging: zcache: clean TODO list

 drivers/staging/zcache/TODO          |    3 +-
 drivers/staging/zcache/debug.c       |   35 +++++++++++++++
 drivers/staging/zcache/debug.h       |   79 ++++++++++++++++++++-------------
 drivers/staging/zcache/zcache-main.c |    4 ++
 4 files changed, 88 insertions(+), 33 deletions(-)
Signature · 7 lines
1.7.5.4

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to [email protected].  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
author
#1 lore raw

PATCH v6 1/3 staging: zcache: fix static variables defined in debug.h but used in mutiple C files

After commit 95bdaee214 ("zcache: Move debugfs code out of zcache-main.c file") be merged, most of knods in zcache debugfs just export zero since these variables are defined in debug.h but are in use in multiple C files zcache-main.c and debug.c, in this case variables can't be treated as shared variables.

---
 drivers/staging/zcache/debug.c |   32 ++++++++++++++++++++
 drivers/staging/zcache/debug.h |   62 ++++++++++++++++++++--------------------
 2 files changed, 63 insertions(+), 31 deletions(-)
drivers/staging/zcache/debug.c +32 -0
index d2d1fdf..faab2a9 100644
@@ -4,6 +4,38 @@
 #ifdef CONFIG_ZCACHE_DEBUG
 #include <linux/debugfs.h>
 
+ssize_t zcache_obj_count;
+ssize_t zcache_obj_count_max;
+ssize_t zcache_objnode_count;
+ssize_t zcache_objnode_count_max;
+u64 zcache_eph_zbytes;
+u64 zcache_eph_zbytes_max;
+u64 zcache_pers_zbytes_max;
+ssize_t zcache_eph_pageframes_max;
+ssize_t zcache_pers_pageframes_max;
+ssize_t zcache_pageframes_alloced;
+ssize_t zcache_pageframes_freed;
+ssize_t zcache_eph_zpages;
+ssize_t zcache_eph_zpages_max;
+ssize_t zcache_pers_zpages_max;
+ssize_t zcache_flush_total;
+ssize_t zcache_flush_found;
+ssize_t zcache_flobj_total;
+ssize_t zcache_flobj_found;
+ssize_t zcache_failed_eph_puts;
+ssize_t zcache_failed_pers_puts;
+ssize_t zcache_failed_getfreepages;
+ssize_t zcache_failed_alloc;
+ssize_t zcache_put_to_flush;
+ssize_t zcache_compress_poor;
+ssize_t zcache_mean_compress_poor;
+ssize_t zcache_eph_ate_tail;
+ssize_t zcache_eph_ate_tail_failed;
+ssize_t zcache_pers_ate_eph;
+ssize_t zcache_pers_ate_eph_failed;
+ssize_t zcache_evicted_eph_zpages;
+ssize_t zcache_evicted_eph_pageframes;
+
 #define ATTR(x)  { .name = #x, .val = &zcache_##x, }
 static struct debug_entry {
 	const char *name;
drivers/staging/zcache/debug.h +31 -31

130 lines not on this page · raw message

Signature · 7 lines
1.7.5.4

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to [email protected].  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
author
#3 lore raw

PATCH v6 2/3 staging: zcache: introduce zero-filled page stat count

In reply to Wanpeng Li

Introduce zero-filled page statistics to monitor the number of zero-filled pages.

---
 drivers/staging/zcache/debug.c       |    3 +++
 drivers/staging/zcache/debug.h       |   17 +++++++++++++++++
 drivers/staging/zcache/zcache-main.c |    4 ++++
 3 files changed, 24 insertions(+), 0 deletions(-)
drivers/staging/zcache/debug.c +3 -0
index faab2a9..daa2691 100644
@@ -35,6 +35,8 @@ ssize_t zcache_pers_ate_eph;
 ssize_t zcache_pers_ate_eph_failed;
 ssize_t zcache_evicted_eph_zpages;
 ssize_t zcache_evicted_eph_pageframes;
+ssize_t zcache_zero_filled_pages;
+ssize_t zcache_zero_filled_pages_max;
 
 #define ATTR(x)  { .name = #x, .val = &zcache_##x, }
 static struct debug_entry {
@@ -62,6 +64,7 @@ static struct debug_entry {
 	ATTR(last_inactive_anon_pageframes),
 	ATTR(eph_nonactive_puts_ignored),
 	ATTR(pers_nonactive_puts_ignored),
+	ATTR(zero_filled_pages),
 #ifdef CONFIG_ZCACHE_WRITEBACK
 	ATTR(outstanding_writeback_pages),
 	ATTR(writtenback_pages),
drivers/staging/zcache/debug.h +17 -0
index 8ec82d4..ddad92f 100644
@@ -122,6 +122,21 @@ static inline void dec_zcache_pers_zpages(unsigned zpages)
 	zcache_pers_zpages = atomic_sub_return(zpages, &zcache_pers_zpages_atomic);
 }
 
+extern ssize_t zcache_zero_filled_pages;
+static atomic_t zcache_zero_filled_pages_atomic = ATOMIC_INIT(0);
+extern ssize_t zcache_zero_filled_pages_max;
+static inline void inc_zcache_zero_filled_pages(void)
+{
+	zcache_zero_filled_pages = atomic_inc_return(
+					&zcache_zero_filled_pages_atomic);
+	if (zcache_zero_filled_pages > zcache_zero_filled_pages_max)
+		zcache_zero_filled_pages_max = zcache_zero_filled_pages;
+}
+static inline void dec_zcache_zero_filled_pages(void)
+{
+	zcache_zero_filled_pages = atomic_dec_return(
+					&zcache_zero_filled_pages_atomic);
+}
 static inline unsigned long curr_pageframes_count(void)
 {
 	return zcache_pageframes_alloced -
@@ -200,6 +215,8 @@ static inline void inc_zcache_eph_zpages(void) { };
 static inline void dec_zcache_eph_zpages(unsigned zpages) { };
 static inline void inc_zcache_pers_zpages(void) { };
 static inline void dec_zcache_pers_zpages(unsigned zpages) { };
+static inline void inc_zcache_zero_filled_pages(void) { };
+static inline void dec_zcache_zero_filled_pages(void) { };
 static inline unsigned long curr_pageframes_count(void)
 {
 	return 0;
drivers/staging/zcache/zcache-main.c +4 -0
index 1994cab..f3de76d 100644
@@ -374,6 +374,7 @@ static void *zcache_pampd_eph_create(char *data, size_t size, bool raw,
 	if (page_is_zero_filled(page)) {
 		clen = 0;
 		zero_filled = true;
+		inc_zcache_zero_filled_pages();
 		goto got_pampd;
 	}
 
@@ -440,6 +441,7 @@ static void *zcache_pampd_pers_create(char *data, size_t size, bool raw,
 	if (page_is_zero_filled(page)) {
 		clen = 0;
 		zero_filled = true;
+		inc_zcache_zero_filled_pages();
 		goto got_pampd;
 	}
 
@@ -652,6 +654,7 @@ static int zcache_pampd_get_data_and_free(char *data, size_t *sizep, bool raw,
 		zpages = 1;
 		if (!raw)
 			*sizep = PAGE_SIZE;
+		dec_zcache_zero_filled_pages();
 		goto zero_fill;
 	}
 
@@ -702,6 +705,7 @@ static void zcache_pampd_free(void *pampd, struct tmem_pool *pool,
 		zero_filled = true;
 		zsize = 0;
 		zpages = 1;
+		dec_zcache_zero_filled_pages();
 	}
 
 	if (pampd_is_remote(pampd) && !zero_filled) {
Signature · 7 lines
1.7.5.4

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to [email protected].  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
author
#5 lore raw

PATCH v2 3/3 staging: zcache: clean TODO list

In reply to Wanpeng Li

Cleanup TODO list since support zero-filled pages more efficiently has already done by this patchset.

---
 drivers/staging/zcache/TODO |    3 +--
 1 files changed, 1 insertions(+), 2 deletions(-)
drivers/staging/zcache/TODO +1 -2
index ec9aa11..d0c18fa 100644
@@ -61,5 +61,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
Signature · 7 lines
1.7.5.4

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to [email protected].  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
Reviewed-by on v6 2/3
#4 lore raw

Re: [PATCH v6 2/3] staging: zcache: introduce zero-filled page stat count

In reply to Wanpeng Li
Quoted 5 lines · Wanpeng Li

Introduce zero-filled page statistics to monitor the number of zero-filled pages.

Quoted 99 lines
---
 drivers/staging/zcache/debug.c       |    3 +++
 drivers/staging/zcache/debug.h       |   17 +++++++++++++++++
 drivers/staging/zcache/zcache-main.c |    4 ++++
 3 files changed, 24 insertions(+), 0 deletions(-)
drivers/staging/zcache/debug.c +3 -0
index faab2a9..daa2691 100644
@@ -35,6 +35,8 @@ ssize_t zcache_pers_ate_eph;
 ssize_t zcache_pers_ate_eph_failed;
 ssize_t zcache_evicted_eph_zpages;
 ssize_t zcache_evicted_eph_pageframes;
+ssize_t zcache_zero_filled_pages;
+ssize_t zcache_zero_filled_pages_max;
 
 #define ATTR(x)  { .name = #x, .val = &zcache_##x, }
 static struct debug_entry {
@@ -62,6 +64,7 @@ static struct debug_entry {
        ATTR(last_inactive_anon_pageframes),
        ATTR(eph_nonactive_puts_ignored),
        ATTR(pers_nonactive_puts_ignored),
+       ATTR(zero_filled_pages),
 #ifdef CONFIG_ZCACHE_WRITEBACK
        ATTR(outstanding_writeback_pages),
        ATTR(writtenback_pages),
drivers/staging/zcache/debug.h +17 -0
index 8ec82d4..ddad92f 100644
@@ -122,6 +122,21 @@ static inline void dec_zcache_pers_zpages(unsigned zpages)
        zcache_pers_zpages = atomic_sub_return(zpages, &zcache_pers_zpages_atomic);
 }
 
+extern ssize_t zcache_zero_filled_pages;
+static atomic_t zcache_zero_filled_pages_atomic = ATOMIC_INIT(0);
+extern ssize_t zcache_zero_filled_pages_max;
+static inline void inc_zcache_zero_filled_pages(void)
+{
+       zcache_zero_filled_pages = atomic_inc_return(
+                                       &zcache_zero_filled_pages_atomic);
+       if (zcache_zero_filled_pages > zcache_zero_filled_pages_max)
+               zcache_zero_filled_pages_max = zcache_zero_filled_pages;
+}
+static inline void dec_zcache_zero_filled_pages(void)
+{
+       zcache_zero_filled_pages = atomic_dec_return(
+                                       &zcache_zero_filled_pages_atomic);
+}
 static inline unsigned long curr_pageframes_count(void)
 {
        return zcache_pageframes_alloced -
@@ -200,6 +215,8 @@ static inline void inc_zcache_eph_zpages(void) { };
 static inline void dec_zcache_eph_zpages(unsigned zpages) { };
 static inline void inc_zcache_pers_zpages(void) { };
 static inline void dec_zcache_pers_zpages(unsigned zpages) { };
+static inline void inc_zcache_zero_filled_pages(void) { };
+static inline void dec_zcache_zero_filled_pages(void) { };
 static inline unsigned long curr_pageframes_count(void)
 {
        return 0;
drivers/staging/zcache/zcache-main.c +4 -1
index 1994cab..f3de76d 100644
@@ -374,6 +374,7 @@ static void *zcache_pampd_eph_create(char *data, size_t size, bool raw,
        if (page_is_zero_filled(page)) {
                clen = 0;
                zero_filled = true;
+               inc_zcache_zero_filled_pages();
                goto got_pampd;
        }
 
@@ -440,6 +441,7 @@ static void *zcache_pampd_pers_create(char *data, size_t size, bool raw,
        if (page_is_zero_filled(page)) {
                clen = 0;
                zero_filled = true;
+               inc_zcache_zero_filled_pages();
                goto got_pampd;
        }
 
@@ -652,6 +654,7 @@ static int zcache_pampd_get_data_and_free(char *data, size_t *sizep, bool raw,
                zpages = 1;
                if (!raw)
                        *sizep = PAGE_SIZE;
+               dec_zcache_zero_filled_pages();
                goto zero_fill;
        }
 
@@ -702,6 +705,7 @@ static void zcache_pampd_free(void *pampd, struct tmem_pool *pool,
                zero_filled = true;
                zsize = 0;
                zpages = 1;
+               dec_zcache_zero_filled_pages();
        }
 
        if (pampd_is_remote(pampd) && !zero_filled) {
--
Quoted 2 lines

1.7.5.4

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>

Reviewed-by on v6 1/3
#2 lore raw

Re: [PATCH v6 1/3] staging: zcache: fix static variables defined in debug.h but used in mutiple C files

In reply to Wanpeng Li
Quoted 6 lines · Wanpeng Li

After commit 95bdaee214 ("zcache: Move debugfs code out of zcache-main.c file") be merged, most of knods in zcache debugfs just export zero since these variables are defined in debug.h but are in use in multiple C files zcache-main.c and debug.c, in this case variables can't be treated as shared variables.

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>

author
#6 lore raw
In reply to Wanpeng Li
Quoted 14 lines · Wanpeng Li

Changelog:
v5 -> v6:
* shove variables in debug.c and in debug.h just have an extern, spotted by Konrad
* update patch description, spotted by Konrad
v4 -> v5:
* fix compile error, reported by Fengguang, Geert
* add check for !is_ephemeral(pool), spotted by Bob
v3 -> v4:
* handle duplication in page_is_zero_filled, spotted by Bob
* fix zcache writeback in dubugfs
* fix pers_pageframes|_max isn't exported in debugfs
* fix static variable defined in debug.h but used in multiple C files
* rebase on Greg's staging-next
v2 -> v3:

Quoted 9 lines

* increment/decrement zcache_[eph|pers]_zpages for zero-filled pages, spotted by Dan
* replace "zero" or "zero page" by "zero_filled_page", spotted by Dan
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.

Hi Dan,

Some issues against Ramster:

- Ramster who takes advantage of zcache also should support zero-filled pages more efficiently, correct? It doesn't handle zero-filled pages well currently.
- Ramster DebugFS counters are exported in /sys/kernel/mm/, but zcache/frontswap/cleancache all are exported in /sys/kernel/debug/, should we unify them?
- If ramster also should move DebugFS counters to a single file like
zcache do?

If you confirm these issues are make sense to fix, I will start coding. ;-)

Regards,
Wanpeng Li

Quoted 47 lines

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 (3):
staging: zcache: fix static variables defined in debug.h but used in
mutiple C files
staging: zcache: introduce zero-filled page stat count
staging: zcache: clean TODO list

Quoted 8 lines
drivers/staging/zcache/TODO          |    3 +-
drivers/staging/zcache/debug.c       |   35 +++++++++++++++
drivers/staging/zcache/debug.h       |   79 ++++++++++++++++++++-------------
drivers/staging/zcache/zcache-main.c |    4 ++
4 files changed, 88 insertions(+), 33 deletions(-)
Signature · 1 line
1.7.5.4

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>

author
#15 lore raw
In reply to Wanpeng Li
Quoted 14 lines · Wanpeng Li

Changelog:
v5 -> v6:
* shove variables in debug.c and in debug.h just have an extern, spotted by Konrad
* update patch description, spotted by Konrad
v4 -> v5:
* fix compile error, reported by Fengguang, Geert
* add check for !is_ephemeral(pool), spotted by Bob
v3 -> v4:
* handle duplication in page_is_zero_filled, spotted by Bob
* fix zcache writeback in dubugfs
* fix pers_pageframes|_max isn't exported in debugfs
* fix static variable defined in debug.h but used in multiple C files
* rebase on Greg's staging-next
v2 -> v3:

Quoted 9 lines

* increment/decrement zcache_[eph|pers]_zpages for zero-filled pages, spotted by Dan
* replace "zero" or "zero page" by "zero_filled_page", spotted by Dan
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.

Hi Dan,

Some issues against Ramster:

- Ramster who takes advantage of zcache also should support zero-filled pages more efficiently, correct? It doesn't handle zero-filled pages well currently.
- Ramster DebugFS counters are exported in /sys/kernel/mm/, but zcache/frontswap/cleancache all are exported in /sys/kernel/debug/, should we unify them?
- If ramster also should move DebugFS counters to a single file like
zcache do?

If you confirm these issues are make sense to fix, I will start coding. ;-)

Regards,
Wanpeng Li

Quoted 47 lines

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 (3):
staging: zcache: fix static variables defined in debug.h but used in
mutiple C files
staging: zcache: introduce zero-filled page stat count
staging: zcache: clean TODO list

Quoted 8 lines
drivers/staging/zcache/TODO          |    3 +-
drivers/staging/zcache/debug.c       |   35 +++++++++++++++
drivers/staging/zcache/debug.h       |   79 ++++++++++++++++++++-------------
drivers/staging/zcache/zcache-main.c |    4 ++
4 files changed, 88 insertions(+), 33 deletions(-)
Signature · 1 line
1.7.5.4

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>

#17 lore raw
In reply to a message not in the archive

cc Bob

Quoted 94 lines · Wanpeng Li
Quoted 14 lines · Wanpeng Li

Changelog:
v5 -> v6:
* shove variables in debug.c and in debug.h just have an extern, spotted by Konrad
* update patch description, spotted by Konrad
v4 -> v5:
* fix compile error, reported by Fengguang, Geert
* add check for !is_ephemeral(pool), spotted by Bob
v3 -> v4:
* handle duplication in page_is_zero_filled, spotted by Bob
* fix zcache writeback in dubugfs
* fix pers_pageframes|_max isn't exported in debugfs
* fix static variable defined in debug.h but used in multiple C files
* rebase on Greg's staging-next
v2 -> v3:

Quoted 9 lines

* increment/decrement zcache_[eph|pers]_zpages for zero-filled pages, spotted by Dan
* replace "zero" or "zero page" by "zero_filled_page", spotted by Dan
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.

Hi Dan,

Some issues against Ramster:

- Ramster who takes advantage of zcache also should support zero-filled pages more efficiently, correct? It doesn't handle zero-filled pages well currently.
- Ramster DebugFS counters are exported in /sys/kernel/mm/, but zcache/frontswap/cleancache all are exported in /sys/kernel/debug/, should we unify them?
- If ramster also should move DebugFS counters to a single file like
zcache do?

If you confirm these issues are make sense to fix, I will start coding. ;-)

Regards,
Wanpeng Li

Quoted 53 lines

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 (3):
staging: zcache: fix static variables defined in debug.h but used in
mutiple C files
staging: zcache: introduce zero-filled page stat count
staging: zcache: clean TODO list

drivers/staging/zcache/TODO          |    3 +-
drivers/staging/zcache/debug.c       |   35 +++++++++++++++
drivers/staging/zcache/debug.h       |   79 ++++++++++++++++++++-------------
drivers/staging/zcache/zcache-main.c |    4 ++
4 files changed, 88 insertions(+), 33 deletions(-)
Quoted 7 lines
Quoted 2 lines
Signature · 1 line
1.7.5.4

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>

#7 lore raw
In reply to Wanpeng Li
Quoted 10 lines

From: Wanpeng Li [mailto:[email protected]]
Subject: Re: [PATCH part2 v6 0/3] staging: zcache: Support zero-filled pages more efficiently

Hi Dan,

Some issues against Ramster:

- Ramster who takes advantage of zcache also should support zero-filled pages more efficiently, correct? It doesn't handle zero-filled pages well currently.

When you first posted your patchset I took a quick look at ramster and it looked like your patchset should work for ramster also. However I didn't actually run ramster to try it so there may be a bug. If it doesn't work, I would very much appreciate a patch.

Quoted 2 lines

- Ramster DebugFS counters are exported in /sys/kernel/mm/, but zcache/frontswap/cleancache all are exported in /sys/kernel/debug/, should we unify them?

That would be great.

Quoted 2 lines

- If ramster also should move DebugFS counters to a single file like zcache do?

Sure! I am concerned about Konrad's patches adding debug.c as they add many global variables. They are only required when ZCACHE_DEBUG is enabled so they may be ok. If not, adding ramster variables to debug.c may make the problem worse.

Quoted 1 line

If you confirm these issues are make sense to fix, I will start coding. ;-)

That would be great. Note that I have a how-to for ramster here:

https://oss.oracle.com/projects/tmem/dist/files/RAMster/HOWTO-120817

If when you are testing you find that this how-to has mistakes, please let me know. Or feel free to add the (corrected) how-to file as a patch in your patchset.

Thanks very much, Wanpeng, for your great contributions!

(Ric, since you have expressed interest in ramster, if you try it and find corrections to the how-to file above, your input would be very much appreciated also!)

Dan

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>

#8 lore raw
Quoted 8 lines

From: Dan Magenheimer
Subject: RE: [PATCH part2 v6 0/3] staging: zcache: Support zero-filled pages more efficiently

Quoted 5 lines

From: Wanpeng Li [mailto:[email protected]]
Subject: Re: [PATCH part2 v6 0/3] staging: zcache: Support zero-filled pages more efficiently

Hi Dan,

Quoted 7 lines
Quoted 2 lines

Some issues against Ramster:

Sure! I am concerned about Konrad's patches adding debug.c as they add many global variables. They are only required when ZCACHE_DEBUG is enabled so they may be ok. If not, adding ramster variables to debug.c may make the problem worse.

Oops, I just noticed/remembered that ramster uses BOTH debugfs and sysfs. The sysfs variables are all currently required, i.e. for configuration so should not be tied to debugfs or a DEBUG config option. However, if there is a more acceptable way to implement the function of those sysfs variables, that would be fine.

Thanks,
Dan

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>

author
#9 lore raw
Quoted 16 lines · Dan Magenheimer
Quoted 8 lines

From: Dan Magenheimer
Subject: RE: [PATCH part2 v6 0/3] staging: zcache: Support zero-filled pages more efficiently

Quoted 5 lines

From: Wanpeng Li [mailto:[email protected]]
Subject: Re: [PATCH part2 v6 0/3] staging: zcache: Support zero-filled pages more efficiently

Hi Dan,

Quoted 7 lines
Quoted 2 lines

Some issues against Ramster:

Sure! I am concerned about Konrad's patches adding debug.c as they add many global variables. They are only required when ZCACHE_DEBUG is enabled so they may be ok. If not, adding ramster variables to debug.c may make the problem worse.

Quoted 5 lines

Oops, I just noticed/remembered that ramster uses BOTH debugfs and sysfs. The sysfs variables are all currently required, i.e. for configuration so should not be tied to debugfs or a DEBUG config option. However, if there is a more acceptable way to implement the function of those sysfs variables, that would be fine.

So if we need move debugfs counters to a single debug.c in zcache/ramster/ and introduce RAMSTER_DEBUG? The work similiar as Konrad done against zcache. ;-)

Regards,
Wanpeng Li

Quoted 9 lines

Thanks,
Dan

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>

author
#10 lore raw
In reply to Dan Magenheimer
Quoted 16 lines · Dan Magenheimer
Quoted 8 lines

From: Dan Magenheimer
Subject: RE: [PATCH part2 v6 0/3] staging: zcache: Support zero-filled pages more efficiently

Quoted 5 lines

From: Wanpeng Li [mailto:[email protected]]
Subject: Re: [PATCH part2 v6 0/3] staging: zcache: Support zero-filled pages more efficiently

Hi Dan,

Quoted 7 lines
Quoted 2 lines

Some issues against Ramster:

Sure! I am concerned about Konrad's patches adding debug.c as they add many global variables. They are only required when ZCACHE_DEBUG is enabled so they may be ok. If not, adding ramster variables to debug.c may make the problem worse.

Quoted 5 lines

Oops, I just noticed/remembered that ramster uses BOTH debugfs and sysfs. The sysfs variables are all currently required, i.e. for configuration so should not be tied to debugfs or a DEBUG config option. However, if there is a more acceptable way to implement the function of those sysfs variables, that would be fine.

So if we need move debugfs counters to a single debug.c in zcache/ramster/ and introduce RAMSTER_DEBUG? The work similiar as Konrad done against zcache. ;-)

Regards,
Wanpeng Li

Quoted 9 lines

Thanks,
Dan

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>

author
#11 lore raw
In reply to Dan Magenheimer
Quoted 7 lines · Dan Magenheimer
Quoted 7 lines

From: Wanpeng Li [mailto:[email protected]]
Subject: Re: [PATCH part2 v6 0/3] staging: zcache: Support zero-filled pages more efficiently

Hi Dan,

Some issues against Ramster:

Quoted 9 lines
Quoted 3 lines

- Ramster who takes advantage of zcache also should support zero-filled pages more efficiently, correct? It doesn't handle zero-filled pages well currently.

When you first posted your patchset I took a quick look at ramster and it looked like your patchset should work for ramster also. However I didn't actually run ramster to try it so there may be a bug. If it doesn't work, I would very much appreciate a patch.

I have already fix it. ;-)

Quoted 5 lines
Quoted 2 lines

- Ramster DebugFS counters are exported in /sys/kernel/mm/, but zcache/frontswap/cleancache all are exported in /sys/kernel/debug/, should we unify them?

That would be great.

Quoted 7 lines
Quoted 2 lines

- If ramster also should move DebugFS counters to a single file like zcache do?

Sure! I am concerned about Konrad's patches adding debug.c as they add many global variables. They are only required when ZCACHE_DEBUG is enabled so they may be ok. If not, adding ramster variables to debug.c may make the problem worse.

I move counters which use dubugfs to single file in zcache/ramster/ and introduce CONFIG_RAMSTER_DEBUG, patchset has already done and under test.

Quoted 11 lines
Quoted 2 lines

If you confirm these issues are make sense to fix, I will start coding. ;-)

That would be great. Note that I have a how-to for ramster here:

https://oss.oracle.com/projects/tmem/dist/files/RAMster/HOWTO-120817

If when you are testing you find that this how-to has mistakes, please let me know. Or feel free to add the (corrected) how-to file as a patch in your patchset.

Ok, I will add it to my patchset. ;-)

Regards,
Wanpeng Li

Quoted 7 lines

Thanks very much, Wanpeng, for your great contributions!

(Ric, since you have expressed interest in ramster, if you try it and find corrections to the how-to file above, your input would be very much appreciated also!)

Dan

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>

author
#12 lore raw
In reply to Dan Magenheimer
Quoted 7 lines · Dan Magenheimer
Quoted 7 lines

From: Wanpeng Li [mailto:[email protected]]
Subject: Re: [PATCH part2 v6 0/3] staging: zcache: Support zero-filled pages more efficiently

Hi Dan,

Some issues against Ramster:

Quoted 9 lines
Quoted 3 lines

- Ramster who takes advantage of zcache also should support zero-filled pages more efficiently, correct? It doesn't handle zero-filled pages well currently.

When you first posted your patchset I took a quick look at ramster and it looked like your patchset should work for ramster also. However I didn't actually run ramster to try it so there may be a bug. If it doesn't work, I would very much appreciate a patch.

I have already fix it. ;-)

Quoted 5 lines
Quoted 2 lines

- Ramster DebugFS counters are exported in /sys/kernel/mm/, but zcache/frontswap/cleancache all are exported in /sys/kernel/debug/, should we unify them?

That would be great.

Quoted 7 lines
Quoted 2 lines

- If ramster also should move DebugFS counters to a single file like zcache do?

Sure! I am concerned about Konrad's patches adding debug.c as they add many global variables. They are only required when ZCACHE_DEBUG is enabled so they may be ok. If not, adding ramster variables to debug.c may make the problem worse.

I move counters which use dubugfs to single file in zcache/ramster/ and introduce CONFIG_RAMSTER_DEBUG, patchset has already done and under test.

Quoted 11 lines
Quoted 2 lines

If you confirm these issues are make sense to fix, I will start coding. ;-)

That would be great. Note that I have a how-to for ramster here:

https://oss.oracle.com/projects/tmem/dist/files/RAMster/HOWTO-120817

If when you are testing you find that this how-to has mistakes, please let me know. Or feel free to add the (corrected) how-to file as a patch in your patchset.

Ok, I will add it to my patchset. ;-)

Regards,
Wanpeng Li

Quoted 7 lines

Thanks very much, Wanpeng, for your great contributions!

(Ric, since you have expressed interest in ramster, if you try it and find corrections to the how-to file above, your input would be very much appreciated also!)

Dan

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>

author
#13 lore raw
In reply to Dan Magenheimer
Quoted 21 lines · Dan Magenheimer
Quoted 10 lines

From: Wanpeng Li [mailto:[email protected]]
Subject: Re: [PATCH part2 v6 0/3] staging: zcache: Support zero-filled pages more efficiently

Hi Dan,

Some issues against Ramster:

- Ramster who takes advantage of zcache also should support zero-filled pages more efficiently, correct? It doesn't handle zero-filled pages well currently.

When you first posted your patchset I took a quick look at ramster and it looked like your patchset should work for ramster also. However I didn't actually run ramster to try it so there may be a bug. If it doesn't work, I would very much appreciate a patch.

Quoted 2 lines

- Ramster DebugFS counters are exported in /sys/kernel/mm/, but zcache/frontswap/cleancache all are exported in /sys/kernel/debug/, should we unify them?

That would be great.

Quoted 9 lines
Quoted 2 lines

- If ramster also should move DebugFS counters to a single file like zcache do?

Sure! I am concerned about Konrad's patches adding debug.c as they add many global variables. They are only required when ZCACHE_DEBUG is enabled so they may be ok. If not, adding ramster variables to debug.c may make the problem worse.

Quoted 1 line

If you confirm these issues are make sense to fix, I will start coding. ;-)

Hi Dan,

Quoted 8 lines

That would be great. Note that I have a how-to for ramster here:

https://oss.oracle.com/projects/tmem/dist/files/RAMster/HOWTO-120817

If when you are testing you find that this how-to has mistakes, please let me know. Or feel free to add the (corrected) how-to file as a patch in your patchset.

You can review my patchset [PATCH 00/10] staging: zcache/ramster: fix and ramster/debugfs improvement

Just update TESTING RAMSTER part since some knobs are eported in /sys/kernel/debug/ramster/ instead of /sys/kernel/mm/ramster/ for your HOWTO file.

D. TESTING RAMSTER
+2) To see if RAMster is working, on the remote system

Regards,
Wanpeng Li

Quoted 8 lines

Thanks very much, Wanpeng, for your great contributions!

(Ric, since you have expressed interest in ramster, if you try it and find corrections to the how-to file above, your input would be very much appreciated also!)

Dan

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>

author
#14 lore raw
In reply to Dan Magenheimer
Quoted 21 lines · Dan Magenheimer
Quoted 10 lines

From: Wanpeng Li [mailto:[email protected]]
Subject: Re: [PATCH part2 v6 0/3] staging: zcache: Support zero-filled pages more efficiently

Hi Dan,

Some issues against Ramster:

- Ramster who takes advantage of zcache also should support zero-filled pages more efficiently, correct? It doesn't handle zero-filled pages well currently.

When you first posted your patchset I took a quick look at ramster and it looked like your patchset should work for ramster also. However I didn't actually run ramster to try it so there may be a bug. If it doesn't work, I would very much appreciate a patch.

Quoted 2 lines

- Ramster DebugFS counters are exported in /sys/kernel/mm/, but zcache/frontswap/cleancache all are exported in /sys/kernel/debug/, should we unify them?

That would be great.

Quoted 9 lines
Quoted 2 lines

- If ramster also should move DebugFS counters to a single file like zcache do?

Sure! I am concerned about Konrad's patches adding debug.c as they add many global variables. They are only required when ZCACHE_DEBUG is enabled so they may be ok. If not, adding ramster variables to debug.c may make the problem worse.

Quoted 1 line

If you confirm these issues are make sense to fix, I will start coding. ;-)

Hi Dan,

Quoted 8 lines

That would be great. Note that I have a how-to for ramster here:

https://oss.oracle.com/projects/tmem/dist/files/RAMster/HOWTO-120817

If when you are testing you find that this how-to has mistakes, please let me know. Or feel free to add the (corrected) how-to file as a patch in your patchset.

You can review my patchset [PATCH 00/10] staging: zcache/ramster: fix and ramster/debugfs improvement

Just update TESTING RAMSTER part since some knobs are eported in /sys/kernel/debug/ramster/ instead of /sys/kernel/mm/ramster/ for your HOWTO file.

D. TESTING RAMSTER
+2) To see if RAMster is working, on the remote system

Regards,
Wanpeng Li

Quoted 8 lines

Thanks very much, Wanpeng, for your great contributions!

(Ric, since you have expressed interest in ramster, if you try it and find corrections to the how-to file above, your input would be very much appreciated also!)

Dan

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>