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_EXCEED_NONE_PTE,	"exceed_none_pte")		\
15 	EM( SCAN_PTE_NON_PRESENT,	"pte_non_present")		\
16 	EM( SCAN_PAGE_RO,		"no_writable_page")		\
17 	EM( SCAN_LACK_REFERENCED_PAGE,	"lack_referenced_page")		\
18 	EM( SCAN_PAGE_NULL,		"page_null")			\
19 	EM( SCAN_SCAN_ABORT,		"scan_aborted")			\
20 	EM( SCAN_PAGE_COUNT,		"not_suitable_page_count")	\
21 	EM( SCAN_PAGE_LRU,		"page_not_in_lru")		\
22 	EM( SCAN_PAGE_LOCK,		"page_locked")			\
23 	EM( SCAN_PAGE_ANON,		"page_not_anon")		\
24 	EM( SCAN_PAGE_COMPOUND,		"page_compound")		\
25 	EM( SCAN_ANY_PROCESS,		"no_process_for_page")		\
26 	EM( SCAN_VMA_NULL,		"vma_null")			\
27 	EM( SCAN_VMA_CHECK,		"vma_check_failed")		\
28 	EM( SCAN_ADDRESS_RANGE,		"not_suitable_address_range")	\
29 	EM( SCAN_SWAP_CACHE_PAGE,	"page_swap_cache")		\
30 	EM( SCAN_DEL_PAGE_LRU,		"could_not_delete_page_from_lru")\
31 	EM( SCAN_ALLOC_HUGE_PAGE_FAIL,	"alloc_huge_page_failed")	\
32 	EM( SCAN_CGROUP_CHARGE_FAIL,	"ccgroup_charge_failed")	\
33 	EM( SCAN_EXCEED_SWAP_PTE,	"exceed_swap_pte")		\
34 	EM( SCAN_TRUNCATED,		"truncated")			\
35 	EMe(SCAN_PAGE_HAS_PRIVATE,	"page_has_private")		\
36 
37 #undef EM
38 #undef EMe
39 #define EM(a, b)	TRACE_DEFINE_ENUM(a);
40 #define EMe(a, b)	TRACE_DEFINE_ENUM(a);
41 
42 SCAN_STATUS
43 
44 #undef EM
45 #undef EMe
46 #define EM(a, b)	{a, b},
47 #define EMe(a, b)	{a, b}
48 
49 TRACE_EVENT(mm_khugepaged_scan_pmd,
50 
51 	TP_PROTO(struct mm_struct *mm, struct page *page, bool writable,
52 		 int referenced, int none_or_zero, int status, int unmapped),
53 
54 	TP_ARGS(mm, page, writable, referenced, none_or_zero, status, unmapped),
55 
56 	TP_STRUCT__entry(
57 		__field(struct mm_struct *, mm)
58 		__field(unsigned long, pfn)
59 		__field(bool, writable)
60 		__field(int, referenced)
61 		__field(int, none_or_zero)
62 		__field(int, status)
63 		__field(int, unmapped)
64 	),
65 
66 	TP_fast_assign(
67 		__entry->mm = mm;
68 		__entry->pfn = page ? page_to_pfn(page) : -1;
69 		__entry->writable = writable;
70 		__entry->referenced = referenced;
71 		__entry->none_or_zero = none_or_zero;
72 		__entry->status = status;
73 		__entry->unmapped = unmapped;
74 	),
75 
76 	TP_printk("mm=%p, scan_pfn=0x%lx, writable=%d, referenced=%d, none_or_zero=%d, status=%s, unmapped=%d",
77 		__entry->mm,
78 		__entry->pfn,
79 		__entry->writable,
80 		__entry->referenced,
81 		__entry->none_or_zero,
82 		__print_symbolic(__entry->status, SCAN_STATUS),
83 		__entry->unmapped)
84 );
85 
86 TRACE_EVENT(mm_collapse_huge_page,
87 
88 	TP_PROTO(struct mm_struct *mm, int isolated, int status),
89 
90 	TP_ARGS(mm, isolated, status),
91 
92 	TP_STRUCT__entry(
93 		__field(struct mm_struct *, mm)
94 		__field(int, isolated)
95 		__field(int, status)
96 	),
97 
98 	TP_fast_assign(
99 		__entry->mm = mm;
100 		__entry->isolated = isolated;
101 		__entry->status = status;
102 	),
103 
104 	TP_printk("mm=%p, isolated=%d, status=%s",
105 		__entry->mm,
106 		__entry->isolated,
107 		__print_symbolic(__entry->status, SCAN_STATUS))
108 );
109 
110 TRACE_EVENT(mm_collapse_huge_page_isolate,
111 
112 	TP_PROTO(struct page *page, int none_or_zero,
113 		 int referenced, bool  writable, int status),
114 
115 	TP_ARGS(page, none_or_zero, referenced, writable, status),
116 
117 	TP_STRUCT__entry(
118 		__field(unsigned long, pfn)
119 		__field(int, none_or_zero)
120 		__field(int, referenced)
121 		__field(bool, writable)
122 		__field(int, status)
123 	),
124 
125 	TP_fast_assign(
126 		__entry->pfn = page ? page_to_pfn(page) : -1;
127 		__entry->none_or_zero = none_or_zero;
128 		__entry->referenced = referenced;
129 		__entry->writable = writable;
130 		__entry->status = status;
131 	),
132 
133 	TP_printk("scan_pfn=0x%lx, none_or_zero=%d, referenced=%d, writable=%d, status=%s",
134 		__entry->pfn,
135 		__entry->none_or_zero,
136 		__entry->referenced,
137 		__entry->writable,
138 		__print_symbolic(__entry->status, SCAN_STATUS))
139 );
140 
141 TRACE_EVENT(mm_collapse_huge_page_swapin,
142 
143 	TP_PROTO(struct mm_struct *mm, int swapped_in, int referenced, int ret),
144 
145 	TP_ARGS(mm, swapped_in, referenced, ret),
146 
147 	TP_STRUCT__entry(
148 		__field(struct mm_struct *, mm)
149 		__field(int, swapped_in)
150 		__field(int, referenced)
151 		__field(int, ret)
152 	),
153 
154 	TP_fast_assign(
155 		__entry->mm = mm;
156 		__entry->swapped_in = swapped_in;
157 		__entry->referenced = referenced;
158 		__entry->ret = ret;
159 	),
160 
161 	TP_printk("mm=%p, swapped_in=%d, referenced=%d, ret=%d",
162 		__entry->mm,
163 		__entry->swapped_in,
164 		__entry->referenced,
165 		__entry->ret)
166 );
167 
168 #endif /* __HUGE_MEMORY_H */
169 #include <trace/define_trace.h>
170