kmem.h 8.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357
  1. #undef TRACE_SYSTEM
  2. #define TRACE_SYSTEM kmem
  3. #if !defined(_TRACE_KMEM_H) || defined(TRACE_HEADER_MULTI_READ)
  4. #define _TRACE_KMEM_H
  5. #include <linux/types.h>
  6. #include <linux/tracepoint.h>
  7. #include <trace/events/gfpflags.h>
  8. DECLARE_EVENT_CLASS(kmem_alloc,
  9. TP_PROTO(unsigned long call_site,
  10. const void *ptr,
  11. size_t bytes_req,
  12. size_t bytes_alloc,
  13. gfp_t gfp_flags),
  14. TP_ARGS(call_site, ptr, bytes_req, bytes_alloc, gfp_flags),
  15. TP_STRUCT__entry(
  16. __field( unsigned long, call_site )
  17. __field( const void *, ptr )
  18. __field( size_t, bytes_req )
  19. __field( size_t, bytes_alloc )
  20. __field( gfp_t, gfp_flags )
  21. ),
  22. TP_fast_assign(
  23. __entry->call_site = call_site;
  24. __entry->ptr = ptr;
  25. __entry->bytes_req = bytes_req;
  26. __entry->bytes_alloc = bytes_alloc;
  27. __entry->gfp_flags = gfp_flags;
  28. ),
  29. TP_printk("call_site=%lx ptr=%p bytes_req=%zu bytes_alloc=%zu gfp_flags=%s",
  30. __entry->call_site,
  31. __entry->ptr,
  32. __entry->bytes_req,
  33. __entry->bytes_alloc,
  34. show_gfp_flags(__entry->gfp_flags))
  35. );
  36. DEFINE_EVENT(kmem_alloc, kmalloc,
  37. TP_PROTO(unsigned long call_site, const void *ptr,
  38. size_t bytes_req, size_t bytes_alloc, gfp_t gfp_flags),
  39. TP_ARGS(call_site, ptr, bytes_req, bytes_alloc, gfp_flags)
  40. );
  41. DEFINE_EVENT(kmem_alloc, kmem_cache_alloc,
  42. TP_PROTO(unsigned long call_site, const void *ptr,
  43. size_t bytes_req, size_t bytes_alloc, gfp_t gfp_flags),
  44. TP_ARGS(call_site, ptr, bytes_req, bytes_alloc, gfp_flags)
  45. );
  46. DECLARE_EVENT_CLASS(kmem_alloc_node,
  47. TP_PROTO(unsigned long call_site,
  48. const void *ptr,
  49. size_t bytes_req,
  50. size_t bytes_alloc,
  51. gfp_t gfp_flags,
  52. int node),
  53. TP_ARGS(call_site, ptr, bytes_req, bytes_alloc, gfp_flags, node),
  54. TP_STRUCT__entry(
  55. __field( unsigned long, call_site )
  56. __field( const void *, ptr )
  57. __field( size_t, bytes_req )
  58. __field( size_t, bytes_alloc )
  59. __field( gfp_t, gfp_flags )
  60. __field( int, node )
  61. ),
  62. TP_fast_assign(
  63. __entry->call_site = call_site;
  64. __entry->ptr = ptr;
  65. __entry->bytes_req = bytes_req;
  66. __entry->bytes_alloc = bytes_alloc;
  67. __entry->gfp_flags = gfp_flags;
  68. __entry->node = node;
  69. ),
  70. TP_printk("call_site=%lx ptr=%p bytes_req=%zu bytes_alloc=%zu gfp_flags=%s node=%d",
  71. __entry->call_site,
  72. __entry->ptr,
  73. __entry->bytes_req,
  74. __entry->bytes_alloc,
  75. show_gfp_flags(__entry->gfp_flags),
  76. __entry->node)
  77. );
  78. DEFINE_EVENT(kmem_alloc_node, kmalloc_node,
  79. TP_PROTO(unsigned long call_site, const void *ptr,
  80. size_t bytes_req, size_t bytes_alloc,
  81. gfp_t gfp_flags, int node),
  82. TP_ARGS(call_site, ptr, bytes_req, bytes_alloc, gfp_flags, node)
  83. );
  84. DEFINE_EVENT(kmem_alloc_node, kmem_cache_alloc_node,
  85. TP_PROTO(unsigned long call_site, const void *ptr,
  86. size_t bytes_req, size_t bytes_alloc,
  87. gfp_t gfp_flags, int node),
  88. TP_ARGS(call_site, ptr, bytes_req, bytes_alloc, gfp_flags, node)
  89. );
  90. DECLARE_EVENT_CLASS(kmem_free,
  91. TP_PROTO(unsigned long call_site, const void *ptr),
  92. TP_ARGS(call_site, ptr),
  93. TP_STRUCT__entry(
  94. __field( unsigned long, call_site )
  95. __field( const void *, ptr )
  96. ),
  97. TP_fast_assign(
  98. __entry->call_site = call_site;
  99. __entry->ptr = ptr;
  100. ),
  101. TP_printk("call_site=%lx ptr=%p", __entry->call_site, __entry->ptr)
  102. );
  103. DEFINE_EVENT(kmem_free, kfree,
  104. TP_PROTO(unsigned long call_site, const void *ptr),
  105. TP_ARGS(call_site, ptr)
  106. );
  107. DEFINE_EVENT_CONDITION(kmem_free, kmem_cache_free,
  108. TP_PROTO(unsigned long call_site, const void *ptr),
  109. TP_ARGS(call_site, ptr),
  110. /*
  111. * This trace can be potentially called from an offlined cpu.
  112. * Since trace points use RCU and RCU should not be used from
  113. * offline cpus, filter such calls out.
  114. * While this trace can be called from a preemptable section,
  115. * it has no impact on the condition since tasks can migrate
  116. * only from online cpus to other online cpus. Thus its safe
  117. * to use raw_smp_processor_id.
  118. */
  119. TP_CONDITION(cpu_online(raw_smp_processor_id()))
  120. );
  121. TRACE_EVENT_CONDITION(mm_page_free,
  122. TP_PROTO(struct page *page, unsigned int order),
  123. TP_ARGS(page, order),
  124. /*
  125. * This trace can be potentially called from an offlined cpu.
  126. * Since trace points use RCU and RCU should not be used from
  127. * offline cpus, filter such calls out.
  128. * While this trace can be called from a preemptable section,
  129. * it has no impact on the condition since tasks can migrate
  130. * only from online cpus to other online cpus. Thus its safe
  131. * to use raw_smp_processor_id.
  132. */
  133. TP_CONDITION(cpu_online(raw_smp_processor_id())),
  134. TP_STRUCT__entry(
  135. __field( unsigned long, pfn )
  136. __field( unsigned int, order )
  137. ),
  138. TP_fast_assign(
  139. __entry->pfn = page_to_pfn(page);
  140. __entry->order = order;
  141. ),
  142. TP_printk("page=%p pfn=%lu order=%d",
  143. pfn_to_page(__entry->pfn),
  144. __entry->pfn,
  145. __entry->order)
  146. );
  147. TRACE_EVENT(mm_page_free_batched,
  148. TP_PROTO(struct page *page, int cold),
  149. TP_ARGS(page, cold),
  150. TP_STRUCT__entry(
  151. __field( unsigned long, pfn )
  152. __field( int, cold )
  153. ),
  154. TP_fast_assign(
  155. __entry->pfn = page_to_pfn(page);
  156. __entry->cold = cold;
  157. ),
  158. TP_printk("page=%p pfn=%lu order=0 cold=%d",
  159. pfn_to_page(__entry->pfn),
  160. __entry->pfn,
  161. __entry->cold)
  162. );
  163. TRACE_EVENT(mm_page_alloc,
  164. TP_PROTO(struct page *page, unsigned int order,
  165. gfp_t gfp_flags, int migratetype),
  166. TP_ARGS(page, order, gfp_flags, migratetype),
  167. TP_STRUCT__entry(
  168. __field( unsigned long, pfn )
  169. __field( unsigned int, order )
  170. __field( gfp_t, gfp_flags )
  171. __field( int, migratetype )
  172. ),
  173. TP_fast_assign(
  174. __entry->pfn = page ? page_to_pfn(page) : -1UL;
  175. __entry->order = order;
  176. __entry->gfp_flags = gfp_flags;
  177. __entry->migratetype = migratetype;
  178. ),
  179. TP_printk("page=%p pfn=%lu order=%d migratetype=%d gfp_flags=%s",
  180. __entry->pfn != -1UL ? pfn_to_page(__entry->pfn) : NULL,
  181. __entry->pfn != -1UL ? __entry->pfn : 0,
  182. __entry->order,
  183. __entry->migratetype,
  184. show_gfp_flags(__entry->gfp_flags))
  185. );
  186. DECLARE_EVENT_CLASS(mm_page,
  187. TP_PROTO(struct page *page, unsigned int order, int migratetype),
  188. TP_ARGS(page, order, migratetype),
  189. TP_STRUCT__entry(
  190. __field( unsigned long, pfn )
  191. __field( unsigned int, order )
  192. __field( int, migratetype )
  193. ),
  194. TP_fast_assign(
  195. __entry->pfn = page ? page_to_pfn(page) : -1UL;
  196. __entry->order = order;
  197. __entry->migratetype = migratetype;
  198. ),
  199. TP_printk("page=%p pfn=%lu order=%u migratetype=%d percpu_refill=%d",
  200. __entry->pfn != -1UL ? pfn_to_page(__entry->pfn) : NULL,
  201. __entry->pfn != -1UL ? __entry->pfn : 0,
  202. __entry->order,
  203. __entry->migratetype,
  204. __entry->order == 0)
  205. );
  206. DEFINE_EVENT(mm_page, mm_page_alloc_zone_locked,
  207. TP_PROTO(struct page *page, unsigned int order, int migratetype),
  208. TP_ARGS(page, order, migratetype)
  209. );
  210. TRACE_EVENT_CONDITION(mm_page_pcpu_drain,
  211. TP_PROTO(struct page *page, unsigned int order, int migratetype),
  212. TP_ARGS(page, order, migratetype),
  213. /*
  214. * This trace can be potentially called from an offlined cpu.
  215. * Since trace points use RCU and RCU should not be used from
  216. * offline cpus, filter such calls out.
  217. * While this trace can be called from a preemptable section,
  218. * it has no impact on the condition since tasks can migrate
  219. * only from online cpus to other online cpus. Thus its safe
  220. * to use raw_smp_processor_id.
  221. */
  222. TP_CONDITION(cpu_online(raw_smp_processor_id())),
  223. TP_STRUCT__entry(
  224. __field( unsigned long, pfn )
  225. __field( unsigned int, order )
  226. __field( int, migratetype )
  227. ),
  228. TP_fast_assign(
  229. __entry->pfn = page ? page_to_pfn(page) : -1UL;
  230. __entry->order = order;
  231. __entry->migratetype = migratetype;
  232. ),
  233. TP_printk("page=%p pfn=%lu order=%d migratetype=%d",
  234. pfn_to_page(__entry->pfn), __entry->pfn,
  235. __entry->order, __entry->migratetype)
  236. );
  237. TRACE_EVENT(mm_page_alloc_extfrag,
  238. TP_PROTO(struct page *page,
  239. int alloc_order, int fallback_order,
  240. int alloc_migratetype, int fallback_migratetype),
  241. TP_ARGS(page,
  242. alloc_order, fallback_order,
  243. alloc_migratetype, fallback_migratetype),
  244. TP_STRUCT__entry(
  245. __field( unsigned long, pfn )
  246. __field( int, alloc_order )
  247. __field( int, fallback_order )
  248. __field( int, alloc_migratetype )
  249. __field( int, fallback_migratetype )
  250. __field( int, change_ownership )
  251. ),
  252. TP_fast_assign(
  253. __entry->pfn = page_to_pfn(page);
  254. __entry->alloc_order = alloc_order;
  255. __entry->fallback_order = fallback_order;
  256. __entry->alloc_migratetype = alloc_migratetype;
  257. __entry->fallback_migratetype = fallback_migratetype;
  258. __entry->change_ownership = (alloc_migratetype ==
  259. get_pageblock_migratetype(page));
  260. ),
  261. TP_printk("page=%p pfn=%lu alloc_order=%d fallback_order=%d pageblock_order=%d alloc_migratetype=%d fallback_migratetype=%d fragmenting=%d change_ownership=%d",
  262. pfn_to_page(__entry->pfn),
  263. __entry->pfn,
  264. __entry->alloc_order,
  265. __entry->fallback_order,
  266. pageblock_order,
  267. __entry->alloc_migratetype,
  268. __entry->fallback_migratetype,
  269. __entry->fallback_order < pageblock_order,
  270. __entry->change_ownership)
  271. );
  272. #endif /* _TRACE_KMEM_H */
  273. /* This part must be outside protection */
  274. #include <trace/define_trace.h>