1 /* SPDX-License-Identifier: GPL-2.0 */
2 #include <linux/node.h>
3 #include <linux/mmzone.h>
4 #include <linux/compaction.h>
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.
9 * For example, if we have GFP_KERNEL before GFP_USER we wil get:
11 * GFP_KERNEL|GFP_HARDWALL
13 * Thus most bits set go first.
16 #define __def_gfpflag_names \
17 {(unsigned long)GFP_TRANSHUGE, "GFP_TRANSHUGE"}, \
18 {(unsigned long)GFP_TRANSHUGE_LIGHT, "GFP_TRANSHUGE_LIGHT"}, \
19 {(unsigned long)GFP_HIGHUSER_MOVABLE, "GFP_HIGHUSER_MOVABLE"},\
20 {(unsigned long)GFP_HIGHUSER, "GFP_HIGHUSER"}, \
21 {(unsigned long)GFP_USER, "GFP_USER"}, \
22 {(unsigned long)GFP_KERNEL_ACCOUNT, "GFP_KERNEL_ACCOUNT"}, \
23 {(unsigned long)GFP_KERNEL, "GFP_KERNEL"}, \
24 {(unsigned long)GFP_NOFS, "GFP_NOFS"}, \
25 {(unsigned long)GFP_ATOMIC, "GFP_ATOMIC"}, \
26 {(unsigned long)GFP_NOIO, "GFP_NOIO"}, \
27 {(unsigned long)GFP_NOWAIT, "GFP_NOWAIT"}, \
28 {(unsigned long)GFP_DMA, "GFP_DMA"}, \
29 {(unsigned long)__GFP_HIGHMEM, "__GFP_HIGHMEM"}, \
30 {(unsigned long)GFP_DMA32, "GFP_DMA32"}, \
31 {(unsigned long)__GFP_HIGH, "__GFP_HIGH"}, \
32 {(unsigned long)__GFP_ATOMIC, "__GFP_ATOMIC"}, \
33 {(unsigned long)__GFP_IO, "__GFP_IO"}, \
34 {(unsigned long)__GFP_FS, "__GFP_FS"}, \
35 {(unsigned long)__GFP_NOWARN, "__GFP_NOWARN"}, \
36 {(unsigned long)__GFP_RETRY_MAYFAIL, "__GFP_RETRY_MAYFAIL"}, \
37 {(unsigned long)__GFP_NOFAIL, "__GFP_NOFAIL"}, \
38 {(unsigned long)__GFP_NORETRY, "__GFP_NORETRY"}, \
39 {(unsigned long)__GFP_COMP, "__GFP_COMP"}, \
40 {(unsigned long)__GFP_ZERO, "__GFP_ZERO"}, \
41 {(unsigned long)__GFP_NOMEMALLOC, "__GFP_NOMEMALLOC"}, \
42 {(unsigned long)__GFP_MEMALLOC, "__GFP_MEMALLOC"}, \
43 {(unsigned long)__GFP_HARDWALL, "__GFP_HARDWALL"}, \
44 {(unsigned long)__GFP_THISNODE, "__GFP_THISNODE"}, \
45 {(unsigned long)__GFP_RECLAIMABLE, "__GFP_RECLAIMABLE"}, \
46 {(unsigned long)__GFP_MOVABLE, "__GFP_MOVABLE"}, \
47 {(unsigned long)__GFP_ACCOUNT, "__GFP_ACCOUNT"}, \
48 {(unsigned long)__GFP_WRITE, "__GFP_WRITE"}, \
49 {(unsigned long)__GFP_RECLAIM, "__GFP_RECLAIM"}, \
50 {(unsigned long)__GFP_DIRECT_RECLAIM, "__GFP_DIRECT_RECLAIM"},\
51 {(unsigned long)__GFP_KSWAPD_RECLAIM, "__GFP_KSWAPD_RECLAIM"}\
53 #define show_gfp_flags(flags) \
54 (flags) ? __print_flags(flags, "|", \
59 #define IF_HAVE_PG_MLOCK(flag,string) ,{1UL << flag, string}
61 #define IF_HAVE_PG_MLOCK(flag,string)
64 #ifdef CONFIG_ARCH_USES_PG_UNCACHED
65 #define IF_HAVE_PG_UNCACHED(flag,string) ,{1UL << flag, string}
67 #define IF_HAVE_PG_UNCACHED(flag,string)
70 #ifdef CONFIG_MEMORY_FAILURE
71 #define IF_HAVE_PG_HWPOISON(flag,string) ,{1UL << flag, string}
73 #define IF_HAVE_PG_HWPOISON(flag,string)
76 #if defined(CONFIG_IDLE_PAGE_TRACKING) && defined(CONFIG_64BIT)
77 #define IF_HAVE_PG_IDLE(flag,string) ,{1UL << flag, string}
79 #define IF_HAVE_PG_IDLE(flag,string)
82 #define __def_pageflag_names \
83 {1UL << PG_locked, "locked" }, \
84 {1UL << PG_waiters, "waiters" }, \
85 {1UL << PG_error, "error" }, \
86 {1UL << PG_referenced, "referenced" }, \
87 {1UL << PG_uptodate, "uptodate" }, \
88 {1UL << PG_dirty, "dirty" }, \
89 {1UL << PG_lru, "lru" }, \
90 {1UL << PG_active, "active" }, \
91 {1UL << PG_workingset, "workingset" }, \
92 {1UL << PG_slab, "slab" }, \
93 {1UL << PG_owner_priv_1, "owner_priv_1" }, \
94 {1UL << PG_arch_1, "arch_1" }, \
95 {1UL << PG_reserved, "reserved" }, \
96 {1UL << PG_private, "private" }, \
97 {1UL << PG_private_2, "private_2" }, \
98 {1UL << PG_writeback, "writeback" }, \
99 {1UL << PG_head, "head" }, \
100 {1UL << PG_mappedtodisk, "mappedtodisk" }, \
101 {1UL << PG_reclaim, "reclaim" }, \
102 {1UL << PG_swapbacked, "swapbacked" }, \
103 {1UL << PG_unevictable, "unevictable" } \
104 IF_HAVE_PG_MLOCK(PG_mlocked, "mlocked" ) \
105 IF_HAVE_PG_UNCACHED(PG_uncached, "uncached" ) \
106 IF_HAVE_PG_HWPOISON(PG_hwpoison, "hwpoison" ) \
107 IF_HAVE_PG_IDLE(PG_young, "young" ) \
108 IF_HAVE_PG_IDLE(PG_idle, "idle" )
110 #define show_page_flags(flags) \
111 (flags) ? __print_flags(flags, "|", \
112 __def_pageflag_names \
115 #if defined(CONFIG_X86)
116 #define __VM_ARCH_SPECIFIC_1 {VM_PAT, "pat" }
117 #elif defined(CONFIG_PPC)
118 #define __VM_ARCH_SPECIFIC_1 {VM_SAO, "sao" }
119 #elif defined(CONFIG_PARISC) || defined(CONFIG_IA64)
120 #define __VM_ARCH_SPECIFIC_1 {VM_GROWSUP, "growsup" }
121 #elif !defined(CONFIG_MMU)
122 #define __VM_ARCH_SPECIFIC_1 {VM_MAPPED_COPY,"mappedcopy" }
124 #define __VM_ARCH_SPECIFIC_1 {VM_ARCH_1, "arch_1" }
127 #ifdef CONFIG_MEM_SOFT_DIRTY
128 #define IF_HAVE_VM_SOFTDIRTY(flag,name) {flag, name },
130 #define IF_HAVE_VM_SOFTDIRTY(flag,name)
133 #define __def_vmaflag_names \
134 {VM_READ, "read" }, \
135 {VM_WRITE, "write" }, \
136 {VM_EXEC, "exec" }, \
137 {VM_SHARED, "shared" }, \
138 {VM_MAYREAD, "mayread" }, \
139 {VM_MAYWRITE, "maywrite" }, \
140 {VM_MAYEXEC, "mayexec" }, \
141 {VM_MAYSHARE, "mayshare" }, \
142 {VM_GROWSDOWN, "growsdown" }, \
143 {VM_UFFD_MISSING, "uffd_missing" }, \
144 {VM_PFNMAP, "pfnmap" }, \
145 {VM_DENYWRITE, "denywrite" }, \
146 {VM_UFFD_WP, "uffd_wp" }, \
147 {VM_LOCKED, "locked" }, \
149 {VM_SEQ_READ, "seqread" }, \
150 {VM_RAND_READ, "randread" }, \
151 {VM_DONTCOPY, "dontcopy" }, \
152 {VM_DONTEXPAND, "dontexpand" }, \
153 {VM_LOCKONFAULT, "lockonfault" }, \
154 {VM_ACCOUNT, "account" }, \
155 {VM_NORESERVE, "noreserve" }, \
156 {VM_HUGETLB, "hugetlb" }, \
157 __VM_ARCH_SPECIFIC_1 , \
158 {VM_WIPEONFORK, "wipeonfork" }, \
159 {VM_DONTDUMP, "dontdump" }, \
160 IF_HAVE_VM_SOFTDIRTY(VM_SOFTDIRTY, "softdirty" ) \
161 {VM_MIXEDMAP, "mixedmap" }, \
162 {VM_HUGEPAGE, "hugepage" }, \
163 {VM_NOHUGEPAGE, "nohugepage" }, \
164 {VM_MERGEABLE, "mergeable" } \
166 #define show_vma_flags(flags) \
167 (flags) ? __print_flags(flags, "|", \
168 __def_vmaflag_names \
171 #ifdef CONFIG_COMPACTION
172 #define COMPACTION_STATUS \
173 EM( COMPACT_SKIPPED, "skipped") \
174 EM( COMPACT_DEFERRED, "deferred") \
175 EM( COMPACT_CONTINUE, "continue") \
176 EM( COMPACT_SUCCESS, "success") \
177 EM( COMPACT_PARTIAL_SKIPPED, "partial_skipped") \
178 EM( COMPACT_COMPLETE, "complete") \
179 EM( COMPACT_NO_SUITABLE_PAGE, "no_suitable_page") \
180 EM( COMPACT_NOT_SUITABLE_ZONE, "not_suitable_zone") \
181 EMe(COMPACT_CONTENDED, "contended")
183 /* High-level compaction status feedback */
184 #define COMPACTION_FAILED 1
185 #define COMPACTION_WITHDRAWN 2
186 #define COMPACTION_PROGRESS 3
188 #define compact_result_to_feedback(result) \
190 enum compact_result __result = result; \
191 (compaction_failed(__result)) ? COMPACTION_FAILED : \
192 (compaction_withdrawn(__result)) ? COMPACTION_WITHDRAWN : COMPACTION_PROGRESS; \
195 #define COMPACTION_FEEDBACK \
196 EM(COMPACTION_FAILED, "failed") \
197 EM(COMPACTION_WITHDRAWN, "withdrawn") \
198 EMe(COMPACTION_PROGRESS, "progress")
200 #define COMPACTION_PRIORITY \
201 EM(COMPACT_PRIO_SYNC_FULL, "COMPACT_PRIO_SYNC_FULL") \
202 EM(COMPACT_PRIO_SYNC_LIGHT, "COMPACT_PRIO_SYNC_LIGHT") \
203 EMe(COMPACT_PRIO_ASYNC, "COMPACT_PRIO_ASYNC")
205 #define COMPACTION_STATUS
206 #define COMPACTION_PRIORITY
207 #define COMPACTION_FEEDBACK
210 #ifdef CONFIG_ZONE_DMA
211 #define IFDEF_ZONE_DMA(X) X
213 #define IFDEF_ZONE_DMA(X)
216 #ifdef CONFIG_ZONE_DMA32
217 #define IFDEF_ZONE_DMA32(X) X
219 #define IFDEF_ZONE_DMA32(X)
222 #ifdef CONFIG_HIGHMEM
223 #define IFDEF_ZONE_HIGHMEM(X) X
225 #define IFDEF_ZONE_HIGHMEM(X)
229 IFDEF_ZONE_DMA( EM (ZONE_DMA, "DMA")) \
230 IFDEF_ZONE_DMA32( EM (ZONE_DMA32, "DMA32")) \
231 EM (ZONE_NORMAL, "Normal") \
232 IFDEF_ZONE_HIGHMEM( EM (ZONE_HIGHMEM,"HighMem")) \
233 EMe(ZONE_MOVABLE,"Movable")
236 EM (LRU_INACTIVE_ANON, "inactive_anon") \
237 EM (LRU_ACTIVE_ANON, "active_anon") \
238 EM (LRU_INACTIVE_FILE, "inactive_file") \
239 EM (LRU_ACTIVE_FILE, "active_file") \
240 EMe(LRU_UNEVICTABLE, "unevictable")
243 * First define the enums in the above macros to be exported to userspace
244 * via TRACE_DEFINE_ENUM().
248 #define EM(a, b) TRACE_DEFINE_ENUM(a);
249 #define EMe(a, b) TRACE_DEFINE_ENUM(a);
253 /* COMPACTION_FEEDBACK are defines not enums. Not needed here. */
258 * Now redefine the EM() and EMe() macros to map the enums to the strings
259 * that will be printed in the output.
263 #define EM(a, b) {a, b},
264 #define EMe(a, b) {a, b}