linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Sergey Senozhatsky <sergey.senozhatsky@gmail.com>
To: Minchan Kim <minchan@kernel.org>
Cc: Andrew Morton <akpm@linux-foundation.org>,
	linux-mm@kvack.org, linux-kernel@vger.kernel.org,
	Sergey Senozhatsky <sergey.senozhatsky.work@gmail.com>,
	Sergey Senozhatsky <sergey.senozhatsky@gmail.com>
Subject: [RFC][PATCHv4 6/7] zsmalloc: account the number of compacted pages
Date: Tue, 30 Jun 2015 21:35:57 +0900	[thread overview]
Message-ID: <1435667758-14075-7-git-send-email-sergey.senozhatsky@gmail.com> (raw)
In-Reply-To: <1435667758-14075-1-git-send-email-sergey.senozhatsky@gmail.com>

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

--
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: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

  parent reply	other threads:[~2015-06-30 12:37 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-06-30 12:35 [RFC][PATCHv4 0/7] mm/zsmalloc: introduce automatic pool compaction Sergey Senozhatsky
2015-06-30 12:35 ` [RFC][PATCHv4 1/7] zsmalloc: drop unused variable `nr_to_migrate' Sergey Senozhatsky
2015-06-30 12:35 ` [RFC][PATCHv4 2/7] zsmalloc: always keep per-class stats Sergey Senozhatsky
2015-06-30 12:35 ` [RFC][PATCHv4 3/7] zsmalloc: introduce zs_can_compact() function Sergey Senozhatsky
2015-06-30 12:35 ` [RFC][PATCHv4 4/7] zsmalloc: cosmetic compaction code adjustments Sergey Senozhatsky
2015-06-30 12:35 ` [RFC][PATCHv4 5/7] zsmalloc/zram: store compaction stats in zspool Sergey Senozhatsky
2015-06-30 12:35 ` Sergey Senozhatsky [this message]
2015-07-01  7:29   ` [RFC][PATCHv4 6/7] zsmalloc: account the number of compacted pages Sergey Senozhatsky
2015-07-02  2:13     ` Sergey Senozhatsky
2015-07-06  7:52     ` Minchan Kim
2015-06-30 12:35 ` [RFC][PATCHv4 7/7] zsmalloc: register a shrinker to trigger auto-compaction Sergey Senozhatsky

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1435667758-14075-7-git-send-email-sergey.senozhatsky@gmail.com \
    --to=sergey.senozhatsky@gmail.com \
    --cc=akpm@linux-foundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=minchan@kernel.org \
    --cc=sergey.senozhatsky.work@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox