1 /* SPDX-License-Identifier: GPL-2.0 */
2 #undef TRACE_SYSTEM
3 #define TRACE_SYSTEM huge_memory
4 
5 #if !defined(__HUGE_MEMORY_H) || defined(TRACE_HEADER_MULTI_READ)
6 #define __HUGE_MEMORY_H
7 
8 #include  <linux/tracepoint.h>
9 
10 #define SCAN_STATUS							\
11 	EM( SCAN_FAIL,			"failed")			\
12 	EM( SCAN_SUCCEED,		"succeeded")			\
13 	EM( SCAN_PMD_NULL,		"pmd_null")			\
14 	EM( SCAN_PMD_NONE,		"pmd_none")			\
15 	EM( SCAN_PMD_MAPPED,		"page_pmd_mapped")		\
16 	EM( SCAN_EXCEED_NONE_PTE,	"exceed_none_pte")		\
17 	EM( SCAN_EXCEED_SWAP_PTE,	"exceed_swap_pte")		\
18 	EM( SCAN_EXCEED_SHARED_PTE,	"exceed_shared_pte")		\
19 	EM( SCAN_PTE_NON_PRESENT,	"pte_non_present")		\
20 	EM( SCAN_PTE_UFFD_WP,		"pte_uffd_wp")			\
21 	EM( SCAN_PTE_MAPPED_HUGEPAGE,	"pte_mapped_hugepage")		\
22 	EM( SCAN_PAGE_RO,		"no_writable_page")		\
23 	EM( SCAN_LACK_REFERENCED_PAGE,	"lack_referenced_page")		\
24 	EM( SCAN_PAGE_NULL,		"page_null")			\
25 	EM( SCAN_SCAN_ABORT,		"scan_aborted")			\
26 	EM( SCAN_PAGE_COUNT,		"not_suitable_page_count")	\
27 	EM( SCAN_PAGE_LRU,		"page_not_in_lru")		\
28 	EM( SCAN_PAGE_LOCK,		"page_locked")			\
29 	EM( SCAN_PAGE_ANON,		"page_not_anon")		\
30 	EM( SCAN_PAGE_COMPOUND,		"page_compound")		\
31 	EM( SCAN_ANY_PROCESS,		"no_process_for_page")		\
32 	EM( SCAN_VMA_NULL,		"vma_null")			\
33 	EM( SCAN_VMA_CHECK,		"vma_check_failed")		\
34 	EM( SCAN_ADDRESS_RANGE,		"not_suitable_address_range")	\
35 	EM( SCAN_DEL_PAGE_LRU,		"could_not_delete_page_from_lru")\
36 	EM( SCAN_ALLOC_HUGE_PAGE_FAIL,	"alloc_huge_page_failed")	\
37 	EM( SCAN_CGROUP_CHARGE_FAIL,	"ccgroup_charge_failed")	\
38 	EM( SCAN_TRUNCATED,		"truncated")			\
39 	EMe(SCAN_PAGE_HAS_PRIVATE,	"page_has_private")		\
40 
41 #undef EM
42 #undef EMe
43 #define EM(a, b)	TRACE_DEFINE_ENUM(a);
44 #define EMe(a, b)	TRACE_DEFINE_ENUM(a);
45 
46 SCAN_STATUS
47 
48 #undef EM
49 #undef EMe
50 #define EM(a, b)	{a, b},
51 #define EMe(a, b)	{a, b}
52 
53 TRACE_EVENT(mm_khugepaged_scan_pmd,
54 
55 	TP_PROTO(struct mm_struct *mm, struct page *page, bool writable,
56 		 int referenced, int none_or_zero, int status, int unmapped),
57 
58 	TP_ARGS(mm, page, writable, referenced, none_or_zero, status, unmapped),
59 
60 	TP_STRUCT__entry(
61 		__field(struct mm_struct *, mm)
62 		__field(unsigned long, pfn)
63 		__field(bool, writable)
64 		__field(int, referenced)
65 		__field(int, none_or_zero)
66 		__field(int, status)
67 		__field(int, unmapped)
68 	),
69 
70 	TP_fast_assign(
71 		__entry->mm = mm;
72 		__entry->pfn = page ? page_to_pfn(page) : -1;
73 		__entry->writable = writable;
74 		__entry->referenced = referenced;
75 		__entry->none_or_zero = none_or_zero;
76 		__entry->status = status;
77 		__entry->unmapped = unmapped;
78 	),
79 
80 	TP_printk("mm=%p, scan_pfn=0x%lx, writable=%d, referenced=%d, none_or_zero=%d, status=%s, unmapped=%d",
81 		__entry->mm,
82 		__entry->pfn,
83 		__entry->writable,
84 		__entry->referenced,
85 		__entry->none_or_zero,
86 		__print_symbolic(__entry->status, SCAN_STATUS),
87 		__entry->unmapped)
88 );
89 
90 TRACE_EVENT(mm_collapse_huge_page,
91 
92 	TP_PROTO(struct mm_struct *mm, int isolated, int status),
93 
94 	TP_ARGS(mm, isolated, status),
95 
96 	TP_STRUCT__entry(
97 		__field(struct mm_struct *, mm)
98 		__field(int, isolated)
99 		__field(int, status)
100 	),
101 
102 	TP_fast_assign(
103 		__entry->mm = mm;
104 		__entry->isolated = isolated;
105 		__entry->status = status;
106 	),
107 
108 	TP_printk("mm=%p, isolated=%d, status=%s",
109 		__entry->mm,
110 		__entry->isolated,
111 		__print_symbolic(__entry->status, SCAN_STATUS))
112 );
113 
114 TRACE_EVENT(mm_collapse_huge_page_isolate,
115 
116 	TP_PROTO(struct page *page, int none_or_zero,
117 		 int referenced, bool  writable, int status),
118 
119 	TP_ARGS(page, none_or_zero, referenced, writable, status),
120 
121 	TP_STRUCT__entry(
122 		__field(unsigned long, pfn)
123 		__field(int, none_or_zero)
124 		__field(int, referenced)
125 		__field(bool, writable)
126 		__field(int, status)
127 	),
128 
129 	TP_fast_assign(
130 		__entry->pfn = page ? page_to_pfn(page) : -1;
131 		__entry->none_or_zero = none_or_zero;
132 		__entry->referenced = referenced;
133 		__entry->writable = writable;
134 		__entry->status = status;
135 	),
136 
137 	TP_printk("scan_pfn=0x%lx, none_or_zero=%d, referenced=%d, writable=%d, status=%s",
138 		__entry->pfn,
139 		__entry->none_or_zero,
140 		__entry->referenced,
141 		__entry->writable,
142 		__print_symbolic(__entry->status, SCAN_STATUS))
143 );
144 
145 TRACE_EVENT(mm_collapse_huge_page_swapin,
146 
147 	TP_PROTO(struct mm_struct *mm, int swapped_in, int referenced, int ret),
148 
149 	TP_ARGS(mm, swapped_in, referenced, ret),
150 
151 	TP_STRUCT__entry(
152 		__field(struct mm_struct *, mm)
153 		__field(int, swapped_in)
154 		__field(int, referenced)
155 		__field(int, ret)
156 	),
157 
158 	TP_fast_assign(
159 		__entry->mm = mm;
160 		__entry->swapped_in = swapped_in;
161 		__entry->referenced = referenced;
162 		__entry->ret = ret;
163 	),
164 
165 	TP_printk("mm=%p, swapped_in=%d, referenced=%d, ret=%d",
166 		__entry->mm,
167 		__entry->swapped_in,
168 		__entry->referenced,
169 		__entry->ret)
170 );
171 
172 TRACE_EVENT(mm_khugepaged_scan_file,
173 
174 	TP_PROTO(struct mm_struct *mm, struct page *page, const char *filename,
175 		 int present, int swap, int result),
176 
177 	TP_ARGS(mm, page, filename, present, swap, result),
178 
179 	TP_STRUCT__entry(
180 		__field(struct mm_struct *, mm)
181 		__field(unsigned long, pfn)
182 		__string(filename, filename)
183 		__field(int, present)
184 		__field(int, swap)
185 		__field(int, result)
186 	),
187 
188 	TP_fast_assign(
189 		__entry->mm = mm;
190 		__entry->pfn = page ? page_to_pfn(page) : -1;
191 		__assign_str(filename, filename);
192 		__entry->present = present;
193 		__entry->swap = swap;
194 		__entry->result = result;
195 	),
196 
197 	TP_printk("mm=%p, scan_pfn=0x%lx, filename=%s, present=%d, swap=%d, result=%s",
198 		__entry->mm,
199 		__entry->pfn,
200 		__get_str(filename),
201 		__entry->present,
202 		__entry->swap,
203 		__print_symbolic(__entry->result, SCAN_STATUS))
204 );
205 
206 #endif /* __HUGE_MEMORY_H */
207 #include <trace/define_trace.h>
208