compaction.h 4.1 KB
Newer Older
1 2 3 4 5 6 7
#undef TRACE_SYSTEM
#define TRACE_SYSTEM compaction

#if !defined(_TRACE_COMPACTION_H) || defined(TRACE_HEADER_MULTI_READ)
#define _TRACE_COMPACTION_H

#include <linux/types.h>
8
#include <linux/list.h>
9
#include <linux/tracepoint.h>
10
#include <trace/events/gfpflags.h>
11 12 13

DECLARE_EVENT_CLASS(mm_compaction_isolate_template,

14 15 16 17
	TP_PROTO(
		unsigned long start_pfn,
		unsigned long end_pfn,
		unsigned long nr_scanned,
18 19
		unsigned long nr_taken),

20
	TP_ARGS(start_pfn, end_pfn, nr_scanned, nr_taken),
21 22

	TP_STRUCT__entry(
23 24
		__field(unsigned long, start_pfn)
		__field(unsigned long, end_pfn)
25 26 27 28 29
		__field(unsigned long, nr_scanned)
		__field(unsigned long, nr_taken)
	),

	TP_fast_assign(
30 31
		__entry->start_pfn = start_pfn;
		__entry->end_pfn = end_pfn;
32 33 34 35
		__entry->nr_scanned = nr_scanned;
		__entry->nr_taken = nr_taken;
	),

36 37 38
	TP_printk("range=(0x%lx ~ 0x%lx) nr_scanned=%lu nr_taken=%lu",
		__entry->start_pfn,
		__entry->end_pfn,
39 40 41 42 43 44
		__entry->nr_scanned,
		__entry->nr_taken)
);

DEFINE_EVENT(mm_compaction_isolate_template, mm_compaction_isolate_migratepages,

45 46 47 48
	TP_PROTO(
		unsigned long start_pfn,
		unsigned long end_pfn,
		unsigned long nr_scanned,
49 50
		unsigned long nr_taken),

51
	TP_ARGS(start_pfn, end_pfn, nr_scanned, nr_taken)
52 53 54
);

DEFINE_EVENT(mm_compaction_isolate_template, mm_compaction_isolate_freepages,
55 56 57 58 59

	TP_PROTO(
		unsigned long start_pfn,
		unsigned long end_pfn,
		unsigned long nr_scanned,
60 61
		unsigned long nr_taken),

62
	TP_ARGS(start_pfn, end_pfn, nr_scanned, nr_taken)
63 64 65 66
);

TRACE_EVENT(mm_compaction_migratepages,

67 68 69
	TP_PROTO(unsigned long nr_all,
		int migrate_rc,
		struct list_head *migratepages),
70

71
	TP_ARGS(nr_all, migrate_rc, migratepages),
72 73 74 75 76 77 78

	TP_STRUCT__entry(
		__field(unsigned long, nr_migrated)
		__field(unsigned long, nr_failed)
	),

	TP_fast_assign(
79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94
		unsigned long nr_failed = 0;
		struct list_head *page_lru;

		/*
		 * migrate_pages() returns either a non-negative number
		 * with the number of pages that failed migration, or an
		 * error code, in which case we need to count the remaining
		 * pages manually
		 */
		if (migrate_rc >= 0)
			nr_failed = migrate_rc;
		else
			list_for_each(page_lru, migratepages)
				nr_failed++;

		__entry->nr_migrated = nr_all - nr_failed;
95 96 97 98 99 100 101 102
		__entry->nr_failed = nr_failed;
	),

	TP_printk("nr_migrated=%lu nr_failed=%lu",
		__entry->nr_migrated,
		__entry->nr_failed)
);

103
TRACE_EVENT(mm_compaction_begin,
104 105
	TP_PROTO(unsigned long zone_start, unsigned long migrate_pfn,
		unsigned long free_pfn, unsigned long zone_end, bool sync),
106

107
	TP_ARGS(zone_start, migrate_pfn, free_pfn, zone_end, sync),
108 109 110

	TP_STRUCT__entry(
		__field(unsigned long, zone_start)
111 112
		__field(unsigned long, migrate_pfn)
		__field(unsigned long, free_pfn)
113
		__field(unsigned long, zone_end)
114
		__field(bool, sync)
115 116 117 118
	),

	TP_fast_assign(
		__entry->zone_start = zone_start;
119 120
		__entry->migrate_pfn = migrate_pfn;
		__entry->free_pfn = free_pfn;
121
		__entry->zone_end = zone_end;
122
		__entry->sync = sync;
123 124
	),

125
	TP_printk("zone_start=0x%lx migrate_pfn=0x%lx free_pfn=0x%lx zone_end=0x%lx, mode=%s",
126
		__entry->zone_start,
127 128 129 130
		__entry->migrate_pfn,
		__entry->free_pfn,
		__entry->zone_end,
		__entry->sync ? "sync" : "async")
131 132 133
);

TRACE_EVENT(mm_compaction_end,
134 135 136
	TP_PROTO(unsigned long zone_start, unsigned long migrate_pfn,
		unsigned long free_pfn, unsigned long zone_end, bool sync,
		int status),
137

138
	TP_ARGS(zone_start, migrate_pfn, free_pfn, zone_end, sync, status),
139 140

	TP_STRUCT__entry(
141 142 143 144 145
		__field(unsigned long, zone_start)
		__field(unsigned long, migrate_pfn)
		__field(unsigned long, free_pfn)
		__field(unsigned long, zone_end)
		__field(bool, sync)
146 147 148 149
		__field(int, status)
	),

	TP_fast_assign(
150 151 152 153 154
		__entry->zone_start = zone_start;
		__entry->migrate_pfn = migrate_pfn;
		__entry->free_pfn = free_pfn;
		__entry->zone_end = zone_end;
		__entry->sync = sync;
155 156 157
		__entry->status = status;
	),

158 159 160 161 162 163 164
	TP_printk("zone_start=0x%lx migrate_pfn=0x%lx free_pfn=0x%lx zone_end=0x%lx, mode=%s status=%s",
		__entry->zone_start,
		__entry->migrate_pfn,
		__entry->free_pfn,
		__entry->zone_end,
		__entry->sync ? "sync" : "async",
		compaction_status_string[__entry->status])
165
);
166 167 168 169 170

#endif /* _TRACE_COMPACTION_H */

/* This part must be outside protection */
#include <trace/define_trace.h>