Skip to content

Commit 16c4a09

Browse files
JoonsooKimtorvalds
authored andcommitted
mm/compaction: enhance tracepoint output for compaction begin/end
We now have tracepoint for begin event of compaction and it prints start position of both scanners, but, tracepoint for end event of compaction doesn't print finish position of both scanners. It'd be also useful to know finish position of both scanners so this patch add it. It will help to find odd behavior or problem on compaction internal logic. And mode is added to both begin/end tracepoint output, since according to mode, compaction behavior is quite different. And lastly, status format is changed to string rather than status number for readability. [[email protected]: fix sparse warning] Signed-off-by: Joonsoo Kim <[email protected]> Acked-by: Vlastimil Babka <[email protected]> Cc: Mel Gorman <[email protected]> Cc: David Rientjes <[email protected]> Cc: Dan Carpenter <[email protected]> Signed-off-by: Andrew Morton <[email protected]> Signed-off-by: Linus Torvalds <[email protected]>
1 parent 4645f06 commit 16c4a09

File tree

3 files changed

+49
-16
lines changed

3 files changed

+49
-16
lines changed

include/linux/compaction.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
#define COMPACT_PARTIAL 3
1313
/* The full zone was compacted */
1414
#define COMPACT_COMPLETE 4
15+
/* When adding new state, please change compaction_status_string, too */
1516

1617
/* Used to signal whether compaction detected need_sched() or lock contention */
1718
/* No contention detected */

include/trace/events/compaction.h

Lines changed: 35 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -85,46 +85,67 @@ TRACE_EVENT(mm_compaction_migratepages,
8585
);
8686

8787
TRACE_EVENT(mm_compaction_begin,
88-
TP_PROTO(unsigned long zone_start, unsigned long migrate_start,
89-
unsigned long free_start, unsigned long zone_end),
88+
TP_PROTO(unsigned long zone_start, unsigned long migrate_pfn,
89+
unsigned long free_pfn, unsigned long zone_end, bool sync),
9090

91-
TP_ARGS(zone_start, migrate_start, free_start, zone_end),
91+
TP_ARGS(zone_start, migrate_pfn, free_pfn, zone_end, sync),
9292

9393
TP_STRUCT__entry(
9494
__field(unsigned long, zone_start)
95-
__field(unsigned long, migrate_start)
96-
__field(unsigned long, free_start)
95+
__field(unsigned long, migrate_pfn)
96+
__field(unsigned long, free_pfn)
9797
__field(unsigned long, zone_end)
98+
__field(bool, sync)
9899
),
99100

100101
TP_fast_assign(
101102
__entry->zone_start = zone_start;
102-
__entry->migrate_start = migrate_start;
103-
__entry->free_start = free_start;
103+
__entry->migrate_pfn = migrate_pfn;
104+
__entry->free_pfn = free_pfn;
104105
__entry->zone_end = zone_end;
106+
__entry->sync = sync;
105107
),
106108

107-
TP_printk("zone_start=0x%lx migrate_start=0x%lx free_start=0x%lx zone_end=0x%lx",
109+
TP_printk("zone_start=0x%lx migrate_pfn=0x%lx free_pfn=0x%lx zone_end=0x%lx, mode=%s",
108110
__entry->zone_start,
109-
__entry->migrate_start,
110-
__entry->free_start,
111-
__entry->zone_end)
111+
__entry->migrate_pfn,
112+
__entry->free_pfn,
113+
__entry->zone_end,
114+
__entry->sync ? "sync" : "async")
112115
);
113116

114117
TRACE_EVENT(mm_compaction_end,
115-
TP_PROTO(int status),
118+
TP_PROTO(unsigned long zone_start, unsigned long migrate_pfn,
119+
unsigned long free_pfn, unsigned long zone_end, bool sync,
120+
int status),
116121

117-
TP_ARGS(status),
122+
TP_ARGS(zone_start, migrate_pfn, free_pfn, zone_end, sync, status),
118123

119124
TP_STRUCT__entry(
125+
__field(unsigned long, zone_start)
126+
__field(unsigned long, migrate_pfn)
127+
__field(unsigned long, free_pfn)
128+
__field(unsigned long, zone_end)
129+
__field(bool, sync)
120130
__field(int, status)
121131
),
122132

123133
TP_fast_assign(
134+
__entry->zone_start = zone_start;
135+
__entry->migrate_pfn = migrate_pfn;
136+
__entry->free_pfn = free_pfn;
137+
__entry->zone_end = zone_end;
138+
__entry->sync = sync;
124139
__entry->status = status;
125140
),
126141

127-
TP_printk("status=%d", __entry->status)
142+
TP_printk("zone_start=0x%lx migrate_pfn=0x%lx free_pfn=0x%lx zone_end=0x%lx, mode=%s status=%s",
143+
__entry->zone_start,
144+
__entry->migrate_pfn,
145+
__entry->free_pfn,
146+
__entry->zone_end,
147+
__entry->sync ? "sync" : "async",
148+
compaction_status_string[__entry->status])
128149
);
129150

130151
#endif /* _TRACE_COMPACTION_H */

mm/compaction.c

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,15 @@ static inline void count_compact_events(enum vm_event_item item, long delta)
3434
#endif
3535

3636
#if defined CONFIG_COMPACTION || defined CONFIG_CMA
37+
#ifdef CONFIG_TRACEPOINTS
38+
static const char *const compaction_status_string[] = {
39+
"deferred",
40+
"skipped",
41+
"continue",
42+
"partial",
43+
"complete",
44+
};
45+
#endif
3746

3847
#define CREATE_TRACE_POINTS
3948
#include <trace/events/compaction.h>
@@ -1197,7 +1206,8 @@ static int compact_zone(struct zone *zone, struct compact_control *cc)
11971206
zone->compact_cached_migrate_pfn[1] = cc->migrate_pfn;
11981207
}
11991208

1200-
trace_mm_compaction_begin(start_pfn, cc->migrate_pfn, cc->free_pfn, end_pfn);
1209+
trace_mm_compaction_begin(start_pfn, cc->migrate_pfn,
1210+
cc->free_pfn, end_pfn, sync);
12011211

12021212
migrate_prep_local();
12031213

@@ -1299,7 +1309,8 @@ static int compact_zone(struct zone *zone, struct compact_control *cc)
12991309
zone->compact_cached_free_pfn = free_pfn;
13001310
}
13011311

1302-
trace_mm_compaction_end(ret);
1312+
trace_mm_compaction_end(start_pfn, cc->migrate_pfn,
1313+
cc->free_pfn, end_pfn, sync, ret);
13031314

13041315
return ret;
13051316
}

0 commit comments

Comments
 (0)