2010-07-26 03:02:17

by KOSAKI Motohiro

[permalink] [raw]
Subject: [PATCH 0/4] memcg reclaim tracepoint v2


Recently, Mel Gorman added some vmscan tracepoint. but they can't
trace memcg. So, This patch series does.


Changelog since v1
o drop all memcg bugfix and cleanups


diffstat
=========================
KOSAKI Motohiro (4):
vmscan: convert direct reclaim tracepoint to DEFINE_TRACE
memcg, vmscan: add memcg reclaim tracepoint
vmscan: convert mm_vmscan_lru_isolate to DEFINE_EVENT
memcg: add mm_vmscan_memcg_isolate tracepoint

include/trace/events/vmscan.h | 79 +++++++++++++++++++++++++++++++++++++++--
mm/memcontrol.c | 6 +++
mm/vmscan.c | 20 ++++++++++-
3 files changed, 101 insertions(+), 4 deletions(-)

Sameple output is here.
=========================

dd-1851 [001] 158.837763: mm_vmscan_memcg_reclaim_begin: order=0 may_writepage=1 gfp_flags=GFP_HIGHUSER_MOVABLE
dd-1851 [001] 158.837783: mm_vmscan_memcg_isolate: isolate_mode=0 order=0 nr_requested=32 nr_scanned=32 nr_taken=32 contig_taken=0 contig_dirty=0 contig_failed=0
dd-1851 [001] 158.837860: mm_vmscan_memcg_reclaim_end: nr_reclaimed=32
(...)
dd-1970 [000] 266.608235: mm_vmscan_wakeup_kswapd: nid=0 zid=1 order=0
dd-1970 [000] 266.608239: mm_vmscan_wakeup_kswapd: nid=1 zid=1 order=0
dd-1970 [000] 266.608248: mm_vmscan_wakeup_kswapd: nid=2 zid=1 order=0
kswapd1-348 [001] 266.608254: mm_vmscan_kswapd_wake: nid=1 order=0
dd-1970 [000] 266.608254: mm_vmscan_wakeup_kswapd: nid=3 zid=1 order=0
kswapd3-350 [000] 266.608266: mm_vmscan_kswapd_wake: nid=3 order=0
(...)
kswapd0-347 [001] 267.328891: mm_vmscan_memcg_softlimit_reclaim_begin: order=0 may_writepage=1 gfp_flags=GFP_HIGHUSER_MOVABLE
kswapd0-347 [001] 267.328897: mm_vmscan_memcg_isolate: isolate_mode=0 order=0 nr_requested=32 nr_scanned=32 nr_taken=32 contig_taken=0 contig_dirty=0 contig_failed=0
kswapd0-347 [001] 267.328915: mm_vmscan_memcg_isolate: isolate_mode=0 order=0 nr_requested=32 nr_scanned=32 nr_taken=32 contig_taken=0 contig_dirty=0 contig_failed=0
kswapd0-347 [001] 267.328989: mm_vmscan_memcg_softlimit_reclaim_end: nr_reclaimed=32
kswapd0-347 [001] 267.329019: mm_vmscan_lru_isolate: isolate_mode=1 order=0 nr_requested=32 nr_scanned=32 nr_taken=32 contig_taken=0 contig_dirty=0 contig_failed=0
kswapd0-347 [001] 267.330562: mm_vmscan_lru_isolate: isolate_mode=1 order=0 nr_requested=32 nr_scanned=32 nr_taken=32 contig_taken=0 contig_dirty=0 contig_failed=0
(...)
kswapd2-349 [001] 267.407081: mm_vmscan_kswapd_sleep: nid=2
kswapd3-350 [001] 267.408077: mm_vmscan_kswapd_sleep: nid=3
kswapd1-348 [000] 267.427858: mm_vmscan_kswapd_sleep: nid=1
kswapd0-347 [001] 267.430064: mm_vmscan_kswapd_sleep: nid=0







2010-07-26 03:03:22

by KOSAKI Motohiro

[permalink] [raw]
Subject: [PATCH 1/4] vmscan: convert direct reclaim tracepoint to DEFINE_TRACE

Mel Gorman recently added some vmscan tracepoints. Unfortunately they are
covered only global reclaim. But we want to trace memcg reclaim too.

