lkml.org 
[lkml]   [2015]   [Jun]   [30]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[RFC][PATCHv4 6/7] zsmalloc: account the number of compacted pages
Date
Compaction returns back to zram the number of migrated objects,
which is quite uninformative -- we have objects of different
sizes so user space cannot obtain any valuable data from that
number. Change compaction to operate in terms of pages and
return back to compaction issuer the number of pages that
were freed during compaction. So from now on `num_compacted'
column in zram<id>/mm_stat represents more meaningful value:
the number of freed (compacted) pages.

Update documentation.

Signed-off-by: Sergey Senozhatsky <sergey.senozhatsky@gmail.com>
---
Documentation/blockdev/zram.txt | 3 ++-
mm/zsmalloc.c | 8 ++++++--
2 files changed, 8 insertions(+), 3 deletions(-)

diff --git a/Documentation/blockdev/zram.txt b/Documentation/blockdev/zram.txt
index c4de576..71f4744 100644
--- a/Documentation/blockdev/zram.txt
+++ b/Documentation/blockdev/zram.txt
@@ -144,7 +144,8 @@ mem_used_max RW the maximum amount memory zram have consumed to
store compressed data
mem_limit RW the maximum amount of memory ZRAM can use to store
the compressed data
-num_migrated RO the number of objects migrated migrated by compaction
+num_migrated RO the number of pages freed during compaction
+ (available only via zram<id>/mm_stat node)
compact WO trigger memory compaction

WARNING
diff --git a/mm/zsmalloc.c b/mm/zsmalloc.c
index e0f508a..51165df 100644
--- a/mm/zsmalloc.c
+++ b/mm/zsmalloc.c
@@ -245,7 +245,7 @@ struct zs_pool {
/* Allocation flags used when growing pool */
gfp_t flags;
atomic_long_t pages_allocated;
- /* How many objects were migrated */
+ /* How many pages were migrated (freed) */
unsigned long num_migrated;

#ifdef CONFIG_ZSMALLOC_STAT
@@ -1758,7 +1758,11 @@ static void __zs_compact(struct zs_pool *pool, struct size_class *class)
if (src_page)
putback_zspage(pool, class, src_page);

- pool->num_migrated += cc.nr_migrated;
+ cc.nr_migrated /= get_maxobj_per_zspage(class->size,
+ class->pages_per_zspage);
+
+ pool->num_migrated += cc.nr_migrated *
+ get_pages_per_zspage(class->size);

spin_unlock(&class->lock);
}
--
2.5.0.rc0.3.g912bd49


\
 
 \ /
  Last update: 2015-06-30 15:01    [W:0.084 / U:1.048 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site