mmflags.h 8.3 KB

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