Thus, this patch convert them to DEFINE_TRACE macro. it help to reuse
tracepoint definition for other similar usage (i.e. memcg).
This patch have no functionally change.

Signed-off-by: KOSAKI Motohiro <[email protected]>
Reviewed-by: KAMEZAWA Hiroyuki <[email protected]>
Acked-by: Mel Gorman <[email protected]>
---
include/trace/events/vmscan.h | 19 +++++++++++++++++--
1 files changed, 17 insertions(+), 2 deletions(-)

diff --git a/include/trace/events/vmscan.h b/include/trace/events/vmscan.h
index f2da66a..a601763 100644
--- a/include/trace/events/vmscan.h
+++ b/include/trace/events/vmscan.h
@@ -68,7 +68,7 @@ TRACE_EVENT(mm_vmscan_wakeup_kswapd,
__entry->order)
);

-TRACE_EVENT(mm_vmscan_direct_reclaim_begin,
+DECLARE_EVENT_CLASS(mm_vmscan_direct_reclaim_begin_template,

TP_PROTO(int order, int may_writepage, gfp_t gfp_flags),

@@ -92,7 +92,15 @@ TRACE_EVENT(mm_vmscan_direct_reclaim_begin,
show_gfp_flags(__entry->gfp_flags))
);

-TRACE_EVENT(mm_vmscan_direct_reclaim_end,
+DEFINE_EVENT(mm_vmscan_direct_reclaim_begin_template, mm_vmscan_direct_reclaim_begin,
+
+ TP_PROTO(int order, int may_writepage, gfp_t gfp_flags),
+
+ TP_ARGS(order, may_writepage, gfp_flags)
+);
+
+
+DECLARE_EVENT_CLASS(mm_vmscan_direct_reclaim_end_template,

TP_PROTO(unsigned long nr_reclaimed),

@@ -109,6 +117,13 @@ TRACE_EVENT(mm_vmscan_direct_reclaim_end,
TP_printk("nr_reclaimed=%lu", __entry->nr_reclaimed)
);

+DEFINE_EVENT(mm_vmscan_direct_reclaim_end_template, mm_vmscan_direct_reclaim_end,
+
+ TP_PROTO(unsigned long nr_reclaimed),
+
+ TP_ARGS(nr_reclaimed)
+);
+
TRACE_EVENT(mm_vmscan_lru_isolate,

TP_PROTO(int order,
--
1.6.5.2


2010-07-26 03:04:18

by KOSAKI Motohiro

[permalink] [raw]
Subject: [PATCH 2/4] memcg, vmscan: add memcg reclaim tracepoint

Memcg also need to trace reclaim progress as direct reclaim. This patch
add it.

Signed-off-by: KOSAKI Motohiro <[email protected]>
Reviewed-by: KAMEZAWA Hiroyuki <[email protected]>
Acked-by: Mel Gorman <[email protected]>
Acked-by: Balbir Singh <[email protected]>
---
include/trace/events/vmscan.h | 28 ++++++++++++++++++++++++++++
mm/vmscan.c | 20 +++++++++++++++++++-
2 files changed, 47 insertions(+), 1 deletions(-)

diff --git a/include/trace/events/vmscan.h b/include/trace/events/vmscan.h
index a601763..c35e905 100644
--- a/include/trace/events/vmscan.h
+++ b/include/trace/events/vmscan.h
@@ -99,6 +99,19 @@ DEFINE_EVENT(mm_vmscan_direct_reclaim_begin_template, mm_vmscan_direct_reclaim_b
TP_ARGS(order, may_writepage, gfp_flags)
);

+DEFINE_EVENT(mm_vmscan_direct_reclaim_begin_template, mm_vmscan_memcg_reclaim_begin,
+
+ TP_PROTO(int order, int may_writepage, gfp_t gfp_flags),
+
+ TP_ARGS(order, may_writepage, gfp_flags)
+);
+
+DEFINE_EVENT(mm_vmscan_direct_reclaim_begin_template, mm_vmscan_memcg_softlimit_reclaim_begin,
+
+ TP_PROTO(int order, int may_writepage, gfp_t gfp_flags),
+
+ TP_ARGS(order, may_writepage, gfp_flags)
+);

DECLARE_EVENT_CLASS(mm_vmscan_direct_reclaim_end_template,

@@ -124,6 +137,21 @@ DEFINE_EVENT(mm_vmscan_direct_reclaim_end_template, mm_vmscan_direct_reclaim_end
TP_ARGS(nr_reclaimed)
);

+DEFINE_EVENT(mm_vmscan_direct_reclaim_end_template, mm_vmscan_memcg_reclaim_end,
+
+ TP_PROTO(unsigned long nr_reclaimed),
+
+ TP_ARGS(nr_reclaimed)
+);
+
+DEFINE_EVENT(mm_vmscan_direct_reclaim_end_template, mm_vmscan_memcg_softlimit_reclaim_end,
+
+ TP_PROTO(unsigned long nr_reclaimed),
+
+ TP_ARGS(nr_reclaimed)
+);
+
+
TRACE_EVENT(mm_vmscan_lru_isolate,

TP_PROTO(int order,
diff --git a/mm/vmscan.c b/mm/vmscan.c
index 97170eb..c691967 100644
--- a/mm/vmscan.c
+++ b/mm/vmscan.c
@@ -1949,6 +1949,11 @@ unsigned long mem_cgroup_shrink_node_zone(struct mem_cgroup *mem,
sc.nodemask = &nm;
sc.nr_reclaimed = 0;
sc.nr_scanned = 0;
+
+ trace_mm_vmscan_memcg_softlimit_reclaim_begin(0,
+ sc.may_writepage,
+ sc.gfp_mask);
+
/*
* NOTE: Although we can get the priority field, using it
* here is not a good idea, since it limits the pages we can scan.
@@ -1957,6 +1962,9 @@ unsigned long mem_cgroup_shrink_node_zone(struct mem_cgroup *mem,
* the priority and make it zero.
*/
shrink_zone(0, zone, &sc);
+
+ trace_mm_vmscan_memcg_softlimit_reclaim_end(sc.nr_reclaimed);
+
return sc.nr_reclaimed;
}

@@ -1966,6 +1974,7 @@ unsigned long try_to_free_mem_cgroup_pages(struct mem_cgroup *mem_cont,
unsigned int swappiness)
{
struct zonelist *zonelist;
+ unsigned long nr_reclaimed;
struct scan_control sc = {
.may_writepage = !laptop_mode,
.may_unmap = 1,
@@ -1980,7 +1989,16 @@ unsigned long try_to_free_mem_cgroup_pages(struct mem_cgroup *mem_cont,
sc.gfp_mask = (gfp_mask & GFP_RECLAIM_MASK) |
(GFP_HIGHUSER_MOVABLE & ~GFP_RECLAIM_MASK);
zonelist = NODE_DATA(numa_node_id())->node_zonelists;
- return do_try_to_free_pages(zonelist, &sc);
+
+ trace_mm_vmscan_memcg_reclaim_begin(0,
+ sc.may_writepage,
+ sc.gfp_mask);
+
+ nr_reclaimed = do_try_to_free_pages(zonelist, &sc);
+
+ trace_mm_vmscan_memcg_reclaim_end(nr_reclaimed);
+
+ return nr_reclaimed;
}
#endif

--
1.6.5.2


2010-07-26 03:05:18

by KOSAKI Motohiro

[permalink] [raw]
Subject: [PATCH 3/4] vmscan: convert mm_vmscan_lru_isolate to DEFINE_EVENT

Mel Gorman recently added some vmscan tracepoints. Unfortunately
they are covered only global reclaim. But we want to trace memcg
reclaim too.

Thus, this patch convert them to DEFINE_TRACE macro. it help to
reuse tracepoint definition for other similar usage (i.e. memcg).
This patch have no functionally change.

Signed-off-by: KOSAKI Motohiro <[email protected]>
Reviewed-by: KAMEZAWA Hiroyuki <[email protected]>
---
include/trace/events/vmscan.h | 17 ++++++++++++++++-
1 files changed, 16 insertions(+), 1 deletions(-)

diff --git a/include/trace/events/vmscan.h b/include/trace/events/vmscan.h
index c35e905..b97a3db 100644
--- a/include/trace/events/vmscan.h
+++ b/include/trace/events/vmscan.h
@@ -152,7 +152,7 @@ DEFINE_EVENT(mm_vmscan_direct_reclaim_end_template, mm_vmscan_memcg_softlimit_re
);


-TRACE_EVENT(mm_vmscan_lru_isolate,
+DECLARE_EVENT_CLASS(mm_vmscan_lru_isolate_template,

TP_PROTO(int order,
unsigned long nr_requested,
@@ -198,6 +198,21 @@ TRACE_EVENT(mm_vmscan_lru_isolate,
__entry->nr_lumpy_failed)
);

+DEFINE_EVENT(mm_vmscan_lru_isolate_template, mm_vmscan_lru_isolate,
+
+ TP_PROTO(int order,
+ unsigned long nr_requested,
+ unsigned long nr_scanned,
+ unsigned long nr_taken,
+ unsigned long nr_lumpy_taken,
+ unsigned long nr_lumpy_dirty,
+ unsigned long nr_lumpy_failed,
+ int isolate_mode),
+
+ TP_ARGS(order, nr_requested, nr_scanned, nr_taken, nr_lumpy_taken, nr_lumpy_dirty, nr_lumpy_failed, isolate_mode)
+
+);
+
TRACE_EVENT(mm_vmscan_writepage,

TP_PROTO(struct page *page,
--
1.6.5.2


2010-07-26 03:06:12

by KOSAKI Motohiro

[permalink] [raw]
Subject: [PATCH 4/4] memcg: add mm_vmscan_memcg_isolate tracepoint

Memcg also need to trace page isolation information as global reclaim.
This patch does it.

Signed-off-by: KOSAKI Motohiro <[email protected]>
Reviewed-by: KAMEZAWA Hiroyuki <[email protected]>
---
include/trace/events/vmscan.h | 15 +++++++++++++++
mm/memcontrol.c | 6 ++++++
2 files changed, 21 insertions(+), 0 deletions(-)

diff --git a/include/trace/events/vmscan.h b/include/trace/events/vmscan.h
index b97a3db..776f92b 100644
--- a/include/trace/events/vmscan.h
+++ b/include/trace/events/vmscan.h
@@ -213,6 +213,21 @@ DEFINE_EVENT(mm_vmscan_lru_isolate_template, mm_vmscan_lru_isolate,

);

+DEFINE_EVENT(mm_vmscan_lru_isolate_template, mm_vmscan_memcg_isolate,
+
+ TP_PROTO(int order,
+ unsigned long nr_requested,
+ unsigned long nr_scanned,
+ unsigned long nr_taken,
+ unsigned long nr_lumpy_taken,
+ unsigned long nr_lumpy_dirty,
+ unsigned long nr_lumpy_failed,
+ int isolate_mode),
+
+ TP_ARGS(order, nr_requested, nr_scanned, nr_taken, nr_lumpy_taken, nr_lumpy_dirty, nr_lumpy_failed, isolate_mode)
+
+);
+
TRACE_EVENT(mm_vmscan_writepage,

TP_PROTO(struct page *page,
diff --git a/mm/memcontrol.c b/mm/memcontrol.c
index 2b648ce..2600776 100644
--- a/mm/memcontrol.c
+++ b/mm/memcontrol.c
@@ -52,6 +52,8 @@

#include <asm/uaccess.h>

+#include <trace/events/vmscan.h>
+
struct cgroup_subsys mem_cgroup_subsys __read_mostly;
#define MEM_CGROUP_RECLAIM_RETRIES 5
struct mem_cgroup *root_mem_cgroup __read_mostly;
@@ -1011,6 +1013,10 @@ unsigned long mem_cgroup_isolate_pages(unsigned long nr_to_scan,
}

*scanned = scan;
+
+ trace_mm_vmscan_memcg_isolate(0, nr_to_scan, scan, nr_taken,
+ 0, 0, 0, mode);
+
return nr_taken;
}

--
1.6.5.2


2010-07-26 10:23:15

by Balbir Singh

[permalink] [raw]
Subject: Re: [PATCH 0/4] memcg reclaim tracepoint v2

On Mon, Jul 26, 2010 at 8:32 AM, KOSAKI Motohiro
<[email protected]> wrote:
>
> Recently, Mel Gorman added some vmscan tracepoint. but they can't
> trace memcg. So, This patch series does.
>

The overall series looks good to me, acking the approach and the need
for these patches

Acked-by: Balbir Singh <[email protected]>

2010-07-26 10:24:11

by Balbir Singh

[permalink] [raw]
Subject: Re: [PATCH 1/4] vmscan: convert direct reclaim tracepoint to DEFINE_TRACE

On Mon, Jul 26, 2010 at 8:33 AM, KOSAKI Motohiro
<[email protected]> wrote:
> Mel Gorman recently added some vmscan tracepoints. Unfortunately they are
> covered only global reclaim. But we want to trace memcg reclaim too.
>
> Thus, this patch convert them to DEFINE_TRACE macro. it help to reuse
> tracepoint definition for other similar usage (i.e. memcg).
> This patch have no functionally change.
>
> Signed-off-by: KOSAKI Motohiro <[email protected]>
> Reviewed-by: KAMEZAWA Hiroyuki <[email protected]>
> Acked-by: Mel Gorman <[email protected]>

Acked-by: Balbir Singh <[email protected]>

Balbir

2010-07-26 10:27:00

by Balbir Singh

[permalink] [raw]
Subject: Re: [PATCH 3/4] vmscan: convert mm_vmscan_lru_isolate to DEFINE_EVENT

On Mon, Jul 26, 2010 at 8:35 AM, KOSAKI Motohiro
<[email protected]> wrote:
> Mel Gorman recently added some vmscan tracepoints. Unfortunately
> they are covered only global reclaim. But we want to trace memcg
> reclaim too.
>
> Thus, this patch convert them to DEFINE_TRACE macro. it help to
> reuse tracepoint definition for other similar usage (i.e. memcg).
> This patch have no functionally change.
>
> Signed-off-by: KOSAKI Motohiro <[email protected]>
> Reviewed-by: KAMEZAWA Hiroyuki <[email protected]>

Acked-by: Balbir Singh <[email protected]>

Balbir

2010-07-26 10:28:00

by Balbir Singh

[permalink] [raw]
Subject: Re: [PATCH 4/4] memcg: add mm_vmscan_memcg_isolate tracepoint

On Mon, Jul 26, 2010 at 8:36 AM, KOSAKI Motohiro
<[email protected]> wrote:
> Memcg also need to trace page isolation information as global reclaim.
> This patch does it.
>
> Signed-off-by: KOSAKI Motohiro <[email protected]>
> Reviewed-by: KAMEZAWA Hiroyuki <[email protected]>

Acked-by: Balbir Singh <[email protected]>

Balbir

2010-07-26 11:11:43

by Mel Gorman

[permalink] [raw]
Subject: Re: [PATCH 3/4] vmscan: convert mm_vmscan_lru_isolate to DEFINE_EVENT

On Mon, Jul 26, 2010 at 12:05:13PM +0900, KOSAKI Motohiro wrote:
> Mel Gorman recently added some vmscan tracepoints. Unfortunately
> they are covered only global reclaim. But we want to trace memcg
> reclaim too.
>
> Thus, this patch convert them to DEFINE_TRACE macro. it help to
> reuse tracepoint definition for other similar usage (i.e. memcg).
> This patch have no functionally change.
>
> Signed-off-by: KOSAKI Motohiro <[email protected]>
> Reviewed-by: KAMEZAWA Hiroyuki <[email protected]>

Acked-by: Mel Gorman <[email protected]>

--
Mel Gorman
Part-time Phd Student Linux Technology Center
University of Limerick IBM Dublin Software Lab

2010-07-26 11:12:23

by Mel Gorman

[permalink] [raw]
Subject: Re: [PATCH 4/4] memcg: add mm_vmscan_memcg_isolate tracepoint

On Mon, Jul 26, 2010 at 12:06:05PM +0900, KOSAKI Motohiro wrote:
> Memcg also need to trace page isolation information as global reclaim.
> This patch does it.
>
> Signed-off-by: KOSAKI Motohiro <[email protected]>
> Reviewed-by: KAMEZAWA Hiroyuki <[email protected]>

Acked-by: Mel Gorman <[email protected]>

--
Mel Gorman
Part-time Phd Student Linux Technology Center
University of Limerick IBM Dublin Software Lab