From: Ganesh Mahendran <opensource.ganesh@gmail.com>
To: linux-kernel@vger.kernel.org, linux-mm@kvack.org
Cc: akpm@linux-foundation.org, minchan@kernel.org, ngupta@vflare.org,
sergey.senozhatsky.work@gmail.com, rostedt@goodmis.org,
mingo@redhat.com, Ganesh Mahendran <opensource.ganesh@gmail.com>
Subject: [PATCH v3 8/8] mm/zsmalloc: add per-class compact trace event
Date: Wed, 6 Jul 2016 14:23:53 +0800 [thread overview]
Message-ID: <1467786233-4481-8-git-send-email-opensource.ganesh@gmail.com> (raw)
In-Reply-To: <1467786233-4481-1-git-send-email-opensource.ganesh@gmail.com>
add per-class compact trace event to get scanned objects and freed pages
number.
trace log is like below:
----
kswapd0-629 [001] .... 293.161053: zs_compact_start: pool zram0
kswapd0-629 [001] .... 293.161056: zs_compact: class 254: 0 objects scanned, 0 pages freed
kswapd0-629 [001] .... 293.161057: zs_compact: class 202: 0 objects scanned, 0 pages freed
kswapd0-629 [001] .... 293.161062: zs_compact: class 190: 1 objects scanned, 3 pages freed
kswapd0-629 [001] .... 293.161063: zs_compact: class 168: 0 objects scanned, 0 pages freed
kswapd0-629 [001] .... 293.161065: zs_compact: class 151: 0 objects scanned, 0 pages freed
kswapd0-629 [001] .... 293.161073: zs_compact: class 144: 4 objects scanned, 8 pages freed
kswapd0-629 [001] .... 293.161087: zs_compact: class 126: 20 objects scanned, 10 pages freed
kswapd0-629 [001] .... 293.161095: zs_compact: class 111: 6 objects scanned, 8 pages freed
kswapd0-629 [001] .... 293.161122: zs_compact: class 107: 27 objects scanned, 27 pages freed
kswapd0-629 [001] .... 293.161157: zs_compact: class 100: 36 objects scanned, 24 pages freed
kswapd0-629 [001] .... 293.161173: zs_compact: class 94: 10 objects scanned, 15 pages freed
kswapd0-629 [001] .... 293.161221: zs_compact: class 91: 30 objects scanned, 40 pages freed
kswapd0-629 [001] .... 293.161256: zs_compact: class 83: 120 objects scanned, 30 pages freed
kswapd0-629 [001] .... 293.161266: zs_compact: class 76: 8 objects scanned, 8 pages freed
kswapd0-629 [001] .... 293.161282: zs_compact: class 74: 20 objects scanned, 15 pages freed
kswapd0-629 [001] .... 293.161306: zs_compact: class 71: 40 objects scanned, 20 pages freed
kswapd0-629 [001] .... 293.161313: zs_compact: class 67: 8 objects scanned, 6 pages freed
...
kswapd0-629 [001] .... 293.161454: zs_compact: class 0: 0 objects scanned, 0 pages freed
kswapd0-629 [001] .... 293.161455: zs_compact_end: pool zram0: 301 pages compacted
----
Also this patch changes trace_zsmalloc_compact_start[end] to
trace_zs_compact_start[end] to keep function naming consistent
with others in zsmalloc.
Signed-off-by: Ganesh Mahendran <opensource.ganesh@gmail.com>
----
v3:
add per-class compact trace event - Minchan
I put this patch from 1/8 to 8/8, since this patch depends on below patch:
mm/zsmalloc: use obj_index to keep consistent with others
mm/zsmalloc: take obj index back from find_alloced_obj
v2:
update commit description
---
include/trace/events/zsmalloc.h | 40 ++++++++++++++++++++++++++++++----------
mm/zsmalloc.c | 26 ++++++++++++++++++--------
2 files changed, 48 insertions(+), 18 deletions(-)
diff --git a/include/trace/events/zsmalloc.h b/include/trace/events/zsmalloc.h
index 3b6f14e..96fcca8 100644
--- a/include/trace/events/zsmalloc.h
+++ b/include/trace/events/zsmalloc.h
@@ -7,7 +7,7 @@
#include <linux/types.h>
#include <linux/tracepoint.h>
-TRACE_EVENT(zsmalloc_compact_start,
+TRACE_EVENT(zs_compact_start,
TP_PROTO(const char *pool_name),
@@ -25,29 +25,49 @@ TRACE_EVENT(zsmalloc_compact_start,
__entry->pool_name)
);
-TRACE_EVENT(zsmalloc_compact_end,
+TRACE_EVENT(zs_compact_end,
- TP_PROTO(const char *pool_name, unsigned long pages_compacted,
- unsigned long pages_total_compacted),
+ TP_PROTO(const char *pool_name, unsigned long pages_compacted),
- TP_ARGS(pool_name, pages_compacted, pages_total_compacted),
+ TP_ARGS(pool_name, pages_compacted),
TP_STRUCT__entry(
__field(const char *, pool_name)
__field(unsigned long, pages_compacted)
- __field(unsigned long, pages_total_compacted)
),
TP_fast_assign(
__entry->pool_name = pool_name;
__entry->pages_compacted = pages_compacted;
- __entry->pages_total_compacted = pages_total_compacted;
),
- TP_printk("pool %s: %ld pages compacted(total %ld)",
+ TP_printk("pool %s: %ld pages compacted",
__entry->pool_name,
- __entry->pages_compacted,
- __entry->pages_total_compacted)
+ __entry->pages_compacted)
+);
+
+TRACE_EVENT(zs_compact,
+
+ TP_PROTO(int class, unsigned long nr_scanned_obj, unsigned long nr_freed_pages),
+
+ TP_ARGS(class, nr_scanned_obj, nr_freed_pages),
+
+ TP_STRUCT__entry(
+ __field(int, class)
+ __field(unsigned long, nr_scanned_obj)
+ __field(unsigned long, nr_freed_pages)
+ ),
+
+ TP_fast_assign(
+ __entry->class = class;
+ __entry->nr_scanned_obj = nr_scanned_obj;
+ __entry->nr_freed_pages = nr_freed_pages;
+ ),
+
+ TP_printk("class %3d: %ld objects scanned, %ld pages freed",
+ __entry->class,
+ __entry->nr_scanned_obj,
+ __entry->nr_freed_pages)
);
#endif /* _TRACE_ZSMALLOC_H */
diff --git a/mm/zsmalloc.c b/mm/zsmalloc.c
index 17d3f53..3a1315e 100644
--- a/mm/zsmalloc.c
+++ b/mm/zsmalloc.c
@@ -1770,9 +1770,12 @@ struct zs_compact_control {
/* Destination page for migration which should be a first page
* of zspage. */
struct page *d_page;
- /* Starting object index within @s_page which used for live object
- * in the subpage. */
+ /* Starting object index within @s_page which used for live object
+ * in the subpage. */
int obj_idx;
+
+ unsigned long nr_scanned_obj;
+ unsigned long nr_freed_pages;
};
static int migrate_zspage(struct zs_pool *pool, struct size_class *class,
@@ -1818,6 +1821,8 @@ static int migrate_zspage(struct zs_pool *pool, struct size_class *class,
obj_free(class, used_obj);
}
+ cc->nr_scanned_obj += obj_idx - cc->obj_idx;
+
/* Remember last position in this iteration */
cc->s_page = s_page;
cc->obj_idx = obj_idx;
@@ -2264,7 +2269,10 @@ static unsigned long zs_can_compact(struct size_class *class)
static void __zs_compact(struct zs_pool *pool, struct size_class *class)
{
- struct zs_compact_control cc;
+ struct zs_compact_control cc = {
+ .nr_scanned_obj = 0,
+ .nr_freed_pages = 0,
+ };
struct zspage *src_zspage;
struct zspage *dst_zspage = NULL;
@@ -2296,7 +2304,7 @@ static void __zs_compact(struct zs_pool *pool, struct size_class *class)
putback_zspage(class, dst_zspage);
if (putback_zspage(class, src_zspage) == ZS_EMPTY) {
free_zspage(pool, class, src_zspage);
- pool->stats.pages_compacted += class->pages_per_zspage;
+ cc.nr_freed_pages += class->pages_per_zspage;
}
spin_unlock(&class->lock);
cond_resched();
@@ -2307,6 +2315,9 @@ static void __zs_compact(struct zs_pool *pool, struct size_class *class)
putback_zspage(class, src_zspage);
spin_unlock(&class->lock);
+
+ pool->stats.pages_compacted += cc.nr_freed_pages;
+ trace_zs_compact(class->index, cc.nr_scanned_obj, cc.nr_freed_pages);
}
unsigned long zs_compact(struct zs_pool *pool)
@@ -2315,7 +2326,7 @@ unsigned long zs_compact(struct zs_pool *pool)
struct size_class *class;
unsigned long pages_compacted_before = pool->stats.pages_compacted;
- trace_zsmalloc_compact_start(pool->name);
+ trace_zs_compact_start(pool->name);
for (i = zs_size_classes - 1; i >= 0; i--) {
class = pool->size_class[i];
@@ -2326,9 +2337,8 @@ unsigned long zs_compact(struct zs_pool *pool)
__zs_compact(pool, class);
}
- trace_zsmalloc_compact_end(pool->name,
- pool->stats.pages_compacted - pages_compacted_before,
- pool->stats.pages_compacted);
+ trace_zs_compact_end(pool->name,
+ pool->stats.pages_compacted - pages_compacted_before);
return pool->stats.pages_compacted;
}
--
1.9.1
--
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>
next prev parent reply other threads:[~2016-07-06 6:26 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-07-06 6:23 [PATCH v3 1/8] mm/zsmalloc: use obj_index to keep consistent with others Ganesh Mahendran
2016-07-06 6:23 ` [PATCH v3 2/8] mm/zsmalloc: take obj index back from find_alloced_obj Ganesh Mahendran
2016-07-06 6:23 ` [PATCH v3 3/8] mm/zsmalloc: use class->objs_per_zspage to get num of max objects Ganesh Mahendran
2016-07-06 6:23 ` [PATCH v3 4/8] mm/zsmalloc: avoid calculate max objects of zspage twice Ganesh Mahendran
2016-07-06 6:23 ` [PATCH v3 5/8] mm/zsmalloc: keep comments consistent with code Ganesh Mahendran
2016-07-06 6:23 ` [PATCH v3 6/8] mm/zsmalloc: add __init,__exit attribute Ganesh Mahendran
2016-07-06 8:01 ` kbuild test robot
2016-07-06 8:06 ` kbuild test robot
2016-07-06 8:20 ` Ganesh Mahendran
2016-07-06 6:23 ` [PATCH v3 7/8] mm/zsmalloc: use helper to clear page->flags bit Ganesh Mahendran
2016-07-06 6:23 ` Ganesh Mahendran [this message]
2016-07-07 7:44 ` [PATCH v3 8/8] mm/zsmalloc: add per-class compact trace event Minchan Kim
2016-07-07 9:08 ` Ganesh Mahendran
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=1467786233-4481-8-git-send-email-opensource.ganesh@gmail.com \
--to=opensource.ganesh@gmail.com \
--cc=akpm@linux-foundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=minchan@kernel.org \
--cc=mingo@redhat.com \
--cc=ngupta@vflare.org \
--cc=rostedt@goodmis.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;
as well as URLs for NNTP newsgroup(s).