2 #define TRACE_SYSTEM kmem
4 #if !defined(_TRACE_KMEM_H) || defined(TRACE_HEADER_MULTI_READ)
7 #include <linux/types.h>
8 #include <linux/tracepoint.h>
9 #include <trace/events/mmflags.h>
11 DECLARE_EVENT_CLASS(kmem_alloc
,
13 TP_PROTO(unsigned long call_site
,
19 TP_ARGS(call_site
, ptr
, bytes_req
, bytes_alloc
, gfp_flags
),
22 __field( unsigned long, call_site
)
23 __field( const void *, ptr
)
24 __field( size_t, bytes_req
)
25 __field( size_t, bytes_alloc
)
26 __field( gfp_t
, gfp_flags
)
30 __entry
->call_site
= call_site
;
32 __entry
->bytes_req
= bytes_req
;
33 __entry
->bytes_alloc
= bytes_alloc
;
34 __entry
->gfp_flags
= gfp_flags
;
37 TP_printk("call_site=%lx ptr=%p bytes_req=%zu bytes_alloc=%zu gfp_flags=%s",
42 show_gfp_flags(__entry
->gfp_flags
))
45 DEFINE_EVENT(kmem_alloc
, kmalloc
,
47 TP_PROTO(unsigned long call_site
, const void *ptr
,
48 size_t bytes_req
, size_t bytes_alloc
, gfp_t gfp_flags
),
50 TP_ARGS(call_site
, ptr
, bytes_req
, bytes_alloc
, gfp_flags
)
53 DEFINE_EVENT(kmem_alloc
, kmem_cache_alloc
,
55 TP_PROTO(unsigned long call_site
, const void *ptr
,
56 size_t bytes_req
, size_t bytes_alloc
, gfp_t gfp_flags
),
58 TP_ARGS(call_site
, ptr
, bytes_req
, bytes_alloc
, gfp_flags
)
61 DECLARE_EVENT_CLASS(kmem_alloc_node
,
63 TP_PROTO(unsigned long call_site
,
70 TP_ARGS(call_site
, ptr
, bytes_req
, bytes_alloc
, gfp_flags
, node
),
73 __field( unsigned long, call_site
)
74 __field( const void *, ptr
)
75 __field( size_t, bytes_req
)
76 __field( size_t, bytes_alloc
)
77 __field( gfp_t
, gfp_flags
)
82 __entry
->call_site
= call_site
;
84 __entry
->bytes_req
= bytes_req
;
85 __entry
->bytes_alloc
= bytes_alloc
;
86 __entry
->gfp_flags
= gfp_flags
;
90 TP_printk("call_site=%lx ptr=%p bytes_req=%zu bytes_alloc=%zu gfp_flags=%s node=%d",
95 show_gfp_flags(__entry
->gfp_flags
),
99 DEFINE_EVENT(kmem_alloc_node
, kmalloc_node
,
101 TP_PROTO(unsigned long call_site
, const void *ptr
,
102 size_t bytes_req
, size_t bytes_alloc
,
103 gfp_t gfp_flags
, int node
),
105 TP_ARGS(call_site
, ptr
, bytes_req
, bytes_alloc
, gfp_flags
, node
)
108 DEFINE_EVENT(kmem_alloc_node
, kmem_cache_alloc_node
,
110 TP_PROTO(unsigned long call_site
, const void *ptr
,
111 size_t bytes_req
, size_t bytes_alloc
,
112 gfp_t gfp_flags
, int node
),
114 TP_ARGS(call_site
, ptr
, bytes_req
, bytes_alloc
, gfp_flags
, node
)
117 DECLARE_EVENT_CLASS(kmem_free
,
119 TP_PROTO(unsigned long call_site
, const void *ptr
),
121 TP_ARGS(call_site
, ptr
),
124 __field( unsigned long, call_site
)
125 __field( const void *, ptr
)
129 __entry
->call_site
= call_site
;
133 TP_printk("call_site=%lx ptr=%p", __entry
->call_site
, __entry
->ptr
)
136 DEFINE_EVENT(kmem_free
, kfree
,
138 TP_PROTO(unsigned long call_site
, const void *ptr
),
140 TP_ARGS(call_site
, ptr
)
143 DEFINE_EVENT(kmem_free
, kmem_cache_free
,
145 TP_PROTO(unsigned long call_site
, const void *ptr
),
147 TP_ARGS(call_site
, ptr
)
150 TRACE_EVENT(mm_page_free
,
152 TP_PROTO(struct page
*page
, unsigned int order
),
154 TP_ARGS(page
, order
),
157 __field( unsigned long, pfn
)
158 __field( unsigned int, order
)
162 __entry
->pfn
= page_to_pfn(page
);
163 __entry
->order
= order
;
166 TP_printk("page=%p pfn=%lu order=%d",
167 pfn_to_page(__entry
->pfn
),
172 TRACE_EVENT(mm_page_free_batched
,
174 TP_PROTO(struct page
*page
, int cold
),
179 __field( unsigned long, pfn
)
184 __entry
->pfn
= page_to_pfn(page
);
185 __entry
->cold
= cold
;
188 TP_printk("page=%p pfn=%lu order=0 cold=%d",
189 pfn_to_page(__entry
->pfn
),
194 TRACE_EVENT(mm_page_alloc
,
196 TP_PROTO(struct page
*page
, unsigned int order
,
197 gfp_t gfp_flags
, int migratetype
),
199 TP_ARGS(page
, order
, gfp_flags
, migratetype
),
202 __field( unsigned long, pfn
)
203 __field( unsigned int, order
)
204 __field( gfp_t
, gfp_flags
)
205 __field( int, migratetype
)
209 __entry
->pfn
= page
? page_to_pfn(page
) : -1UL;
210 __entry
->order
= order
;
211 __entry
->gfp_flags
= gfp_flags
;
212 __entry
->migratetype
= migratetype
;
215 TP_printk("page=%p pfn=%lu order=%d migratetype=%d gfp_flags=%s",
216 __entry
->pfn
!= -1UL ? pfn_to_page(__entry
->pfn
) : NULL
,
217 __entry
->pfn
!= -1UL ? __entry
->pfn
: 0,
219 __entry
->migratetype
,
220 show_gfp_flags(__entry
->gfp_flags
))
223 DECLARE_EVENT_CLASS(mm_page
,
225 TP_PROTO(struct page
*page
, unsigned int order
, int migratetype
),
227 TP_ARGS(page
, order
, migratetype
),
230 __field( unsigned long, pfn
)
231 __field( unsigned int, order
)
232 __field( int, migratetype
)
236 __entry
->pfn
= page
? page_to_pfn(page
) : -1UL;
237 __entry
->order
= order
;
238 __entry
->migratetype
= migratetype
;
241 TP_printk("page=%p pfn=%lu order=%u migratetype=%d percpu_refill=%d",
242 __entry
->pfn
!= -1UL ? pfn_to_page(__entry
->pfn
) : NULL
,
243 __entry
->pfn
!= -1UL ? __entry
->pfn
: 0,
245 __entry
->migratetype
,
249 DEFINE_EVENT(mm_page
, mm_page_alloc_zone_locked
,
251 TP_PROTO(struct page
*page
, unsigned int order
, int migratetype
),
253 TP_ARGS(page
, order
, migratetype
)
256 TRACE_EVENT(mm_page_pcpu_drain
,
258 TP_PROTO(struct page
*page
, unsigned int order
, int migratetype
),
260 TP_ARGS(page
, order
, migratetype
),
263 __field( unsigned long, pfn
)
264 __field( unsigned int, order
)
265 __field( int, migratetype
)
269 __entry
->pfn
= page
? page_to_pfn(page
) : -1UL;
270 __entry
->order
= order
;
271 __entry
->migratetype
= migratetype
;
274 TP_printk("page=%p pfn=%lu order=%d migratetype=%d",
275 pfn_to_page(__entry
->pfn
), __entry
->pfn
,
276 __entry
->order
, __entry
->migratetype
)
279 TRACE_EVENT(mm_page_alloc_extfrag
,
281 TP_PROTO(struct page
*page
,
282 int alloc_order
, int fallback_order
,
283 int alloc_migratetype
, int fallback_migratetype
),
286 alloc_order
, fallback_order
,
287 alloc_migratetype
, fallback_migratetype
),
290 __field( unsigned long, pfn
)
291 __field( int, alloc_order
)
292 __field( int, fallback_order
)
293 __field( int, alloc_migratetype
)
294 __field( int, fallback_migratetype
)
295 __field( int, change_ownership
)
299 __entry
->pfn
= page_to_pfn(page
);
300 __entry
->alloc_order
= alloc_order
;
301 __entry
->fallback_order
= fallback_order
;
302 __entry
->alloc_migratetype
= alloc_migratetype
;
303 __entry
->fallback_migratetype
= fallback_migratetype
;
304 __entry
->change_ownership
= (alloc_migratetype
==
305 get_pageblock_migratetype(page
));
308 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",
309 pfn_to_page(__entry
->pfn
),
311 __entry
->alloc_order
,
312 __entry
->fallback_order
,
314 __entry
->alloc_migratetype
,
315 __entry
->fallback_migratetype
,
316 __entry
->fallback_order
< pageblock_order
,
317 __entry
->change_ownership
)
320 #endif /* _TRACE_KMEM_H */
322 /* This part must be outside protection */
323 #include <trace/define_trace.h>