xref: /openbmc/linux/include/trace/events/mmflags.h (revision 6726d552)
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_ATOMIC),		\
35 	gfpflag_string(__GFP_IO),		\
36 	gfpflag_string(__GFP_FS),		\
37 	gfpflag_string(__GFP_NOWARN),		\
38 	gfpflag_string(__GFP_RETRY_MAYFAIL),	\
39 	gfpflag_string(__GFP_NOFAIL),		\
40 	gfpflag_string(__GFP_NORETRY),		\
41 	gfpflag_string(__GFP_COMP),		\
42 	gfpflag_string(__GFP_ZERO),		\
43 	gfpflag_string(__GFP_NOMEMALLOC),	\
44 	gfpflag_string(__GFP_MEMALLOC),		\
45 	gfpflag_string(__GFP_HARDWALL),		\
46 	gfpflag_string(__GFP_THISNODE),		\
47 	gfpflag_string(__GFP_RECLAIMABLE),	\
48 	gfpflag_string(__GFP_MOVABLE),		\
49 	gfpflag_string(__GFP_ACCOUNT),		\
50 	gfpflag_string(__GFP_WRITE),		\
51 	gfpflag_string(__GFP_RECLAIM),		\
52 	gfpflag_string(__GFP_DIRECT_RECLAIM),	\
53 	gfpflag_string(__GFP_KSWAPD_RECLAIM),	\
54 	gfpflag_string(__GFP_ZEROTAGS)
55 
56 #ifdef CONFIG_KASAN_HW_TAGS
57 #define __def_gfpflag_names_kasan ,			\
58 	gfpflag_string(__GFP_SKIP_ZERO),		\
59 	gfpflag_string(__GFP_SKIP_KASAN_POISON),	\
60 	gfpflag_string(__GFP_SKIP_KASAN_UNPOISON)
61 #else
62 #define __def_gfpflag_names_kasan
63 #endif
64 
65 #define show_gfp_flags(flags)						\
66 	(flags) ? __print_flags(flags, "|",				\
67 	__def_gfpflag_names __def_gfpflag_names_kasan			\
68 	) : "none"
69 
70 #ifdef CONFIG_MMU
71 #define IF_HAVE_PG_MLOCK(flag,string) ,{1UL << flag, string}
72 #else
73 #define IF_HAVE_PG_MLOCK(flag,string)
74 #endif
75 
76 #ifdef CONFIG_ARCH_USES_PG_UNCACHED
77 #define IF_HAVE_PG_UNCACHED(flag,string) ,{1UL << flag, string}
78 #else
79 #define IF_HAVE_PG_UNCACHED(flag,string)
80 #endif
81 
82 #ifdef CONFIG_MEMORY_FAILURE
83 #define IF_HAVE_PG_HWPOISON(flag,string) ,{1UL << flag, string}
84 #else
85 #define IF_HAVE_PG_HWPOISON(flag,string)
86 #endif
87 
88 #if defined(CONFIG_PAGE_IDLE_FLAG) && defined(CONFIG_64BIT)
89 #define IF_HAVE_PG_IDLE(flag,string) ,{1UL << flag, string}
90 #else
91 #define IF_HAVE_PG_IDLE(flag,string)
92 #endif
93 
94 #ifdef CONFIG_64BIT
95 #define IF_HAVE_PG_ARCH_2(flag,string) ,{1UL << flag, string}
96 #else
97 #define IF_HAVE_PG_ARCH_2(flag,string)
98 #endif
99 
100 #ifdef CONFIG_KASAN_HW_TAGS
101 #define IF_HAVE_PG_SKIP_KASAN_POISON(flag,string) ,{1UL << flag, string}
102 #else
103 #define IF_HAVE_PG_SKIP_KASAN_POISON(flag,string)
104 #endif
105 
106 #define __def_pageflag_names						\
107 	{1UL << PG_locked,		"locked"	},		\
108 	{1UL << PG_waiters,		"waiters"	},		\
109 	{1UL << PG_error,		"error"		},		\
110 	{1UL << PG_referenced,		"referenced"	},		\
111 	{1UL << PG_uptodate,		"uptodate"	},		\
112 	{1UL << PG_dirty,		"dirty"		},		\
113 	{1UL << PG_lru,			"lru"		},		\
114 	{1UL << PG_active,		"active"	},		\
115 	{1UL << PG_workingset,		"workingset"	},		\
116 	{1UL << PG_slab,		"slab"		},		\
117 	{1UL << PG_owner_priv_1,	"owner_priv_1"	},		\
118 	{1UL << PG_arch_1,		"arch_1"	},		\
119 	{1UL << PG_reserved,		"reserved"	},		\
120 	{1UL << PG_private,		"private"	},		\
121 	{1UL << PG_private_2,		"private_2"	},		\
122 	{1UL << PG_writeback,		"writeback"	},		\
123 	{1UL << PG_head,		"head"		},		\
124 	{1UL << PG_mappedtodisk,	"mappedtodisk"	},		\
125 	{1UL << PG_reclaim,		"reclaim"	},		\
126 	{1UL << PG_swapbacked,		"swapbacked"	},		\
127 	{1UL << PG_unevictable,		"unevictable"	}		\
128 IF_HAVE_PG_MLOCK(PG_mlocked,		"mlocked"	)		\
129 IF_HAVE_PG_UNCACHED(PG_uncached,	"uncached"	)		\
130 IF_HAVE_PG_HWPOISON(PG_hwpoison,	"hwpoison"	)		\
131 IF_HAVE_PG_IDLE(PG_young,		"young"		)		\
132 IF_HAVE_PG_IDLE(PG_idle,		"idle"		)		\
133 IF_HAVE_PG_ARCH_2(PG_arch_2,		"arch_2"	)		\
134 IF_HAVE_PG_SKIP_KASAN_POISON(PG_skip_kasan_poison, "skip_kasan_poison")
135 
136 #define show_page_flags(flags)						\
137 	(flags) ? __print_flags(flags, "|",				\
138 	__def_pageflag_names						\
139 	) : "none"
140 
141 #if defined(CONFIG_X86)
142 #define __VM_ARCH_SPECIFIC_1 {VM_PAT,     "pat"           }
143 #elif defined(CONFIG_PPC)
144 #define __VM_ARCH_SPECIFIC_1 {VM_SAO,     "sao"           }
145 #elif defined(CONFIG_PARISC) || defined(CONFIG_IA64)
146 #define __VM_ARCH_SPECIFIC_1 {VM_GROWSUP,	"growsup"	}
147 #elif !defined(CONFIG_MMU)
148 #define __VM_ARCH_SPECIFIC_1 {VM_MAPPED_COPY,"mappedcopy"	}
149 #else
150 #define __VM_ARCH_SPECIFIC_1 {VM_ARCH_1,	"arch_1"	}
151 #endif
152 
153 #ifdef CONFIG_MEM_SOFT_DIRTY
154 #define IF_HAVE_VM_SOFTDIRTY(flag,name) {flag, name },
155 #else
156 #define IF_HAVE_VM_SOFTDIRTY(flag,name)
157 #endif
158 
159 #ifdef CONFIG_HAVE_ARCH_USERFAULTFD_MINOR
160 # define IF_HAVE_UFFD_MINOR(flag, name) {flag, name},
161 #else
162 # define IF_HAVE_UFFD_MINOR(flag, name)
163 #endif
164 
165 #define __def_vmaflag_names						\
166 	{VM_READ,			"read"		},		\
167 	{VM_WRITE,			"write"		},		\
168 	{VM_EXEC,			"exec"		},		\
169 	{VM_SHARED,			"shared"	},		\
170 	{VM_MAYREAD,			"mayread"	},		\
171 	{VM_MAYWRITE,			"maywrite"	},		\
172 	{VM_MAYEXEC,			"mayexec"	},		\
173 	{VM_MAYSHARE,			"mayshare"	},		\
174 	{VM_GROWSDOWN,			"growsdown"	},		\
175 	{VM_UFFD_MISSING,		"uffd_missing"	},		\
176 IF_HAVE_UFFD_MINOR(VM_UFFD_MINOR,	"uffd_minor"	)		\
177 	{VM_PFNMAP,			"pfnmap"	},		\
178 	{VM_UFFD_WP,			"uffd_wp"	},		\
179 	{VM_LOCKED,			"locked"	},		\
180 	{VM_IO,				"io"		},		\
181 	{VM_SEQ_READ,			"seqread"	},		\
182 	{VM_RAND_READ,			"randread"	},		\
183 	{VM_DONTCOPY,			"dontcopy"	},		\
184 	{VM_DONTEXPAND,			"dontexpand"	},		\
185 	{VM_LOCKONFAULT,		"lockonfault"	},		\
186 	{VM_ACCOUNT,			"account"	},		\
187 	{VM_NORESERVE,			"noreserve"	},		\
188 	{VM_HUGETLB,			"hugetlb"	},		\
189 	{VM_SYNC,			"sync"		},		\
190 	__VM_ARCH_SPECIFIC_1				,		\
191 	{VM_WIPEONFORK,			"wipeonfork"	},		\
192 	{VM_DONTDUMP,			"dontdump"	},		\
193 IF_HAVE_VM_SOFTDIRTY(VM_SOFTDIRTY,	"softdirty"	)		\
194 	{VM_MIXEDMAP,			"mixedmap"	},		\
195 	{VM_HUGEPAGE,			"hugepage"	},		\
196 	{VM_NOHUGEPAGE,			"nohugepage"	},		\
197 	{VM_MERGEABLE,			"mergeable"	}		\
198 
199 #define show_vma_flags(flags)						\
200 	(flags) ? __print_flags(flags, "|",				\
201 	__def_vmaflag_names						\
202 	) : "none"
203 
204 #ifdef CONFIG_COMPACTION
205 #define COMPACTION_STATUS					\
206 	EM( COMPACT_SKIPPED,		"skipped")		\
207 	EM( COMPACT_DEFERRED,		"deferred")		\
208 	EM( COMPACT_CONTINUE,		"continue")		\
209 	EM( COMPACT_SUCCESS,		"success")		\
210 	EM( COMPACT_PARTIAL_SKIPPED,	"partial_skipped")	\
211 	EM( COMPACT_COMPLETE,		"complete")		\
212 	EM( COMPACT_NO_SUITABLE_PAGE,	"no_suitable_page")	\
213 	EM( COMPACT_NOT_SUITABLE_ZONE,	"not_suitable_zone")	\
214 	EMe(COMPACT_CONTENDED,		"contended")
215 
216 /* High-level compaction status feedback */
217 #define COMPACTION_FAILED	1
218 #define COMPACTION_WITHDRAWN	2
219 #define COMPACTION_PROGRESS	3
220 
221 #define compact_result_to_feedback(result)	\
222 ({						\
223 	enum compact_result __result = result;	\
224 	(compaction_failed(__result)) ? COMPACTION_FAILED : \
225 		(compaction_withdrawn(__result)) ? COMPACTION_WITHDRAWN : COMPACTION_PROGRESS; \
226 })
227 
228 #define COMPACTION_FEEDBACK		\
229 	EM(COMPACTION_FAILED,		"failed")	\
230 	EM(COMPACTION_WITHDRAWN,	"withdrawn")	\
231 	EMe(COMPACTION_PROGRESS,	"progress")
232 
233 #define COMPACTION_PRIORITY						\
234 	EM(COMPACT_PRIO_SYNC_FULL,	"COMPACT_PRIO_SYNC_FULL")	\
235 	EM(COMPACT_PRIO_SYNC_LIGHT,	"COMPACT_PRIO_SYNC_LIGHT")	\
236 	EMe(COMPACT_PRIO_ASYNC,		"COMPACT_PRIO_ASYNC")
237 #else
238 #define COMPACTION_STATUS
239 #define COMPACTION_PRIORITY
240 #define COMPACTION_FEEDBACK
241 #endif
242 
243 #ifdef CONFIG_ZONE_DMA
244 #define IFDEF_ZONE_DMA(X) X
245 #else
246 #define IFDEF_ZONE_DMA(X)
247 #endif
248 
249 #ifdef CONFIG_ZONE_DMA32
250 #define IFDEF_ZONE_DMA32(X) X
251 #else
252 #define IFDEF_ZONE_DMA32(X)
253 #endif
254 
255 #ifdef CONFIG_HIGHMEM
256 #define IFDEF_ZONE_HIGHMEM(X) X
257 #else
258 #define IFDEF_ZONE_HIGHMEM(X)
259 #endif
260 
261 #define ZONE_TYPE						\
262 	IFDEF_ZONE_DMA(		EM (ZONE_DMA,	 "DMA"))	\
263 	IFDEF_ZONE_DMA32(	EM (ZONE_DMA32,	 "DMA32"))	\
264 				EM (ZONE_NORMAL, "Normal")	\
265 	IFDEF_ZONE_HIGHMEM(	EM (ZONE_HIGHMEM,"HighMem"))	\
266 				EMe(ZONE_MOVABLE,"Movable")
267 
268 #define LRU_NAMES		\
269 		EM (LRU_INACTIVE_ANON, "inactive_anon") \
270 		EM (LRU_ACTIVE_ANON, "active_anon") \
271 		EM (LRU_INACTIVE_FILE, "inactive_file") \
272 		EM (LRU_ACTIVE_FILE, "active_file") \
273 		EMe(LRU_UNEVICTABLE, "unevictable")
274 
275 /*
276  * First define the enums in the above macros to be exported to userspace
277  * via TRACE_DEFINE_ENUM().
278  */
279 #undef EM
280 #undef EMe
281 #define EM(a, b)	TRACE_DEFINE_ENUM(a);
282 #define EMe(a, b)	TRACE_DEFINE_ENUM(a);
283 
284 COMPACTION_STATUS
285 COMPACTION_PRIORITY
286 /* COMPACTION_FEEDBACK are defines not enums. Not needed here. */
287 ZONE_TYPE
288 LRU_NAMES
289 
290 /*
291  * Now redefine the EM() and EMe() macros to map the enums to the strings
292  * that will be printed in the output.
293  */
294 #undef EM
295 #undef EMe
296 #define EM(a, b)	{a, b},
297 #define EMe(a, b)	{a, b}
298