xref: /openbmc/linux/include/trace/events/mmflags.h (revision f0931824)
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(hugetlb),					\
139 	DEF_PAGETYPE_NAME(offline),					\
140 	DEF_PAGETYPE_NAME(guard),					\
141 	DEF_PAGETYPE_NAME(table),					\
142 	DEF_PAGETYPE_NAME(buddy)
143 
144 #if defined(CONFIG_X86)
145 #define __VM_ARCH_SPECIFIC_1 {VM_PAT,     "pat"           }
146 #elif defined(CONFIG_PPC)
147 #define __VM_ARCH_SPECIFIC_1 {VM_SAO,     "sao"           }
148 #elif defined(CONFIG_PARISC) || defined(CONFIG_IA64)
149 #define __VM_ARCH_SPECIFIC_1 {VM_GROWSUP,	"growsup"	}
150 #elif !defined(CONFIG_MMU)
151 #define __VM_ARCH_SPECIFIC_1 {VM_MAPPED_COPY,"mappedcopy"	}
152 #else
153 #define __VM_ARCH_SPECIFIC_1 {VM_ARCH_1,	"arch_1"	}
154 #endif
155 
156 #ifdef CONFIG_MEM_SOFT_DIRTY
157 #define IF_HAVE_VM_SOFTDIRTY(flag,name) {flag, name },
158 #else
159 #define IF_HAVE_VM_SOFTDIRTY(flag,name)
160 #endif
161 
162 #ifdef CONFIG_HAVE_ARCH_USERFAULTFD_MINOR
163 # define IF_HAVE_UFFD_MINOR(flag, name) {flag, name},
164 #else
165 # define IF_HAVE_UFFD_MINOR(flag, name)
166 #endif
167 
168 #define __def_vmaflag_names						\
169 	{VM_READ,			"read"		},		\
170 	{VM_WRITE,			"write"		},		\
171 	{VM_EXEC,			"exec"		},		\
172 	{VM_SHARED,			"shared"	},		\
173 	{VM_MAYREAD,			"mayread"	},		\
174 	{VM_MAYWRITE,			"maywrite"	},		\
175 	{VM_MAYEXEC,			"mayexec"	},		\
176 	{VM_MAYSHARE,			"mayshare"	},		\
177 	{VM_GROWSDOWN,			"growsdown"	},		\
178 	{VM_UFFD_MISSING,		"uffd_missing"	},		\
179 IF_HAVE_UFFD_MINOR(VM_UFFD_MINOR,	"uffd_minor"	)		\
180 	{VM_PFNMAP,			"pfnmap"	},		\
181 	{VM_UFFD_WP,			"uffd_wp"	},		\
182 	{VM_LOCKED,			"locked"	},		\
183 	{VM_IO,				"io"		},		\
184 	{VM_SEQ_READ,			"seqread"	},		\
185 	{VM_RAND_READ,			"randread"	},		\
186 	{VM_DONTCOPY,			"dontcopy"	},		\
187 	{VM_DONTEXPAND,			"dontexpand"	},		\
188 	{VM_LOCKONFAULT,		"lockonfault"	},		\
189 	{VM_ACCOUNT,			"account"	},		\
190 	{VM_NORESERVE,			"noreserve"	},		\
191 	{VM_HUGETLB,			"hugetlb"	},		\
192 	{VM_SYNC,			"sync"		},		\
193 	__VM_ARCH_SPECIFIC_1				,		\
194 	{VM_WIPEONFORK,			"wipeonfork"	},		\
195 	{VM_DONTDUMP,			"dontdump"	},		\
196 IF_HAVE_VM_SOFTDIRTY(VM_SOFTDIRTY,	"softdirty"	)		\
197 	{VM_MIXEDMAP,			"mixedmap"	},		\
198 	{VM_HUGEPAGE,			"hugepage"	},		\
199 	{VM_NOHUGEPAGE,			"nohugepage"	},		\
200 	{VM_MERGEABLE,			"mergeable"	}		\
201 
202 #define show_vma_flags(flags)						\
203 	(flags) ? __print_flags(flags, "|",				\
204 	__def_vmaflag_names						\
205 	) : "none"
206 
207 #ifdef CONFIG_COMPACTION
208 #define COMPACTION_STATUS					\
209 	EM( COMPACT_SKIPPED,		"skipped")		\
210 	EM( COMPACT_DEFERRED,		"deferred")		\
211 	EM( COMPACT_CONTINUE,		"continue")		\
212 	EM( COMPACT_SUCCESS,		"success")		\
213 	EM( COMPACT_PARTIAL_SKIPPED,	"partial_skipped")	\
214 	EM( COMPACT_COMPLETE,		"complete")		\
215 	EM( COMPACT_NO_SUITABLE_PAGE,	"no_suitable_page")	\
216 	EM( COMPACT_NOT_SUITABLE_ZONE,	"not_suitable_zone")	\
217 	EMe(COMPACT_CONTENDED,		"contended")
218 
219 /* High-level compaction status feedback */
220 #define COMPACTION_FAILED	1
221 #define COMPACTION_WITHDRAWN	2
222 #define COMPACTION_PROGRESS	3
223 
224 #define compact_result_to_feedback(result)	\
225 ({						\
226 	enum compact_result __result = result;	\
227 	(__result == COMPACT_COMPLETE) ? COMPACTION_FAILED : \
228 		(__result == COMPACT_SUCCESS) ? COMPACTION_PROGRESS : COMPACTION_WITHDRAWN; \
229 })
230 
231 #define COMPACTION_FEEDBACK		\
232 	EM(COMPACTION_FAILED,		"failed")	\
233 	EM(COMPACTION_WITHDRAWN,	"withdrawn")	\
234 	EMe(COMPACTION_PROGRESS,	"progress")
235 
236 #define COMPACTION_PRIORITY						\
237 	EM(COMPACT_PRIO_SYNC_FULL,	"COMPACT_PRIO_SYNC_FULL")	\
238 	EM(COMPACT_PRIO_SYNC_LIGHT,	"COMPACT_PRIO_SYNC_LIGHT")	\
239 	EMe(COMPACT_PRIO_ASYNC,		"COMPACT_PRIO_ASYNC")
240 #else
241 #define COMPACTION_STATUS
242 #define COMPACTION_PRIORITY
243 #define COMPACTION_FEEDBACK
244 #endif
245 
246 #ifdef CONFIG_ZONE_DMA
247 #define IFDEF_ZONE_DMA(X) X
248 #else
249 #define IFDEF_ZONE_DMA(X)
250 #endif
251 
252 #ifdef CONFIG_ZONE_DMA32
253 #define IFDEF_ZONE_DMA32(X) X
254 #else
255 #define IFDEF_ZONE_DMA32(X)
256 #endif
257 
258 #ifdef CONFIG_HIGHMEM
259 #define IFDEF_ZONE_HIGHMEM(X) X
260 #else
261 #define IFDEF_ZONE_HIGHMEM(X)
262 #endif
263 
264 #define ZONE_TYPE						\
265 	IFDEF_ZONE_DMA(		EM (ZONE_DMA,	 "DMA"))	\
266 	IFDEF_ZONE_DMA32(	EM (ZONE_DMA32,	 "DMA32"))	\
267 				EM (ZONE_NORMAL, "Normal")	\
268 	IFDEF_ZONE_HIGHMEM(	EM (ZONE_HIGHMEM,"HighMem"))	\
269 				EMe(ZONE_MOVABLE,"Movable")
270 
271 #define LRU_NAMES		\
272 		EM (LRU_INACTIVE_ANON, "inactive_anon") \
273 		EM (LRU_ACTIVE_ANON, "active_anon") \
274 		EM (LRU_INACTIVE_FILE, "inactive_file") \
275 		EM (LRU_ACTIVE_FILE, "active_file") \
276 		EMe(LRU_UNEVICTABLE, "unevictable")
277 
278 /*
279  * First define the enums in the above macros to be exported to userspace
280  * via TRACE_DEFINE_ENUM().
281  */
282 #undef EM
283 #undef EMe
284 #define EM(a, b)	TRACE_DEFINE_ENUM(a);
285 #define EMe(a, b)	TRACE_DEFINE_ENUM(a);
286 
287 COMPACTION_STATUS
288 COMPACTION_PRIORITY
289 /* COMPACTION_FEEDBACK are defines not enums. Not needed here. */
290 ZONE_TYPE
291 LRU_NAMES
292 
293 /*
294  * Now redefine the EM() and EMe() macros to map the enums to the strings
295  * that will be printed in the output.
296  */
297 #undef EM
298 #undef EMe
299 #define EM(a, b)	{a, b},
300 #define EMe(a, b)	{a, b}
301