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