xref: /linux/include/trace/events/mmflags.h (revision 42d37fc0c819b81f6f6afd108b55d04ba9d32d0f)
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(owner_priv_1),				\
111 	DEF_PAGEFLAG_NAME(arch_1),					\
112 	DEF_PAGEFLAG_NAME(reserved),					\
113 	DEF_PAGEFLAG_NAME(private),					\
114 	DEF_PAGEFLAG_NAME(private_2),					\
115 	DEF_PAGEFLAG_NAME(writeback),					\
116 	DEF_PAGEFLAG_NAME(head),					\
117 	DEF_PAGEFLAG_NAME(mappedtodisk),				\
118 	DEF_PAGEFLAG_NAME(reclaim),					\
119 	DEF_PAGEFLAG_NAME(swapbacked),					\
120 	DEF_PAGEFLAG_NAME(unevictable)					\
121 IF_HAVE_PG_MLOCK(mlocked)						\
122 IF_HAVE_PG_UNCACHED(uncached)						\
123 IF_HAVE_PG_HWPOISON(hwpoison)						\
124 IF_HAVE_PG_IDLE(idle)							\
125 IF_HAVE_PG_IDLE(young)							\
126 IF_HAVE_PG_ARCH_X(arch_2)						\
127 IF_HAVE_PG_ARCH_X(arch_3)
128 
129 #define show_page_flags(flags)						\
130 	(flags) ? __print_flags(flags, "|",				\
131 	__def_pageflag_names						\
132 	) : "none"
133 
134 #define DEF_PAGETYPE_NAME(_name) { PG_##_name, __stringify(_name) }
135 
136 #define __def_pagetype_names						\
137 	DEF_PAGETYPE_NAME(slab),					\
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)
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 #ifdef CONFIG_64BIT
169 # define IF_HAVE_VM_DROPPABLE(flag, name) {flag, name},
170 #else
171 # define IF_HAVE_VM_DROPPABLE(flag, name)
172 #endif
173 
174 #define __def_vmaflag_names						\
175 	{VM_READ,			"read"		},		\
176 	{VM_WRITE,			"write"		},		\
177 	{VM_EXEC,			"exec"		},		\
178 	{VM_SHARED,			"shared"	},		\
179 	{VM_MAYREAD,			"mayread"	},		\
180 	{VM_MAYWRITE,			"maywrite"	},		\
181 	{VM_MAYEXEC,			"mayexec"	},		\
182 	{VM_MAYSHARE,			"mayshare"	},		\
183 	{VM_GROWSDOWN,			"growsdown"	},		\
184 	{VM_UFFD_MISSING,		"uffd_missing"	},		\
185 IF_HAVE_UFFD_MINOR(VM_UFFD_MINOR,	"uffd_minor"	)		\
186 	{VM_PFNMAP,			"pfnmap"	},		\
187 	{VM_UFFD_WP,			"uffd_wp"	},		\
188 	{VM_LOCKED,			"locked"	},		\
189 	{VM_IO,				"io"		},		\
190 	{VM_SEQ_READ,			"seqread"	},		\
191 	{VM_RAND_READ,			"randread"	},		\
192 	{VM_DONTCOPY,			"dontcopy"	},		\
193 	{VM_DONTEXPAND,			"dontexpand"	},		\
194 	{VM_LOCKONFAULT,		"lockonfault"	},		\
195 	{VM_ACCOUNT,			"account"	},		\
196 	{VM_NORESERVE,			"noreserve"	},		\
197 	{VM_HUGETLB,			"hugetlb"	},		\
198 	{VM_SYNC,			"sync"		},		\
199 	__VM_ARCH_SPECIFIC_1				,		\
200 	{VM_WIPEONFORK,			"wipeonfork"	},		\
201 	{VM_DONTDUMP,			"dontdump"	},		\
202 IF_HAVE_VM_SOFTDIRTY(VM_SOFTDIRTY,	"softdirty"	)		\
203 	{VM_MIXEDMAP,			"mixedmap"	},		\
204 	{VM_HUGEPAGE,			"hugepage"	},		\
205 	{VM_NOHUGEPAGE,			"nohugepage"	},		\
206 IF_HAVE_VM_DROPPABLE(VM_DROPPABLE,	"droppable"	)		\
207 	{VM_MERGEABLE,			"mergeable"	}		\
208 
209 #define show_vma_flags(flags)						\
210 	(flags) ? __print_flags(flags, "|",				\
211 	__def_vmaflag_names						\
212 	) : "none"
213 
214 #ifdef CONFIG_COMPACTION
215 #define COMPACTION_STATUS					\
216 	EM( COMPACT_SKIPPED,		"skipped")		\
217 	EM( COMPACT_DEFERRED,		"deferred")		\
218 	EM( COMPACT_CONTINUE,		"continue")		\
219 	EM( COMPACT_SUCCESS,		"success")		\
220 	EM( COMPACT_PARTIAL_SKIPPED,	"partial_skipped")	\
221 	EM( COMPACT_COMPLETE,		"complete")		\
222 	EM( COMPACT_NO_SUITABLE_PAGE,	"no_suitable_page")	\
223 	EM( COMPACT_NOT_SUITABLE_ZONE,	"not_suitable_zone")	\
224 	EMe(COMPACT_CONTENDED,		"contended")
225 
226 /* High-level compaction status feedback */
227 #define COMPACTION_FAILED	1
228 #define COMPACTION_WITHDRAWN	2
229 #define COMPACTION_PROGRESS	3
230 
231 #define compact_result_to_feedback(result)	\
232 ({						\
233 	enum compact_result __result = result;	\
234 	(__result == COMPACT_COMPLETE) ? COMPACTION_FAILED : \
235 		(__result == COMPACT_SUCCESS) ? COMPACTION_PROGRESS : COMPACTION_WITHDRAWN; \
236 })
237 
238 #define COMPACTION_FEEDBACK		\
239 	EM(COMPACTION_FAILED,		"failed")	\
240 	EM(COMPACTION_WITHDRAWN,	"withdrawn")	\
241 	EMe(COMPACTION_PROGRESS,	"progress")
242 
243 #define COMPACTION_PRIORITY						\
244 	EM(COMPACT_PRIO_SYNC_FULL,	"COMPACT_PRIO_SYNC_FULL")	\
245 	EM(COMPACT_PRIO_SYNC_LIGHT,	"COMPACT_PRIO_SYNC_LIGHT")	\
246 	EMe(COMPACT_PRIO_ASYNC,		"COMPACT_PRIO_ASYNC")
247 #else
248 #define COMPACTION_STATUS
249 #define COMPACTION_PRIORITY
250 #define COMPACTION_FEEDBACK
251 #endif
252 
253 #ifdef CONFIG_ZONE_DMA
254 #define IFDEF_ZONE_DMA(X) X
255 #else
256 #define IFDEF_ZONE_DMA(X)
257 #endif
258 
259 #ifdef CONFIG_ZONE_DMA32
260 #define IFDEF_ZONE_DMA32(X) X
261 #else
262 #define IFDEF_ZONE_DMA32(X)
263 #endif
264 
265 #ifdef CONFIG_HIGHMEM
266 #define IFDEF_ZONE_HIGHMEM(X) X
267 #else
268 #define IFDEF_ZONE_HIGHMEM(X)
269 #endif
270 
271 #define ZONE_TYPE						\
272 	IFDEF_ZONE_DMA(		EM (ZONE_DMA,	 "DMA"))	\
273 	IFDEF_ZONE_DMA32(	EM (ZONE_DMA32,	 "DMA32"))	\
274 				EM (ZONE_NORMAL, "Normal")	\
275 	IFDEF_ZONE_HIGHMEM(	EM (ZONE_HIGHMEM,"HighMem"))	\
276 				EMe(ZONE_MOVABLE,"Movable")
277 
278 #define LRU_NAMES		\
279 		EM (LRU_INACTIVE_ANON, "inactive_anon") \
280 		EM (LRU_ACTIVE_ANON, "active_anon") \
281 		EM (LRU_INACTIVE_FILE, "inactive_file") \
282 		EM (LRU_ACTIVE_FILE, "active_file") \
283 		EMe(LRU_UNEVICTABLE, "unevictable")
284 
285 /*
286  * First define the enums in the above macros to be exported to userspace
287  * via TRACE_DEFINE_ENUM().
288  */
289 #undef EM
290 #undef EMe
291 #define EM(a, b)	TRACE_DEFINE_ENUM(a);
292 #define EMe(a, b)	TRACE_DEFINE_ENUM(a);
293 
294 COMPACTION_STATUS
295 COMPACTION_PRIORITY
296 /* COMPACTION_FEEDBACK are defines not enums. Not needed here. */
297 ZONE_TYPE
298 LRU_NAMES
299 
300 /*
301  * Now redefine the EM() and EMe() macros to map the enums to the strings
302  * that will be printed in the output.
303  */
304 #undef EM
305 #undef EMe
306 #define EM(a, b)	{a, b},
307 #define EMe(a, b)	{a, b}
308