xref: /openbmc/linux/include/trace/events/mmflags.h (revision ffcdf473)
1 /* SPDX-License-Identifier: GPL-2.0 */
2 #include <linux/node.h>
3 #include <linux/mmzone.h>
4 #include <linux/compaction.h>
5 /*
6  * The order of these masks is important. Matching masks will be seen
7  * first and the left over flags will end up showing by themselves.
8  *
9  * For example, if we have GFP_KERNEL before GFP_USER we wil get:
10  *
11  *  GFP_KERNEL|GFP_HARDWALL
12  *
13  * Thus most bits set go first.
14  */
15 
16 #define gfpflag_string(flag) {(__force unsigned long)flag, #flag}
17 
18 #define __def_gfpflag_names			\
19 	gfpflag_string(GFP_TRANSHUGE),		\
20 	gfpflag_string(GFP_TRANSHUGE_LIGHT),	\
21 	gfpflag_string(GFP_HIGHUSER_MOVABLE),	\
22 	gfpflag_string(GFP_HIGHUSER),		\
23 	gfpflag_string(GFP_USER),		\
24 	gfpflag_string(GFP_KERNEL_ACCOUNT),	\
25 	gfpflag_string(GFP_KERNEL),		\
26 	gfpflag_string(GFP_NOFS),		\
27 	gfpflag_string(GFP_ATOMIC),		\
28 	gfpflag_string(GFP_NOIO),		\
29 	gfpflag_string(GFP_NOWAIT),		\
30 	gfpflag_string(GFP_DMA),		\
31 	gfpflag_string(__GFP_HIGHMEM),		\
32 	gfpflag_string(GFP_DMA32),		\
33 	gfpflag_string(__GFP_HIGH),		\
34 	gfpflag_string(__GFP_IO),		\
35 	gfpflag_string(__GFP_FS),		\
36 	gfpflag_string(__GFP_NOWARN),		\
37 	gfpflag_string(__GFP_RETRY_MAYFAIL),	\
38 	gfpflag_string(__GFP_NOFAIL),		\
39 	gfpflag_string(__GFP_NORETRY),		\
40 	gfpflag_string(__GFP_COMP),		\
41 	gfpflag_string(__GFP_ZERO),		\
42 	gfpflag_string(__GFP_NOMEMALLOC),	\
43 	gfpflag_string(__GFP_MEMALLOC),		\
44 	gfpflag_string(__GFP_HARDWALL),		\
45 	gfpflag_string(__GFP_THISNODE),		\
46 	gfpflag_string(__GFP_RECLAIMABLE),	\
47 	gfpflag_string(__GFP_MOVABLE),		\
48 	gfpflag_string(__GFP_ACCOUNT),		\
49 	gfpflag_string(__GFP_WRITE),		\
50 	gfpflag_string(__GFP_RECLAIM),		\
51 	gfpflag_string(__GFP_DIRECT_RECLAIM),	\
52 	gfpflag_string(__GFP_KSWAPD_RECLAIM),	\
53 	gfpflag_string(__GFP_ZEROTAGS)
54 
55 #ifdef CONFIG_KASAN_HW_TAGS
56 #define __def_gfpflag_names_kasan ,			\
57 	gfpflag_string(__GFP_SKIP_ZERO),		\
58 	gfpflag_string(__GFP_SKIP_KASAN)
59 #else
60 #define __def_gfpflag_names_kasan
61 #endif
62 
63 #define show_gfp_flags(flags)						\
64 	(flags) ? __print_flags(flags, "|",				\
65 	__def_gfpflag_names __def_gfpflag_names_kasan			\
66 	) : "none"
67 
68 #ifdef CONFIG_MMU
69 #define IF_HAVE_PG_MLOCK(_name) ,{1UL << PG_##_name, __stringify(_name)}
70 #else
71 #define IF_HAVE_PG_MLOCK(_name)
72 #endif
73 
74 #ifdef CONFIG_ARCH_USES_PG_UNCACHED
75 #define IF_HAVE_PG_UNCACHED(_name) ,{1UL << PG_##_name, __stringify(_name)}
76 #else
77 #define IF_HAVE_PG_UNCACHED(_name)
78 #endif
79 
80 #ifdef CONFIG_MEMORY_FAILURE
81 #define IF_HAVE_PG_HWPOISON(_name) ,{1UL << PG_##_name, __stringify(_name)}
82 #else
83 #define IF_HAVE_PG_HWPOISON(_name)
84 #endif
85 
86 #if defined(CONFIG_PAGE_IDLE_FLAG) && defined(CONFIG_64BIT)
87 #define IF_HAVE_PG_IDLE(_name) ,{1UL << PG_##_name, __stringify(_name)}
88 #else
89 #define IF_HAVE_PG_IDLE(_name)
90 #endif
91 
92 #ifdef CONFIG_ARCH_USES_PG_ARCH_X
93 #define IF_HAVE_PG_ARCH_X(_name) ,{1UL << PG_##_name, __stringify(_name)}
94 #else
95 #define IF_HAVE_PG_ARCH_X(_name)
96 #endif
97 
98 #define DEF_PAGEFLAG_NAME(_name) { 1UL <<  PG_##_name, __stringify(_name) }
99 
100 #define __def_pageflag_names						\
101 	DEF_PAGEFLAG_NAME(locked),					\
102 	DEF_PAGEFLAG_NAME(waiters),					\
103 	DEF_PAGEFLAG_NAME(error),					\
104 	DEF_PAGEFLAG_NAME(referenced),					\
105 	DEF_PAGEFLAG_NAME(uptodate),					\
106 	DEF_PAGEFLAG_NAME(dirty),					\
107 	DEF_PAGEFLAG_NAME(lru),						\
108 	DEF_PAGEFLAG_NAME(active),					\
109 	DEF_PAGEFLAG_NAME(workingset),					\
110 	DEF_PAGEFLAG_NAME(slab),					\
111 	DEF_PAGEFLAG_NAME(owner_priv_1),				\
112 	DEF_PAGEFLAG_NAME(arch_1),					\
113 	DEF_PAGEFLAG_NAME(reserved),					\
114 	DEF_PAGEFLAG_NAME(private),					\
115 	DEF_PAGEFLAG_NAME(private_2),					\
116 	DEF_PAGEFLAG_NAME(writeback),					\
117 	DEF_PAGEFLAG_NAME(head),					\
118 	DEF_PAGEFLAG_NAME(mappedtodisk),				\
119 	DEF_PAGEFLAG_NAME(reclaim),					\
120 	DEF_PAGEFLAG_NAME(swapbacked),					\
121 	DEF_PAGEFLAG_NAME(unevictable)					\
122 IF_HAVE_PG_MLOCK(mlocked)						\
123 IF_HAVE_PG_UNCACHED(uncached)						\
124 IF_HAVE_PG_HWPOISON(hwpoison)						\
125 IF_HAVE_PG_IDLE(idle)							\
126 IF_HAVE_PG_IDLE(young)							\
127 IF_HAVE_PG_ARCH_X(arch_2)						\
128 IF_HAVE_PG_ARCH_X(arch_3)
129 
130 #define show_page_flags(flags)						\
131 	(flags) ? __print_flags(flags, "|",				\
132 	__def_pageflag_names						\
133 	) : "none"
134 
135 #define DEF_PAGETYPE_NAME(_name) { PG_##_name, __stringify(_name) }
136 
137 #define __def_pagetype_names						\
138 	DEF_PAGETYPE_NAME(offline),					\
139 	DEF_PAGETYPE_NAME(guard),					\
140 	DEF_PAGETYPE_NAME(table),					\
141 	DEF_PAGETYPE_NAME(buddy)
142 
143 #if defined(CONFIG_X86)
144 #define __VM_ARCH_SPECIFIC_1 {VM_PAT,     "pat"           }
145 #elif defined(CONFIG_PPC)
146 #define __VM_ARCH_SPECIFIC_1 {VM_SAO,     "sao"           }
147 #elif defined(CONFIG_PARISC) || defined(CONFIG_IA64)
148 #define __VM_ARCH_SPECIFIC_1 {VM_GROWSUP,	"growsup"	}
149 #elif !defined(CONFIG_MMU)
150 #define __VM_ARCH_SPECIFIC_1 {VM_MAPPED_COPY,"mappedcopy"	}
151 #else
152 #define __VM_ARCH_SPECIFIC_1 {VM_ARCH_1,	"arch_1"	}
153 #endif
154 
155 #ifdef CONFIG_MEM_SOFT_DIRTY
156 #define IF_HAVE_VM_SOFTDIRTY(flag,name) {flag, name },
157 #else
158 #define IF_HAVE_VM_SOFTDIRTY(flag,name)
159 #endif
160 
161 #ifdef CONFIG_HAVE_ARCH_USERFAULTFD_MINOR
162 # define IF_HAVE_UFFD_MINOR(flag, name) {flag, name},
163 #else
164 # define IF_HAVE_UFFD_MINOR(flag, name)
165 #endif
166 
167 #define __def_vmaflag_names						\
168 	{VM_READ,			"read"		},		\
169 	{VM_WRITE,			"write"		},		\
170 	{VM_EXEC,			"exec"		},		\
171 	{VM_SHARED,			"shared"	},		\
172 	{VM_MAYREAD,			"mayread"	},		\
173 	{VM_MAYWRITE,			"maywrite"	},		\
174 	{VM_MAYEXEC,			"mayexec"	},		\
175 	{VM_MAYSHARE,			"mayshare"	},		\
176 	{VM_GROWSDOWN,			"growsdown"	},		\
177 	{VM_UFFD_MISSING,		"uffd_missing"	},		\
178 IF_HAVE_UFFD_MINOR(VM_UFFD_MINOR,	"uffd_minor"	)		\
179 	{VM_PFNMAP,			"pfnmap"	},		\
180 	{VM_UFFD_WP,			"uffd_wp"	},		\
181 	{VM_LOCKED,			"locked"	},		\
182 	{VM_IO,				"io"		},		\
183 	{VM_SEQ_READ,			"seqread"	},		\
184 	{VM_RAND_READ,			"randread"	},		\
185 	{VM_DONTCOPY,			"dontcopy"	},		\
186 	{VM_DONTEXPAND,			"dontexpand"	},		\
187 	{VM_LOCKONFAULT,		"lockonfault"	},		\
188 	{VM_ACCOUNT,			"account"	},		\
189 	{VM_NORESERVE,			"noreserve"	},		\
190 	{VM_HUGETLB,			"hugetlb"	},		\
191 	{VM_SYNC,			"sync"		},		\
192 	__VM_ARCH_SPECIFIC_1				,		\
193 	{VM_WIPEONFORK,			"wipeonfork"	},		\
194 	{VM_DONTDUMP,			"dontdump"	},		\
195 IF_HAVE_VM_SOFTDIRTY(VM_SOFTDIRTY,	"softdirty"	)		\
196 	{VM_MIXEDMAP,			"mixedmap"	},		\
197 	{VM_HUGEPAGE,			"hugepage"	},		\
198 	{VM_NOHUGEPAGE,			"nohugepage"	},		\
199 	{VM_MERGEABLE,			"mergeable"	}		\
200 
201 #define show_vma_flags(flags)						\
202 	(flags) ? __print_flags(flags, "|",				\
203 	__def_vmaflag_names						\
204 	) : "none"
205 
206 #ifdef CONFIG_COMPACTION
207 #define COMPACTION_STATUS					\
208 	EM( COMPACT_SKIPPED,		"skipped")		\
209 	EM( COMPACT_DEFERRED,		"deferred")		\
210 	EM( COMPACT_CONTINUE,		"continue")		\
211 	EM( COMPACT_SUCCESS,		"success")		\
212 	EM( COMPACT_PARTIAL_SKIPPED,	"partial_skipped")	\
213 	EM( COMPACT_COMPLETE,		"complete")		\
214 	EM( COMPACT_NO_SUITABLE_PAGE,	"no_suitable_page")	\
215 	EM( COMPACT_NOT_SUITABLE_ZONE,	"not_suitable_zone")	\
216 	EMe(COMPACT_CONTENDED,		"contended")
217 
218 /* High-level compaction status feedback */
219 #define COMPACTION_FAILED	1
220 #define COMPACTION_WITHDRAWN	2
221 #define COMPACTION_PROGRESS	3
222 
223 #define compact_result_to_feedback(result)	\
224 ({						\
225 	enum compact_result __result = result;	\
226 	(compaction_failed(__result)) ? COMPACTION_FAILED : \
227 		(compaction_withdrawn(__result)) ? COMPACTION_WITHDRAWN : COMPACTION_PROGRESS; \
228 })
229 
230 #define COMPACTION_FEEDBACK		\
231 	EM(COMPACTION_FAILED,		"failed")	\
232 	EM(COMPACTION_WITHDRAWN,	"withdrawn")	\
233 	EMe(COMPACTION_PROGRESS,	"progress")
234 
235 #define COMPACTION_PRIORITY						\
236 	EM(COMPACT_PRIO_SYNC_FULL,	"COMPACT_PRIO_SYNC_FULL")	\
237 	EM(COMPACT_PRIO_SYNC_LIGHT,	"COMPACT_PRIO_SYNC_LIGHT")	\
238 	EMe(COMPACT_PRIO_ASYNC,		"COMPACT_PRIO_ASYNC")
239 #else
240 #define COMPACTION_STATUS
241 #define COMPACTION_PRIORITY
242 #define COMPACTION_FEEDBACK
243 #endif
244 
245 #ifdef CONFIG_ZONE_DMA
246 #define IFDEF_ZONE_DMA(X) X
247 #else
248 #define IFDEF_ZONE_DMA(X)
249 #endif
250 
251 #ifdef CONFIG_ZONE_DMA32
252 #define IFDEF_ZONE_DMA32(X) X
253 #else
254 #define IFDEF_ZONE_DMA32(X)
255 #endif
256 
257 #ifdef CONFIG_HIGHMEM
258 #define IFDEF_ZONE_HIGHMEM(X) X
259 #else
260 #define IFDEF_ZONE_HIGHMEM(X)
261 #endif
262 
263 #define ZONE_TYPE						\
264 	IFDEF_ZONE_DMA(		EM (ZONE_DMA,	 "DMA"))	\
265 	IFDEF_ZONE_DMA32(	EM (ZONE_DMA32,	 "DMA32"))	\
266 				EM (ZONE_NORMAL, "Normal")	\
267 	IFDEF_ZONE_HIGHMEM(	EM (ZONE_HIGHMEM,"HighMem"))	\
268 				EMe(ZONE_MOVABLE,"Movable")
269 
270 #define LRU_NAMES		\
271 		EM (LRU_INACTIVE_ANON, "inactive_anon") \
272 		EM (LRU_ACTIVE_ANON, "active_anon") \
273 		EM (LRU_INACTIVE_FILE, "inactive_file") \
274 		EM (LRU_ACTIVE_FILE, "active_file") \
275 		EMe(LRU_UNEVICTABLE, "unevictable")
276 
277 /*
278  * First define the enums in the above macros to be exported to userspace
279  * via TRACE_DEFINE_ENUM().
280  */
281 #undef EM
282 #undef EMe
283 #define EM(a, b)	TRACE_DEFINE_ENUM(a);
284 #define EMe(a, b)	TRACE_DEFINE_ENUM(a);
285 
286 COMPACTION_STATUS
287 COMPACTION_PRIORITY
288 /* COMPACTION_FEEDBACK are defines not enums. Not needed here. */
289 ZONE_TYPE
290 LRU_NAMES
291 
292 /*
293  * Now redefine the EM() and EMe() macros to map the enums to the strings
294  * that will be printed in the output.
295  */
296 #undef EM
297 #undef EMe
298 #define EM(a, b)	{a, b},
299 #define EMe(a, b)	{a, b}
300