mm: vmscan: add tracepoints for node reclaim
Subsystems (4)
PATCH 1/1 mm: vmscan: add tracepoints for node reclaim
In the page alloc fast path, it may do node reclaim, which may cause latency spike.
We should add tracepoint for this event, and also mesure the latency it causes.
So bellow two tracepoints are introduced,
mm_vmscan_node_reclaim_begin
mm_vmscan_node_reclaim_end
--- include/trace/events/vmscan.h | 48 +++++++++++++++++++++++++++++++++++++++++++ mm/vmscan.c | 13 +++++++++++- 2 files changed, 60 insertions(+), 1 deletion(-)
include/trace/events/vmscan.h +48 -0
@@ -465,6 +465,54 @@ __entry->ratio, show_reclaim_flags(__entry->reclaim_flags)) ); + +TRACE_EVENT (mm_vmscan_node_reclaim_begin, + + TP_PROTO(int nid, int order, int may_writepage, + gfp_t gfp_flags, int zid), + +TP_ARGS (nid, order, may_writepage, gfp_flags, zid), + +TP_STRUCT__entry ( + __field(int, nid) + __field(int, order) + __field(int, may_writepage) + __field(gfp_t, gfp_flags) +__field (int, zid) + ), + +TP_fast_assign ( + __entry->nid = nid; + __entry->order = order; + __entry->may_writepage = may_writepage; + __entry->gfp_flags = gfp_flags; + __entry->zid = zid; + ), + +TP_printk ("nid=%d zid=%d order=%d may_writepage=%d gfp_flags=%s" , + __entry->nid, + __entry->zid, + __entry->order, + __entry->may_writepage, +show_gfp_flags (__entry->gfp_flags)) +); + +TRACE_EVENT (mm_vmscan_node_reclaim_end, + + TP_PROTO(int result), + +TP_ARGS (result), + +TP_STRUCT__entry ( +__field (int, result) + ), + +TP_fast_assign ( + __entry->result = result; + ), + +TP_printk ("result=%d" , __entry->result) +);#endif /* _TRACE_VMSCAN_H */ /* This part must be outside protection */
mm/vmscan.c +12 -1
@@ -4240,6 +4240,12 @@ static int __node_reclaim(struct pglist_data *pgdat, gfp_t gfp_mask, unsigned in .may_swap = 1, .reclaim_idx = gfp_zone(gfp_mask), }; +int result; + +trace_mm_vmscan_node_reclaim_begin (pgdat->node_id, order, + sc.may_writepage, + sc.gfp_mask, + sc.reclaim_idx);cond_resched ();fs_reclaim_acquire (sc.gfp_mask);
@@ -4267,7 +4273,12 @@ static int __node_reclaim(struct pglist_data *pgdat, gfp_t gfp_mask, unsigned in current->flags &= ~PF_SWAPWRITE ;memalloc_noreclaim_restore (noreclaim_flag);fs_reclaim_release (sc.gfp_mask); -return sc.nr_reclaimed >= nr_pages; + + result = sc.nr_reclaimed >= nr_pages; + +trace_mm_vmscan_node_reclaim_end (result); + +return result; }int node_reclaim (struct pglist_data *pgdat,gfp_t gfp_mask,unsigned int order)
Signature · 1 line
1.8.3.1
Quoted 5 lines · Yafang Shao
In the page alloc fast path, it may do node reclaim, which may cause latency spike.
We should add tracepoint for this event, and also mesure the latency it causes.
Minor typo : mesure ->measure.
Quoted 75 lines
So bellow two tracepoints are introduced,
mm_vmscan_node_reclaim_begin
mm_vmscan_node_reclaim_endSigned-off-by Yafang Shao <[email protected]>--- include/trace/events/vmscan.h | 48 +++++++++++++++++++++++++++++++++++++++++++ mm/vmscan.c | 13 +++++++++++- 2 files changed, 60 insertions(+), 1 deletion(-)include/trace/events/vmscan.h +48
-0@@ -465,6 +465,54 @@ __entry->ratio, show_reclaim_flags(__entry->reclaim_flags)) ); + +TRACE_EVENT (mm_vmscan_node_reclaim_begin, + + TP_PROTO(int nid, int order, int may_writepage, + gfp_t gfp_flags, int zid), + +TP_ARGS (nid, order, may_writepage, gfp_flags, zid), + +TP_STRUCT__entry ( + __field(int, nid) + __field(int, order) + __field(int, may_writepage) + __field(gfp_t, gfp_flags) +__field (int, zid) + ), + +TP_fast_assign ( + __entry->nid = nid; + __entry->order = order; + __entry->may_writepage = may_writepage; + __entry->gfp_flags = gfp_flags; + __entry->zid = zid; + ), + +TP_printk ("nid=%d zid=%d order=%d may_writepage=%d gfp_flags=%s" , + __entry->nid, + __entry->zid, + __entry->order, + __entry->may_writepage, +show_gfp_flags (__entry->gfp_flags)) +); + +TRACE_EVENT (mm_vmscan_node_reclaim_end, + + TP_PROTO(int result), + +TP_ARGS (result), + +TP_STRUCT__entry ( +__field (int, result) + ), + +TP_fast_assign ( + __entry->result = result; + ), + +TP_printk ("result=%d" , __entry->result) +);#endif /* _TRACE_VMSCAN_H */ /* This part must be outside protection */ mm/vmscan.c +0
-0
mm/vmscan.c static int __node_reclaim(struct pglist_data *pgdat, gfp_t gfp_mask, unsigned in · line 4243
Quoted 4 lines
mm/vmscan.c +1
-0@@ -4240,6 +4240,12 @@ static int __node_reclaim(struct pglist_data *pgdat, gfp_t gfp_mask, unsigned in .may_swap = 1, .reclaim_idx = gfp_zone(gfp_mask), }; +int result;
If it goes to v2, then
s/result/ret ?
Quoted 25 lines
mm/vmscan.c +11
-2+ +trace_mm_vmscan_node_reclaim_begin (pgdat->node_id, order, + sc.may_writepage, + sc.gfp_mask, + sc.reclaim_idx);cond_resched ();fs_reclaim_acquire (sc.gfp_mask);@@ -4267,7 +4273,12 @@ static int __node_reclaim(struct pglist_data *pgdat, gfp_t gfp_mask, unsigned in current->flags &= ~PF_SWAPWRITE ;memalloc_noreclaim_restore (noreclaim_flag);fs_reclaim_release (sc.gfp_mask); -return sc.nr_reclaimed >= nr_pages; + + result = sc.nr_reclaimed >= nr_pages; + +trace_mm_vmscan_node_reclaim_end (result); + +return result; }int node_reclaim (struct pglist_data *pgdat,gfp_t gfp_mask,unsigned int order) --1.8.3.1
Quoted 10 lines · Souptick Joarder
Quoted 5 lines · Yafang Shao
In the page alloc fast path, it may do node reclaim, which may cause latency spike.
We should add tracepoint for this event, and also mesure the latency it causes.Minor typo : mesure ->measure.
Thanks for your correction.
Quoted 69 lines
Quoted 69 lines
So bellow two tracepoints are introduced,
mm_vmscan_node_reclaim_begin
mm_vmscan_node_reclaim_endSigned-off-by Yafang Shao <[email protected]>--- include/trace/events/vmscan.h | 48 +++++++++++++++++++++++++++++++++++++++++++ mm/vmscan.c | 13 +++++++++++- 2 files changed, 60 insertions(+), 1 deletion(-)include/trace/events/vmscan.h +48
-0@@ -465,6 +465,54 @@ __entry->ratio, show_reclaim_flags(__entry->reclaim_flags)) ); + +TRACE_EVENT (mm_vmscan_node_reclaim_begin, + + TP_PROTO(int nid, int order, int may_writepage, + gfp_t gfp_flags, int zid), + +TP_ARGS (nid, order, may_writepage, gfp_flags, zid), + +TP_STRUCT__entry ( + __field(int, nid) + __field(int, order) + __field(int, may_writepage) + __field(gfp_t, gfp_flags) +__field (int, zid) + ), + +TP_fast_assign ( + __entry->nid = nid; + __entry->order = order; + __entry->may_writepage = may_writepage; + __entry->gfp_flags = gfp_flags; + __entry->zid = zid; + ), + +TP_printk ("nid=%d zid=%d order=%d may_writepage=%d gfp_flags=%s" , + __entry->nid, + __entry->zid, + __entry->order, + __entry->may_writepage, +show_gfp_flags (__entry->gfp_flags)) +); + +TRACE_EVENT (mm_vmscan_node_reclaim_end, + + TP_PROTO(int result), + +TP_ARGS (result), + +TP_STRUCT__entry ( +__field (int, result) + ), + +TP_fast_assign ( + __entry->result = result; + ), + +TP_printk ("result=%d" , __entry->result) +);#endif /* _TRACE_VMSCAN_H */
Quoted 14 lines
mm/vmscan.c static int __node_reclaim(struct pglist_data *pgdat, gfp_t gfp_mask, unsigned in · line 4243
Quoted 10 lines
include/trace/events/vmscan.h +0
-0/* This part must be outside protection */ mm/vmscan.c +1
-0@@ -4240,6 +4240,12 @@ static int __node_reclaim(struct pglist_data *pgdat, gfp_t gfp_mask, unsigned in .may_swap = 1, .reclaim_idx = gfp_zone(gfp_mask), }; +int result;If it goes to v2, then
s/result/ret ?
Sure. Will change it.
Quoted 21 lines
Quoted 21 lines
mm/vmscan.c +11
-1+ +trace_mm_vmscan_node_reclaim_begin (pgdat->node_id, order, + sc.may_writepage, + sc.gfp_mask, + sc.reclaim_idx);cond_resched ();fs_reclaim_acquire (sc.gfp_mask);@@ -4267,7 +4273,12 @@ static int __node_reclaim(struct pglist_data *pgdat, gfp_t gfp_mask, unsigned in current->flags &= ~PF_SWAPWRITE ;memalloc_noreclaim_restore (noreclaim_flag);fs_reclaim_release (sc.gfp_mask); -return sc.nr_reclaimed >= nr_pages; + + result = sc.nr_reclaimed >= nr_pages; + +trace_mm_vmscan_node_reclaim_end (result); + +return result; }
Quoted 4 lines
Quoted 4 lines
mm/vmscan.c +0
-1int node_reclaim (struct pglist_data *pgdat,gfp_t gfp_mask,unsigned int order) --1.8.3.1
Thanks
Yafang
Michal Hocko
reviewerQuoted 8 lines · Yafang Shao
In the page alloc fast path, it may do node reclaim, which may cause latency spike.
We should add tracepoint for this event, and also mesure the latency it causes.So bellow two tracepoints are introduced,
mm_vmscan_node_reclaim_begin
mm_vmscan_node_reclaim_end
This makes some sense to me. Regular direct reclaim already does have similar tracepoints. Is there any reason you haven't used mm_vmscan_direct_reclaim_{begin,end}_template as all other direct reclaim paths?
Quoted 98 lines
Signed-off-by Yafang Shao <[email protected]>--- include/trace/events/vmscan.h | 48 +++++++++++++++++++++++++++++++++++++++++++ mm/vmscan.c | 13 +++++++++++- 2 files changed, 60 insertions(+), 1 deletion(-)include/trace/events/vmscan.h +48
-0@@ -465,6 +465,54 @@ __entry->ratio, show_reclaim_flags(__entry->reclaim_flags)) ); + +TRACE_EVENT (mm_vmscan_node_reclaim_begin, + + TP_PROTO(int nid, int order, int may_writepage, + gfp_t gfp_flags, int zid), + +TP_ARGS (nid, order, may_writepage, gfp_flags, zid), + +TP_STRUCT__entry ( + __field(int, nid) + __field(int, order) + __field(int, may_writepage) + __field(gfp_t, gfp_flags) +__field (int, zid) + ), + +TP_fast_assign ( + __entry->nid = nid; + __entry->order = order; + __entry->may_writepage = may_writepage; + __entry->gfp_flags = gfp_flags; + __entry->zid = zid; + ), + +TP_printk ("nid=%d zid=%d order=%d may_writepage=%d gfp_flags=%s" , + __entry->nid, + __entry->zid, + __entry->order, + __entry->may_writepage, +show_gfp_flags (__entry->gfp_flags)) +); + +TRACE_EVENT (mm_vmscan_node_reclaim_end, + + TP_PROTO(int result), + +TP_ARGS (result), + +TP_STRUCT__entry ( +__field (int, result) + ), + +TP_fast_assign ( + __entry->result = result; + ), + +TP_printk ("result=%d" , __entry->result) +);#endif /* _TRACE_VMSCAN_H */ /* This part must be outside protection */ mm/vmscan.c +12
-1@@ -4240,6 +4240,12 @@ static int __node_reclaim(struct pglist_data *pgdat, gfp_t gfp_mask, unsigned in .may_swap = 1, .reclaim_idx = gfp_zone(gfp_mask), }; +int result; + +trace_mm_vmscan_node_reclaim_begin (pgdat->node_id, order, + sc.may_writepage, + sc.gfp_mask, + sc.reclaim_idx);cond_resched ();fs_reclaim_acquire (sc.gfp_mask);@@ -4267,7 +4273,12 @@ static int __node_reclaim(struct pglist_data *pgdat, gfp_t gfp_mask, unsigned in current->flags &= ~PF_SWAPWRITE ;memalloc_noreclaim_restore (noreclaim_flag);fs_reclaim_release (sc.gfp_mask); -return sc.nr_reclaimed >= nr_pages; + + result = sc.nr_reclaimed >= nr_pages; + +trace_mm_vmscan_node_reclaim_end (result); + +return result; }int node_reclaim (struct pglist_data *pgdat,gfp_t gfp_mask,unsigned int order)Signature · 1 line
1.8.3.1
Signature · 2 lines
Michal Hocko SUSE Labs
Quoted 7 lines · Michal Hocko
Quoted 5 lines · Yafang Shao
In the page alloc fast path, it may do node reclaim, which may cause latency spike.
We should add tracepoint for this event, and also mesure the latency it causes.
Quoted 9 lines
Quoted 3 lines
So bellow two tracepoints are introduced,
mm_vmscan_node_reclaim_begin
mm_vmscan_node_reclaim_endThis makes some sense to me. Regular direct reclaim already does have similar tracepoints. Is there any reason you haven't used mm_vmscan_direct_reclaim_{begin,end}_template as all other direct reclaim paths?
Because I also want to know the node id, which is not show in mm_vmscan_direct_reclaim_{begin,end}_template.
Or should we modify mm_vmscan_direct_reclaim_{begin,end}_template to show the node id as well ?
Thanks
Yafang
Quoted 102 lines
Quoted 97 lines
Signed-off-by Yafang Shao <[email protected]>--- include/trace/events/vmscan.h | 48 +++++++++++++++++++++++++++++++++++++++++++ mm/vmscan.c | 13 +++++++++++- 2 files changed, 60 insertions(+), 1 deletion(-)include/trace/events/vmscan.h +48
-0@@ -465,6 +465,54 @@ __entry->ratio, show_reclaim_flags(__entry->reclaim_flags)) ); + +TRACE_EVENT (mm_vmscan_node_reclaim_begin, + + TP_PROTO(int nid, int order, int may_writepage, + gfp_t gfp_flags, int zid), + +TP_ARGS (nid, order, may_writepage, gfp_flags, zid), + +TP_STRUCT__entry ( + __field(int, nid) + __field(int, order) + __field(int, may_writepage) + __field(gfp_t, gfp_flags) +__field (int, zid) + ), + +TP_fast_assign ( + __entry->nid = nid; + __entry->order = order; + __entry->may_writepage = may_writepage; + __entry->gfp_flags = gfp_flags; + __entry->zid = zid; + ), + +TP_printk ("nid=%d zid=%d order=%d may_writepage=%d gfp_flags=%s" , + __entry->nid, + __entry->zid, + __entry->order, + __entry->may_writepage, +show_gfp_flags (__entry->gfp_flags)) +); + +TRACE_EVENT (mm_vmscan_node_reclaim_end, + + TP_PROTO(int result), + +TP_ARGS (result), + +TP_STRUCT__entry ( +__field (int, result) + ), + +TP_fast_assign ( + __entry->result = result; + ), + +TP_printk ("result=%d" , __entry->result) +);#endif /* _TRACE_VMSCAN_H */ /* This part must be outside protection */ mm/vmscan.c +12
-2@@ -4240,6 +4240,12 @@ static int __node_reclaim(struct pglist_data *pgdat, gfp_t gfp_mask, unsigned in .may_swap = 1, .reclaim_idx = gfp_zone(gfp_mask), }; +int result; + +trace_mm_vmscan_node_reclaim_begin (pgdat->node_id, order, + sc.may_writepage, + sc.gfp_mask, + sc.reclaim_idx);cond_resched ();fs_reclaim_acquire (sc.gfp_mask);@@ -4267,7 +4273,12 @@ static int __node_reclaim(struct pglist_data *pgdat, gfp_t gfp_mask, unsigned in current->flags &= ~PF_SWAPWRITE ;memalloc_noreclaim_restore (noreclaim_flag);fs_reclaim_release (sc.gfp_mask); -return sc.nr_reclaimed >= nr_pages; + + result = sc.nr_reclaimed >= nr_pages; + +trace_mm_vmscan_node_reclaim_end (result); + +return result; }int node_reclaim (struct pglist_data *pgdat,gfp_t gfp_mask,unsigned int order) --Quoted 1 line
1.8.3.1
--
Michal Hocko
SUSE Labs
Michal Hocko
reviewerQuoted 18 lines · Yafang Shao
Quoted 7 lines · Michal Hocko
Quoted 5 lines · Yafang Shao
In the page alloc fast path, it may do node reclaim, which may cause latency spike.
We should add tracepoint for this event, and also mesure the latency it causes.Quoted 9 lines
Quoted 3 lines
So bellow two tracepoints are introduced,
mm_vmscan_node_reclaim_begin
mm_vmscan_node_reclaim_endThis makes some sense to me. Regular direct reclaim already does have similar tracepoints. Is there any reason you haven't used mm_vmscan_direct_reclaim_{begin,end}_template as all other direct reclaim paths?
Quoted 5 lines
Because I also want to know the node id, which is not show in mm_vmscan_direct_reclaim_{begin,end}_template.
Or should we modify mm_vmscan_direct_reclaim_{begin,end}_template to show the node id as well ?
OK, I see. I thought it was there but it would make much less sense than for the node reclaim for sure. A separate tracepoint makes more sense then.
Signature · 2 lines
Michal Hocko SUSE Labs
Quoted 25 lines · Yafang Shao
In the page alloc fast path, it may do node reclaim, which may cause latency spike.
We should add tracepoint for this event, and also mesure the latency it causes.So bellow two tracepoints are introduced,
mm_vmscan_node_reclaim_begin
mm_vmscan_node_reclaim_endSigned-off-by Yafang Shao <[email protected]>--- include/trace/events/vmscan.h | 48 +++++++++++++++++++++++++++++++++++++++++++ mm/vmscan.c | 13 +++++++++++- 2 files changed, 60 insertions(+), 1 deletion(-)include/trace/events/vmscan.h +2
-0@@ -465,6 +465,54 @@ __entry->ratio, show_reclaim_flags(__entry->reclaim_flags)) ); + +TRACE_EVENT(mm_vmscan_node_reclaim_begin,
include/trace/events/vmscan.h line 479
Quoted 10 lines
include/trace/events/vmscan.h +10
-0+ + TP_PROTO(int nid, int order, int may_writepage, + gfp_t gfp_flags, int zid), + + TP_ARGS(nid, order, may_writepage, gfp_flags, zid), + + TP_STRUCT__entry( + __field(int, nid) + __field(int, order) + __field(int, may_writepage)
For node reclaim may_writepage is statically set in node_reclaim_mode, so I'm not sure it's worth including it.
include/trace/events/vmscan.h line 481
Quoted 2 lines
include/trace/events/vmscan.h +2
-0+ __field(gfp_t, gfp_flags) +__field (int, zid)
zid seems wasteful and misleading as it's simply derived by gfp_zone(gfp_mask), so I would drop it.
Quoted 16 lines
include/trace/events/vmscan.h +16
-0+ ), + + TP_fast_assign( + __entry->nid = nid; + __entry->order = order; + __entry->may_writepage = may_writepage; + __entry->gfp_flags = gfp_flags; + __entry->zid = zid; + ), + +TP_printk ("nid=%d zid=%d order=%d may_writepage=%d gfp_flags=%s" , + __entry->nid, + __entry->zid, + __entry->order, + __entry->may_writepage, +show_gfp_flags (__entry->gfp_flags))
include/trace/events/vmscan.h line 507
Quoted 10 lines
include/trace/events/vmscan.h +10
-0+); + +TRACE_EVENT(mm_vmscan_node_reclaim_end, + + TP_PROTO(int result), + + TP_ARGS(result), + + TP_STRUCT__entry( + __field(int, result)
Reporting sc.nr_reclaimed sounds more useful and in line with other reclaim tracepoints. Result (sc.nr_reclaimed >= nr_pages) can then be derived by postprocessing as the beginning tracepoint contains 'order' thus we know nr_pages?
Quoted 43 lines
include/trace/events/vmscan.h +8
-0+ ), + +TP_fast_assign ( + __entry->result = result; + ), + +TP_printk ("result=%d" , __entry->result) +);#endif /* _TRACE_VMSCAN_H */ /* This part must be outside protection */ mm/vmscan.c +12
-1@@ -4240,6 +4240,12 @@ static int __node_reclaim(struct pglist_data *pgdat, gfp_t gfp_mask, unsigned in .may_swap = 1, .reclaim_idx = gfp_zone(gfp_mask), }; +int result; + +trace_mm_vmscan_node_reclaim_begin (pgdat->node_id, order, + sc.may_writepage, + sc.gfp_mask, + sc.reclaim_idx);cond_resched ();fs_reclaim_acquire (sc.gfp_mask);@@ -4267,7 +4273,12 @@ static int __node_reclaim(struct pglist_data *pgdat, gfp_t gfp_mask, unsigned in current->flags &= ~PF_SWAPWRITE ;memalloc_noreclaim_restore (noreclaim_flag);fs_reclaim_release (sc.gfp_mask); -return sc.nr_reclaimed >= nr_pages; + + result = sc.nr_reclaimed >= nr_pages; + +trace_mm_vmscan_node_reclaim_end (result); + +return result; }int node_reclaim (struct pglist_data *pgdat,gfp_t gfp_mask,unsigned int order)
Quoted 41 lines · Vlastimil Babka
Quoted 25 lines · Yafang Shao
In the page alloc fast path, it may do node reclaim, which may cause latency spike.
We should add tracepoint for this event, and also mesure the latency it causes.So bellow two tracepoints are introduced,
mm_vmscan_node_reclaim_begin
mm_vmscan_node_reclaim_endSigned-off-by Yafang Shao <[email protected]>--- include/trace/events/vmscan.h | 48 +++++++++++++++++++++++++++++++++++++++++++ mm/vmscan.c | 13 +++++++++++- 2 files changed, 60 insertions(+), 1 deletion(-)include/trace/events/vmscan.h +2
-0@@ -465,6 +465,54 @@ __entry->ratio, show_reclaim_flags(__entry->reclaim_flags)) ); + +TRACE_EVENT(mm_vmscan_node_reclaim_begin,include/trace/events/vmscan.h line 479
Quoted 10 lines
include/trace/events/vmscan.h +10
-0+ + TP_PROTO(int nid, int order, int may_writepage, + gfp_t gfp_flags, int zid), + + TP_ARGS(nid, order, may_writepage, gfp_flags, zid), + + TP_STRUCT__entry( + __field(int, nid) + __field(int, order) + __field(int, may_writepage)For node reclaim
may_writepageis statically set innode_reclaim_mode, so I'm not sure it's worth including it.
Quoted 6 lines
include/trace/events/vmscan.h line 481
Quoted 2 lines
include/trace/events/vmscan.h +2
-0+ __field(gfp_t, gfp_flags) +__field (int, zid)zid seems wasteful and misleading as it's simply derived by
gfp_zone(gfp_mask), so I would drop it.
I agree with you that may_writepage and zid is wasteful, but I found they are in other tracepoints in this file,
so I place them in this tracepoint as well.
Seems we'd better drop them from other tracepoints as well ?
Quoted 23 lines
Quoted 23 lines
include/trace/events/vmscan.h +23
-0+ ), + + TP_fast_assign( + __entry->nid = nid; + __entry->order = order; + __entry->may_writepage = may_writepage; + __entry->gfp_flags = gfp_flags; + __entry->zid = zid; + ), + +TP_printk ("nid=%d zid=%d order=%d may_writepage=%d gfp_flags=%s" , + __entry->nid, + __entry->zid, + __entry->order, + __entry->may_writepage, +show_gfp_flags (__entry->gfp_flags)) +); + +TRACE_EVENT(mm_vmscan_node_reclaim_end, + + TP_PROTO(int result), + + TP_ARGS(result),
Quoted 9 lines
include/trace/events/vmscan.h line 507
Quoted 3 lines
include/trace/events/vmscan.h +3
-0+ +TP_STRUCT__entry ( + __field(int, result)Reporting sc.nr_reclaimed sounds more useful and in line with other reclaim tracepoints. Result (sc.nr_reclaimed >=
nr_pages) can then be derived by postprocessing as the beginning tracepoint contains 'order' thus we knownr_pages?
Seems reasonable.
Will change it.
Quoted 41 lines
Quoted 41 lines
include/trace/events/vmscan.h +8
-0+ ), + +TP_fast_assign ( + __entry->result = result; + ), + +TP_printk ("result=%d" , __entry->result) +);#endif /* _TRACE_VMSCAN_H */ /* This part must be outside protection */ mm/vmscan.c +12
-1@@ -4240,6 +4240,12 @@ static int __node_reclaim(struct pglist_data *pgdat, gfp_t gfp_mask, unsigned in .may_swap = 1, .reclaim_idx = gfp_zone(gfp_mask), }; +int result; + +trace_mm_vmscan_node_reclaim_begin (pgdat->node_id, order, + sc.may_writepage, + sc.gfp_mask, + sc.reclaim_idx);cond_resched ();fs_reclaim_acquire (sc.gfp_mask);@@ -4267,7 +4273,12 @@ static int __node_reclaim(struct pglist_data *pgdat, gfp_t gfp_mask, unsigned in current->flags &= ~PF_SWAPWRITE ;memalloc_noreclaim_restore (noreclaim_flag);fs_reclaim_release (sc.gfp_mask); -return sc.nr_reclaimed >= nr_pages; + + result = sc.nr_reclaimed >= nr_pages; + +trace_mm_vmscan_node_reclaim_end (result); + +return result; }
Quoted 3 lines
mm/vmscan.c static int __node_reclaim(struct pglist_data *pgdat, gfp_t gfp_mask, unsigned in · line 4284
Quoted 2 lines
mm/vmscan.c +0
-0int node_reclaim (struct pglist_data *pgdat,gfp_t gfp_mask,unsigned int order)
Thanks
Yafang
Quoted 45 lines · Yafang Shao
Quoted 44 lines · Vlastimil Babka
Quoted 25 lines · Yafang Shao
In the page alloc fast path, it may do node reclaim, which may cause latency spike.
We should add tracepoint for this event, and also mesure the latency it causes.So bellow two tracepoints are introduced,
mm_vmscan_node_reclaim_begin
mm_vmscan_node_reclaim_endSigned-off-by Yafang Shao <[email protected]>--- include/trace/events/vmscan.h | 48 +++++++++++++++++++++++++++++++++++++++++++ mm/vmscan.c | 13 +++++++++++- 2 files changed, 60 insertions(+), 1 deletion(-)include/trace/events/vmscan.h +2
-0@@ -465,6 +465,54 @@ __entry->ratio, show_reclaim_flags(__entry->reclaim_flags)) ); + +TRACE_EVENT(mm_vmscan_node_reclaim_begin,include/trace/events/vmscan.h line 479
Quoted 10 lines
include/trace/events/vmscan.h +10
-0+ + TP_PROTO(int nid, int order, int may_writepage, + gfp_t gfp_flags, int zid), + + TP_ARGS(nid, order, may_writepage, gfp_flags, zid), + + TP_STRUCT__entry( + __field(int, nid) + __field(int, order) + __field(int, may_writepage)For node reclaim
may_writepageis statically set innode_reclaim_mode, so I'm not sure it's worth including it.Quoted 2 lines
include/trace/events/vmscan.h +2
-0+ __field(gfp_t, gfp_flags) +__field (int, zid)
Quoted 7 lines
Quoted 3 lines
zid seems wasteful and misleading as it's simply derived by
gfp_zone(gfp_mask), so I would drop it.I agree with you that
may_writepageand zid is wasteful, but I found they are in other tracepoints in this file,
so I place them in this tracepoint as well.
I see zid only in kswapd waking tracepoints? That's different kind of event.
Quoted 1 line
Seems we'd better drop them from other tracepoints as well ?
Hmm seems may_writepage in other tracepoints depends on laptop_mode which is also a static setting. do_try_to_free_pages() can override it due to priority, but that doesn't affect the tracepoints. If they are to be dropped, it would be a separate patch though.
Quoted 51 lines · Vlastimil Babka
Quoted 49 lines · Yafang Shao
Quoted 47 lines · Vlastimil Babka
Quoted 25 lines · Yafang Shao
In the page alloc fast path, it may do node reclaim, which may cause latency spike.
We should add tracepoint for this event, and also mesure the latency it causes.So bellow two tracepoints are introduced,
mm_vmscan_node_reclaim_begin
mm_vmscan_node_reclaim_endSigned-off-by Yafang Shao <[email protected]>--- include/trace/events/vmscan.h | 48 +++++++++++++++++++++++++++++++++++++++++++ mm/vmscan.c | 13 +++++++++++- 2 files changed, 60 insertions(+), 1 deletion(-)include/trace/events/vmscan.h +2
-0@@ -465,6 +465,54 @@ __entry->ratio, show_reclaim_flags(__entry->reclaim_flags)) ); + +TRACE_EVENT(mm_vmscan_node_reclaim_begin,include/trace/events/vmscan.h line 479
Quoted 10 lines
include/trace/events/vmscan.h +10
-0+ + TP_PROTO(int nid, int order, int may_writepage, + gfp_t gfp_flags, int zid), + + TP_ARGS(nid, order, may_writepage, gfp_flags, zid), + + TP_STRUCT__entry( + __field(int, nid) + __field(int, order) + __field(int, may_writepage)For node reclaim
may_writepageis statically set innode_reclaim_mode, so I'm not sure it's worth including it.include/trace/events/vmscan.h line 481
Quoted 2 lines
include/trace/events/vmscan.h +2
-0+ __field(gfp_t, gfp_flags) +__field (int, zid)zid seems wasteful and misleading as it's simply derived by
gfp_zone(gfp_mask), so I would drop it.
Quoted 7 lines
Quoted 3 lines
I agree with you that
may_writepageand zid is wasteful, but I found they are in other tracepoints in this file,
so I place them in this tracepoint as well.I see zid only in kswapd waking tracepoints? That's different kind of event.
Pls. see mm_vmscan_wakeup_kswapd and classzone_idx in mm_vmscan_direct_reclaim_begin_template.
mm_vmscan_direct_reclaim_begin_template:
"order=%d may_writepage=%d gfp_flags=%s classzone_idx=%d"
mm_vmscan_wakeup_kswapd:
"nid=%d zid=%d order=%d gfp_flags=%s"
Quoted 6 lines
Quoted 1 line
Seems we'd better drop them from other tracepoints as well ?
Hmm seems
may_writepagein other tracepoints depends onlaptop_modewhich is also a static setting.do_try_to_free_pages()can override it due to priority, but that doesn't affect the tracepoints. If they are to be dropped, it would be a separate patch though.
OK.
Thanks
Yafang