1 /* SPDX-License-Identifier: GPL-2.0 */
3 #define TRACE_SYSTEM kmem
5 #if !defined(_TRACE_KMEM_H) || defined(TRACE_HEADER_MULTI_READ)
8 #include <linux/types.h>
9 #include <linux/tracepoint.h>
10 #include <trace/events/mmflags.h>
12 DECLARE_EVENT_CLASS(kmem_alloc
,
14 TP_PROTO(unsigned long call_site
,
20 TP_ARGS(call_site
, ptr
, bytes_req
, bytes_alloc
, gfp_flags
),
23 __field( unsigned long, call_site
)
24 __field( const void *, ptr
)
25 __field( size_t, bytes_req
)
26 __field( size_t, bytes_alloc
)
27 __field( gfp_t
, gfp_flags
)
31 __entry
->call_site
= call_site
;
33 __entry
->bytes_req
= bytes_req
;
34 __entry
->bytes_alloc
= bytes_alloc
;
35 __entry
->gfp_flags
= gfp_flags
;
38 TP_printk("call_site=%lx ptr=%p bytes_req=%zu bytes_alloc=%zu gfp_flags=%s",
43 show_gfp_flags(__entry
->gfp_flags
))
46 DEFINE_EVENT(kmem_alloc
, kmalloc
,
48 TP_PROTO(unsigned long call_site
, const void *ptr
,
49 size_t bytes_req
, size_t bytes_alloc
, gfp_t gfp_flags
),
51 TP_ARGS(call_site
, ptr
, bytes_req
, bytes_alloc
, gfp_flags
)
54 DEFINE_EVENT(kmem_alloc
, kmem_cache_alloc
,
56 TP_PROTO(unsigned long call_site
, const void *ptr
,
57 size_t bytes_req
, size_t bytes_alloc
, gfp_t gfp_flags
),
59 TP_ARGS(call_site
, ptr
, bytes_req
, bytes_alloc
, gfp_flags
)
62 DECLARE_EVENT_CLASS(kmem_alloc_node
,
64 TP_PROTO(unsigned long call_site
,
71 TP_ARGS(call_site
, ptr
, bytes_req
, bytes_alloc
, gfp_flags
, node
),
74 __field( unsigned long, call_site
)
75 __field( const void *, ptr
)
76 __field( size_t, bytes_req
)
77 __field( size_t, bytes_alloc
)
78 __field( gfp_t
, gfp_flags
)
83 __entry
->call_site
= call_site
;
85 __entry
->bytes_req
= bytes_req
;
86 __entry
->bytes_alloc
= bytes_alloc
;
87 __entry
->gfp_flags
= gfp_flags
;
91 TP_printk("call_site=%lx ptr=%p bytes_req=%zu bytes_alloc=%zu gfp_flags=%s node=%d",
96 show_gfp_flags(__entry
->gfp_flags
),
100 DEFINE_EVENT(kmem_alloc_node
, kmalloc_node
,
102 TP_PROTO(unsigned long call_site
, const void *ptr
,
103 size_t bytes_req
, size_t bytes_alloc
,
104 gfp_t gfp_flags
, int node
),
106 TP_ARGS(call_site
, ptr
, bytes_req
, bytes_alloc
, gfp_flags
, node
)
109 DEFINE_EVENT(kmem_alloc_node
, kmem_cache_alloc_node
,
111 TP_PROTO(unsigned long call_site
, const void *ptr
,
112 size_t bytes_req
, size_t bytes_alloc
,
113 gfp_t gfp_flags
, int node
),
115 TP_ARGS(call_site
, ptr
, bytes_req
, bytes_alloc
, gfp_flags
, node
)
118 DECLARE_EVENT_CLASS(kmem_free
,
120 TP_PROTO(unsigned long call_site
, const void *ptr
),
122 TP_ARGS(call_site
, ptr
),
125 __field( unsigned long, call_site
)
126 __field( const void *, ptr
)
130 __entry
->call_site
= call_site
;
134 TP_printk("call_site=%lx ptr=%p", __entry
->call_site
, __entry
->ptr
)
137 DEFINE_EVENT(kmem_free
, kfree
,
139 TP_PROTO(unsigned long call_site
, const void *ptr
),
141 TP_ARGS(call_site
, ptr
)
144 DEFINE_EVENT(kmem_free
, kmem_cache_free
,
146 TP_PROTO(unsigned long call_site
, const void *ptr
),
148 TP_ARGS(call_site
, ptr
)
151 TRACE_EVENT(mm_page_free
,
153 TP_PROTO(struct page
*page
, unsigned int order
),
155 TP_ARGS(page
, order
),
158 __field( unsigned long, pfn
)
159 __field( unsigned int, order
)
163 __entry
->pfn
= page_to_pfn(page
);
164 __entry
->order
= order
;
167 TP_printk("page=%p pfn=%lu order=%d",
168 pfn_to_page(__entry
->pfn
),
173 TRACE_EVENT(mm_page_free_batched
,
175 TP_PROTO(struct page
*page
),
180 __field( unsigned long, pfn
)
184 __entry
->pfn
= page_to_pfn(page
);
187 TP_printk("page=%p pfn=%lu order=0",
188 pfn_to_page(__entry
->pfn
),
192 TRACE_EVENT(mm_page_alloc
,
194 TP_PROTO(struct page
*page
, unsigned int order
,
195 gfp_t gfp_flags
, int migratetype
),
197 TP_ARGS(page
, order
, gfp_flags
, migratetype
),
200 __field( unsigned long, pfn
)
201 __field( unsigned int, order
)
202 __field( gfp_t
, gfp_flags
)
203 __field( int, migratetype
)
207 __entry
->pfn
= page
? page_to_pfn(page
) : -1UL;
208 __entry
->order
= order
;
209 __entry
->gfp_flags
= gfp_flags
;
210 __entry
->migratetype
= migratetype
;
213 TP_printk("page=%p pfn=%lu order=%d migratetype=%d gfp_flags=%s",
214 __entry
->pfn
!= -1UL ? pfn_to_page(__entry
->pfn
) : NULL
,
215 __entry
->pfn
!= -1UL ? __entry
->pfn
: 0,
217 __entry
->migratetype
,
218 show_gfp_flags(__entry
->gfp_flags
))
221 DECLARE_EVENT_CLASS(mm_page
,
223 TP_PROTO(struct page
*page
, unsigned int order
, int migratetype
),
225 TP_ARGS(page
, order
, migratetype
),
228 __field( unsigned long, pfn
)
229 __field( unsigned int, order
)
230 __field( int, migratetype
)
234 __entry
->pfn
= page
? page_to_pfn(page
) : -1UL;
235 __entry
->order
= order
;
236 __entry
->migratetype
= migratetype
;
239 TP_printk("page=%p pfn=%lu order=%u migratetype=%d percpu_refill=%d",
240 __entry
->pfn
!= -1UL ? pfn_to_page(__entry
->pfn
) : NULL
,
241 __entry
->pfn
!= -1UL ? __entry
->pfn
: 0,
243 __entry
->migratetype
,
247 DEFINE_EVENT(mm_page
, mm_page_alloc_zone_locked
,
249 TP_PROTO(struct page
*page
, unsigned int order
, int migratetype
),
251 TP_ARGS(page
, order
, migratetype
)
254 TRACE_EVENT(mm_page_pcpu_drain
,
256 TP_PROTO(struct page
*page
, unsigned int order
, int migratetype
),
258 TP_ARGS(page
, order
, migratetype
),
261 __field( unsigned long, pfn
)
262 __field( unsigned int, order
)
263 __field( int, migratetype
)
267 __entry
->pfn
= page
? page_to_pfn(page
) : -1UL;
268 __entry
->order
= order
;
269 __entry
->migratetype
= migratetype
;
272 TP_printk("page=%p pfn=%lu order=%d migratetype=%d",
273 pfn_to_page(__entry
->pfn
), __entry
->pfn
,
274 __entry
->order
, __entry
->migratetype
)
277 TRACE_EVENT(mm_page_alloc_extfrag
,
279 TP_PROTO(struct page
*page
,
280 int alloc_order
, int fallback_order
,
281 int alloc_migratetype
, int fallback_migratetype
),
284 alloc_order
, fallback_order
,
285 alloc_migratetype
, fallback_migratetype
),
288 __field( unsigned long, pfn
)
289 __field( int, alloc_order
)
290 __field( int, fallback_order
)
291 __field( int, alloc_migratetype
)
292 __field( int, fallback_migratetype
)
293 __field( int, change_ownership
)
297 __entry
->pfn
= page_to_pfn(page
);
298 __entry
->alloc_order
= alloc_order
;
299 __entry
->fallback_order
= fallback_order
;
300 __entry
->alloc_migratetype
= alloc_migratetype
;
301 __entry
->fallback_migratetype
= fallback_migratetype
;
302 __entry
->change_ownership
= (alloc_migratetype
==
303 get_pageblock_migratetype(page
));
306 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",
307 pfn_to_page(__entry
->pfn
),
309 __entry
->alloc_order
,
310 __entry
->fallback_order
,
312 __entry
->alloc_migratetype
,
313 __entry
->fallback_migratetype
,
314 __entry
->fallback_order
< pageblock_order
,
315 __entry
->change_ownership
)
318 #endif /* _TRACE_KMEM_H */
320 /* This part must be outside protection */
321 #include <trace/define_trace.h>