kmem.h 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309
  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 "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(kmem_free, kmem_cache_free,
  108. TP_PROTO(unsigned long call_site, const void *ptr),
  109. TP_ARGS(call_site, ptr)
  110. );
  111. TRACE_EVENT(mm_page_free_direct,
  112. TP_PROTO(struct page *page, unsigned int order),
  113. TP_ARGS(page, order),
  114. TP_STRUCT__entry(
  115. __field( struct page *, page )
  116. __field( unsigned int, order )
  117. ),
  118. TP_fast_assign(
  119. __entry->page = page;
  120. __entry->order = order;
  121. ),
  122. TP_printk("page=%p pfn=%lu order=%d",
  123. __entry->page,
  124. page_to_pfn(__entry->page),
  125. __entry->order)
  126. );
  127. TRACE_EVENT(mm_pagevec_free,
  128. TP_PROTO(struct page *page, int cold),
  129. TP_ARGS(page, cold),
  130. TP_STRUCT__entry(
  131. __field( struct page *, page )
  132. __field( int, cold )
  133. ),
  134. TP_fast_assign(
  135. __entry->page = page;
  136. __entry->cold = cold;
  137. ),
  138. TP_printk("page=%p pfn=%lu order=0 cold=%d",
  139. __entry->page,
  140. page_to_pfn(__entry->page),
  141. __entry->cold)
  142. );
  143. TRACE_EVENT(mm_page_alloc,
  144. TP_PROTO(struct page *page, unsigned int order,
  145. gfp_t gfp_flags, int migratetype),
  146. TP_ARGS(page, order, gfp_flags, migratetype),
  147. TP_STRUCT__entry(
  148. __field( struct page *, page )
  149. __field( unsigned int, order )
  150. __field( gfp_t, gfp_flags )
  151. __field( int, migratetype )
  152. ),
  153. TP_fast_assign(
  154. __entry->page = page;
  155. __entry->order = order;
  156. __entry->gfp_flags = gfp_flags;
  157. __entry->migratetype = migratetype;
  158. ),
  159. TP_printk("page=%p pfn=%lu order=%d migratetype=%d gfp_flags=%s",
  160. __entry->page,
  161. page_to_pfn(__entry->page),
  162. __entry->order,
  163. __entry->migratetype,
  164. show_gfp_flags(__entry->gfp_flags))
  165. );
  166. DECLARE_EVENT_CLASS(mm_page,
  167. TP_PROTO(struct page *page, unsigned int order, int migratetype),
  168. TP_ARGS(page, order, migratetype),
  169. TP_STRUCT__entry(
  170. __field( struct page *, page )
  171. __field( unsigned int, order )
  172. __field( int, migratetype )
  173. ),
  174. TP_fast_assign(
  175. __entry->page = page;
  176. __entry->order = order;
  177. __entry->migratetype = migratetype;
  178. ),
  179. TP_printk("page=%p pfn=%lu order=%u migratetype=%d percpu_refill=%d",
  180. __entry->page,
  181. page_to_pfn(__entry->page),
  182. __entry->order,
  183. __entry->migratetype,
  184. __entry->order == 0)
  185. );
  186. DEFINE_EVENT(mm_page, mm_page_alloc_zone_locked,
  187. TP_PROTO(struct page *page, unsigned int order, int migratetype),
  188. TP_ARGS(page, order, migratetype)
  189. );
  190. DEFINE_EVENT_PRINT(mm_page, mm_page_pcpu_drain,
  191. TP_PROTO(struct page *page, unsigned int order, int migratetype),
  192. TP_ARGS(page, order, migratetype),
  193. TP_printk("page=%p pfn=%lu order=%d migratetype=%d",
  194. __entry->page, page_to_pfn(__entry->page),
  195. __entry->order, __entry->migratetype)
  196. );
  197. TRACE_EVENT(mm_page_alloc_extfrag,
  198. TP_PROTO(struct page *page,
  199. int alloc_order, int fallback_order,
  200. int alloc_migratetype, int fallback_migratetype),
  201. TP_ARGS(page,
  202. alloc_order, fallback_order,
  203. alloc_migratetype, fallback_migratetype),
  204. TP_STRUCT__entry(
  205. __field( struct page *, page )
  206. __field( int, alloc_order )
  207. __field( int, fallback_order )
  208. __field( int, alloc_migratetype )
  209. __field( int, fallback_migratetype )
  210. ),
  211. TP_fast_assign(
  212. __entry->page = page;
  213. __entry->alloc_order = alloc_order;
  214. __entry->fallback_order = fallback_order;
  215. __entry->alloc_migratetype = alloc_migratetype;
  216. __entry->fallback_migratetype = fallback_migratetype;
  217. ),
  218. 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",
  219. __entry->page,
  220. page_to_pfn(__entry->page),
  221. __entry->alloc_order,
  222. __entry->fallback_order,
  223. pageblock_order,
  224. __entry->alloc_migratetype,
  225. __entry->fallback_migratetype,
  226. __entry->fallback_order < pageblock_order,
  227. __entry->alloc_migratetype == __entry->fallback_migratetype)
  228. );
  229. #endif /* _TRACE_KMEM_H */
  230. /* This part must be outside protection */
  231. #include <trace/define_trace.h>