Commit abd4349f authored by Baolin Wang's avatar Baolin Wang Committed by Linus Torvalds

mm: compaction: cleanup the compaction trace events

As Steven suggested [1], we should access the pointers from the trace
event to avoid dereferencing them to the tracepoint function when the
tracepoint is disabled.

[1] https://lkml.org/lkml/2021/11/3/409

Link: https://lkml.kernel.org/r/4cd393b4d57f8f01ed72c001509b28e3a3b1a8c1.1646985115.git.baolin.wang@linux.alibaba.comSigned-off-by: default avatarBaolin Wang <baolin.wang@linux.alibaba.com>
Cc: Steven Rostedt (Google) <rostedt@goodmis.org>
Cc: Ingo Molnar <mingo@redhat.com>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
parent 96bd3e79
...@@ -67,10 +67,10 @@ DEFINE_EVENT(mm_compaction_isolate_template, mm_compaction_isolate_freepages, ...@@ -67,10 +67,10 @@ DEFINE_EVENT(mm_compaction_isolate_template, mm_compaction_isolate_freepages,
#ifdef CONFIG_COMPACTION #ifdef CONFIG_COMPACTION
TRACE_EVENT(mm_compaction_migratepages, TRACE_EVENT(mm_compaction_migratepages,
TP_PROTO(unsigned long nr_all, TP_PROTO(struct compact_control *cc,
unsigned int nr_succeeded), unsigned int nr_succeeded),
TP_ARGS(nr_all, nr_succeeded), TP_ARGS(cc, nr_succeeded),
TP_STRUCT__entry( TP_STRUCT__entry(
__field(unsigned long, nr_migrated) __field(unsigned long, nr_migrated)
...@@ -79,7 +79,7 @@ TRACE_EVENT(mm_compaction_migratepages, ...@@ -79,7 +79,7 @@ TRACE_EVENT(mm_compaction_migratepages,
TP_fast_assign( TP_fast_assign(
__entry->nr_migrated = nr_succeeded; __entry->nr_migrated = nr_succeeded;
__entry->nr_failed = nr_all - nr_succeeded; __entry->nr_failed = cc->nr_migratepages - nr_succeeded;
), ),
TP_printk("nr_migrated=%lu nr_failed=%lu", TP_printk("nr_migrated=%lu nr_failed=%lu",
...@@ -88,10 +88,10 @@ TRACE_EVENT(mm_compaction_migratepages, ...@@ -88,10 +88,10 @@ TRACE_EVENT(mm_compaction_migratepages,
); );
TRACE_EVENT(mm_compaction_begin, TRACE_EVENT(mm_compaction_begin,
TP_PROTO(unsigned long zone_start, unsigned long migrate_pfn, TP_PROTO(struct compact_control *cc, unsigned long zone_start,
unsigned long free_pfn, unsigned long zone_end, bool sync), unsigned long zone_end, bool sync),
TP_ARGS(zone_start, migrate_pfn, free_pfn, zone_end, sync), TP_ARGS(cc, zone_start, zone_end, sync),
TP_STRUCT__entry( TP_STRUCT__entry(
__field(unsigned long, zone_start) __field(unsigned long, zone_start)
...@@ -103,8 +103,8 @@ TRACE_EVENT(mm_compaction_begin, ...@@ -103,8 +103,8 @@ TRACE_EVENT(mm_compaction_begin,
TP_fast_assign( TP_fast_assign(
__entry->zone_start = zone_start; __entry->zone_start = zone_start;
__entry->migrate_pfn = migrate_pfn; __entry->migrate_pfn = cc->migrate_pfn;
__entry->free_pfn = free_pfn; __entry->free_pfn = cc->free_pfn;
__entry->zone_end = zone_end; __entry->zone_end = zone_end;
__entry->sync = sync; __entry->sync = sync;
), ),
...@@ -118,11 +118,11 @@ TRACE_EVENT(mm_compaction_begin, ...@@ -118,11 +118,11 @@ TRACE_EVENT(mm_compaction_begin,
); );
TRACE_EVENT(mm_compaction_end, TRACE_EVENT(mm_compaction_end,
TP_PROTO(unsigned long zone_start, unsigned long migrate_pfn, TP_PROTO(struct compact_control *cc, unsigned long zone_start,
unsigned long free_pfn, unsigned long zone_end, bool sync, unsigned long zone_end, bool sync,
int status), int status),
TP_ARGS(zone_start, migrate_pfn, free_pfn, zone_end, sync, status), TP_ARGS(cc, zone_start, zone_end, sync, status),
TP_STRUCT__entry( TP_STRUCT__entry(
__field(unsigned long, zone_start) __field(unsigned long, zone_start)
...@@ -135,8 +135,8 @@ TRACE_EVENT(mm_compaction_end, ...@@ -135,8 +135,8 @@ TRACE_EVENT(mm_compaction_end,
TP_fast_assign( TP_fast_assign(
__entry->zone_start = zone_start; __entry->zone_start = zone_start;
__entry->migrate_pfn = migrate_pfn; __entry->migrate_pfn = cc->migrate_pfn;
__entry->free_pfn = free_pfn; __entry->free_pfn = cc->free_pfn;
__entry->zone_end = zone_end; __entry->zone_end = zone_end;
__entry->sync = sync; __entry->sync = sync;
__entry->status = status; __entry->status = status;
......
...@@ -2387,8 +2387,7 @@ compact_zone(struct compact_control *cc, struct capture_control *capc) ...@@ -2387,8 +2387,7 @@ compact_zone(struct compact_control *cc, struct capture_control *capc)
update_cached = !sync && update_cached = !sync &&
cc->zone->compact_cached_migrate_pfn[0] == cc->zone->compact_cached_migrate_pfn[1]; cc->zone->compact_cached_migrate_pfn[0] == cc->zone->compact_cached_migrate_pfn[1];
trace_mm_compaction_begin(start_pfn, cc->migrate_pfn, trace_mm_compaction_begin(cc, start_pfn, end_pfn, sync);
cc->free_pfn, end_pfn, sync);
/* lru_add_drain_all could be expensive with involving other CPUs */ /* lru_add_drain_all could be expensive with involving other CPUs */
lru_add_drain(); lru_add_drain();
...@@ -2438,8 +2437,7 @@ compact_zone(struct compact_control *cc, struct capture_control *capc) ...@@ -2438,8 +2437,7 @@ compact_zone(struct compact_control *cc, struct capture_control *capc)
compaction_free, (unsigned long)cc, cc->mode, compaction_free, (unsigned long)cc, cc->mode,
MR_COMPACTION, &nr_succeeded); MR_COMPACTION, &nr_succeeded);
trace_mm_compaction_migratepages(cc->nr_migratepages, trace_mm_compaction_migratepages(cc, nr_succeeded);
nr_succeeded);
/* All pages were either migrated or will be released */ /* All pages were either migrated or will be released */
cc->nr_migratepages = 0; cc->nr_migratepages = 0;
...@@ -2515,8 +2513,7 @@ compact_zone(struct compact_control *cc, struct capture_control *capc) ...@@ -2515,8 +2513,7 @@ compact_zone(struct compact_control *cc, struct capture_control *capc)
count_compact_events(COMPACTMIGRATE_SCANNED, cc->total_migrate_scanned); count_compact_events(COMPACTMIGRATE_SCANNED, cc->total_migrate_scanned);
count_compact_events(COMPACTFREE_SCANNED, cc->total_free_scanned); count_compact_events(COMPACTFREE_SCANNED, cc->total_free_scanned);
trace_mm_compaction_end(start_pfn, cc->migrate_pfn, trace_mm_compaction_end(cc, start_pfn, end_pfn, sync, ret);
cc->free_pfn, end_pfn, sync, ret);
return ret; return ret;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment