blob: 6b2e154fd23a1bcaa21e07dc578644c7b910e5eb [file] [log] [blame]
Li Zefand0b6e042009-07-13 10:33:21 +08001#undef TRACE_SYSTEM
2#define TRACE_SYSTEM kmem
3
Steven Rostedtea20d922009-04-10 08:54:16 -04004#if !defined(_TRACE_KMEM_H) || defined(TRACE_HEADER_MULTI_READ)
Zhaolei02af61b2009-04-10 14:26:18 +08005#define _TRACE_KMEM_H
Eduard - Gabriel Munteanub9ce08c2008-08-10 20:14:03 +03006
7#include <linux/types.h>
Zhaoleifc182a42009-04-10 14:27:38 +08008#include <linux/tracepoint.h>
Vlastimil Babka420adbe92016-03-15 14:55:52 -07009#include <trace/events/mmflags.h>
Steven Rostedt62ba1802009-05-15 16:16:30 -040010
Li Zefan53d04222009-11-26 15:04:10 +080011DECLARE_EVENT_CLASS(kmem_alloc,
Steven Rostedtea20d922009-04-10 08:54:16 -040012
13 TP_PROTO(unsigned long call_site,
14 const void *ptr,
15 size_t bytes_req,
16 size_t bytes_alloc,
17 gfp_t gfp_flags),
18
19 TP_ARGS(call_site, ptr, bytes_req, bytes_alloc, gfp_flags),
20
21 TP_STRUCT__entry(
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 )
27 ),
28
29 TP_fast_assign(
30 __entry->call_site = call_site;
31 __entry->ptr = ptr;
32 __entry->bytes_req = bytes_req;
33 __entry->bytes_alloc = bytes_alloc;
34 __entry->gfp_flags = gfp_flags;
35 ),
36
Steven Rostedt62ba1802009-05-15 16:16:30 -040037 TP_printk("call_site=%lx ptr=%p bytes_req=%zu bytes_alloc=%zu gfp_flags=%s",
Steven Rostedtea20d922009-04-10 08:54:16 -040038 __entry->call_site,
39 __entry->ptr,
40 __entry->bytes_req,
41 __entry->bytes_alloc,
Steven Rostedt62ba1802009-05-15 16:16:30 -040042 show_gfp_flags(__entry->gfp_flags))
Steven Rostedtea20d922009-04-10 08:54:16 -040043);
44
Li Zefan53d04222009-11-26 15:04:10 +080045DEFINE_EVENT(kmem_alloc, kmalloc,
Steven Rostedtea20d922009-04-10 08:54:16 -040046
Li Zefan53d04222009-11-26 15:04:10 +080047 TP_PROTO(unsigned long call_site, const void *ptr,
48 size_t bytes_req, size_t bytes_alloc, gfp_t gfp_flags),
Steven Rostedtea20d922009-04-10 08:54:16 -040049
Li Zefan53d04222009-11-26 15:04:10 +080050 TP_ARGS(call_site, ptr, bytes_req, bytes_alloc, gfp_flags)
Steven Rostedtea20d922009-04-10 08:54:16 -040051);
52
Li Zefan53d04222009-11-26 15:04:10 +080053DEFINE_EVENT(kmem_alloc, kmem_cache_alloc,
54
55 TP_PROTO(unsigned long call_site, const void *ptr,
56 size_t bytes_req, size_t bytes_alloc, gfp_t gfp_flags),
57
58 TP_ARGS(call_site, ptr, bytes_req, bytes_alloc, gfp_flags)
59);
60
61DECLARE_EVENT_CLASS(kmem_alloc_node,
Steven Rostedtea20d922009-04-10 08:54:16 -040062
63 TP_PROTO(unsigned long call_site,
64 const void *ptr,
65 size_t bytes_req,
66 size_t bytes_alloc,
67 gfp_t gfp_flags,
68 int node),
69
70 TP_ARGS(call_site, ptr, bytes_req, bytes_alloc, gfp_flags, node),
71
72 TP_STRUCT__entry(
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 )
78 __field( int, node )
79 ),
80
81 TP_fast_assign(
82 __entry->call_site = call_site;
83 __entry->ptr = ptr;
84 __entry->bytes_req = bytes_req;
85 __entry->bytes_alloc = bytes_alloc;
86 __entry->gfp_flags = gfp_flags;
87 __entry->node = node;
88 ),
89
Steven Rostedt62ba1802009-05-15 16:16:30 -040090 TP_printk("call_site=%lx ptr=%p bytes_req=%zu bytes_alloc=%zu gfp_flags=%s node=%d",
Steven Rostedtea20d922009-04-10 08:54:16 -040091 __entry->call_site,
92 __entry->ptr,
93 __entry->bytes_req,
94 __entry->bytes_alloc,
Steven Rostedt62ba1802009-05-15 16:16:30 -040095 show_gfp_flags(__entry->gfp_flags),
Steven Rostedtea20d922009-04-10 08:54:16 -040096 __entry->node)
97);
98
Li Zefan53d04222009-11-26 15:04:10 +080099DEFINE_EVENT(kmem_alloc_node, kmalloc_node,
Steven Rostedtea20d922009-04-10 08:54:16 -0400100
Li Zefan53d04222009-11-26 15:04:10 +0800101 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),
Steven Rostedtea20d922009-04-10 08:54:16 -0400104
Li Zefan53d04222009-11-26 15:04:10 +0800105 TP_ARGS(call_site, ptr, bytes_req, bytes_alloc, gfp_flags, node)
Steven Rostedtea20d922009-04-10 08:54:16 -0400106);
107
Li Zefan53d04222009-11-26 15:04:10 +0800108DEFINE_EVENT(kmem_alloc_node, kmem_cache_alloc_node,
109
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),
113
114 TP_ARGS(call_site, ptr, bytes_req, bytes_alloc, gfp_flags, node)
115);
116
117DECLARE_EVENT_CLASS(kmem_free,
Steven Rostedtea20d922009-04-10 08:54:16 -0400118
119 TP_PROTO(unsigned long call_site, const void *ptr),
120
121 TP_ARGS(call_site, ptr),
122
123 TP_STRUCT__entry(
124 __field( unsigned long, call_site )
125 __field( const void *, ptr )
126 ),
127
128 TP_fast_assign(
129 __entry->call_site = call_site;
130 __entry->ptr = ptr;
131 ),
132
133 TP_printk("call_site=%lx ptr=%p", __entry->call_site, __entry->ptr)
134);
135
Li Zefan53d04222009-11-26 15:04:10 +0800136DEFINE_EVENT(kmem_free, kfree,
Steven Rostedtea20d922009-04-10 08:54:16 -0400137
138 TP_PROTO(unsigned long call_site, const void *ptr),
139
Li Zefan53d04222009-11-26 15:04:10 +0800140 TP_ARGS(call_site, ptr)
141);
Steven Rostedtea20d922009-04-10 08:54:16 -0400142
Steven Rostedt (Red Hat)633f6f52016-02-19 13:59:54 -0500143DEFINE_EVENT(kmem_free, kmem_cache_free,
Steven Rostedtea20d922009-04-10 08:54:16 -0400144
Li Zefan53d04222009-11-26 15:04:10 +0800145 TP_PROTO(unsigned long call_site, const void *ptr),
Steven Rostedtea20d922009-04-10 08:54:16 -0400146
Steven Rostedt (Red Hat)633f6f52016-02-19 13:59:54 -0500147 TP_ARGS(call_site, ptr)
Steven Rostedtea20d922009-04-10 08:54:16 -0400148);
Mel Gorman4b4f2782009-09-21 17:02:41 -0700149
Steven Rostedt (Red Hat)633f6f52016-02-19 13:59:54 -0500150TRACE_EVENT(mm_page_free,
Mel Gorman4b4f2782009-09-21 17:02:41 -0700151
152 TP_PROTO(struct page *page, unsigned int order),
153
154 TP_ARGS(page, order),
155
156 TP_STRUCT__entry(
Namhyung Kim9fdd8a82015-04-06 14:36:09 +0900157 __field( unsigned long, pfn )
Mel Gorman4b4f2782009-09-21 17:02:41 -0700158 __field( unsigned int, order )
159 ),
160
161 TP_fast_assign(
Namhyung Kim9fdd8a82015-04-06 14:36:09 +0900162 __entry->pfn = page_to_pfn(page);
Mel Gorman4b4f2782009-09-21 17:02:41 -0700163 __entry->order = order;
164 ),
165
166 TP_printk("page=%p pfn=%lu order=%d",
Namhyung Kim9fdd8a82015-04-06 14:36:09 +0900167 pfn_to_page(__entry->pfn),
168 __entry->pfn,
Mel Gorman4b4f2782009-09-21 17:02:41 -0700169 __entry->order)
170);
171
Konstantin Khlebnikovb413d482012-01-10 15:07:09 -0800172TRACE_EVENT(mm_page_free_batched,
Mel Gorman4b4f2782009-09-21 17:02:41 -0700173
174 TP_PROTO(struct page *page, int cold),
175
176 TP_ARGS(page, cold),
177
178 TP_STRUCT__entry(
Namhyung Kim9fdd8a82015-04-06 14:36:09 +0900179 __field( unsigned long, pfn )
Mel Gorman4b4f2782009-09-21 17:02:41 -0700180 __field( int, cold )
181 ),
182
183 TP_fast_assign(
Namhyung Kim9fdd8a82015-04-06 14:36:09 +0900184 __entry->pfn = page_to_pfn(page);
Mel Gorman4b4f2782009-09-21 17:02:41 -0700185 __entry->cold = cold;
186 ),
187
188 TP_printk("page=%p pfn=%lu order=0 cold=%d",
Namhyung Kim9fdd8a82015-04-06 14:36:09 +0900189 pfn_to_page(__entry->pfn),
190 __entry->pfn,
Mel Gorman4b4f2782009-09-21 17:02:41 -0700191 __entry->cold)
192);
193
194TRACE_EVENT(mm_page_alloc,
195
196 TP_PROTO(struct page *page, unsigned int order,
197 gfp_t gfp_flags, int migratetype),
198
199 TP_ARGS(page, order, gfp_flags, migratetype),
200
201 TP_STRUCT__entry(
Namhyung Kim9fdd8a82015-04-06 14:36:09 +0900202 __field( unsigned long, pfn )
Mel Gorman4b4f2782009-09-21 17:02:41 -0700203 __field( unsigned int, order )
204 __field( gfp_t, gfp_flags )
205 __field( int, migratetype )
206 ),
207
208 TP_fast_assign(
Namhyung Kim9fdd8a82015-04-06 14:36:09 +0900209 __entry->pfn = page ? page_to_pfn(page) : -1UL;
Mel Gorman4b4f2782009-09-21 17:02:41 -0700210 __entry->order = order;
211 __entry->gfp_flags = gfp_flags;
212 __entry->migratetype = migratetype;
213 ),
214
215 TP_printk("page=%p pfn=%lu order=%d migratetype=%d gfp_flags=%s",
Namhyung Kim9fdd8a82015-04-06 14:36:09 +0900216 __entry->pfn != -1UL ? pfn_to_page(__entry->pfn) : NULL,
217 __entry->pfn != -1UL ? __entry->pfn : 0,
Mel Gorman4b4f2782009-09-21 17:02:41 -0700218 __entry->order,
219 __entry->migratetype,
220 show_gfp_flags(__entry->gfp_flags))
221);
222
Li Zefan53d04222009-11-26 15:04:10 +0800223DECLARE_EVENT_CLASS(mm_page,
Mel Gorman0d3d0622009-09-21 17:02:44 -0700224
225 TP_PROTO(struct page *page, unsigned int order, int migratetype),
226
227 TP_ARGS(page, order, migratetype),
228
229 TP_STRUCT__entry(
Namhyung Kim9fdd8a82015-04-06 14:36:09 +0900230 __field( unsigned long, pfn )
Mel Gorman0d3d0622009-09-21 17:02:44 -0700231 __field( unsigned int, order )
232 __field( int, migratetype )
233 ),
234
235 TP_fast_assign(
Namhyung Kim9fdd8a82015-04-06 14:36:09 +0900236 __entry->pfn = page ? page_to_pfn(page) : -1UL;
Mel Gorman0d3d0622009-09-21 17:02:44 -0700237 __entry->order = order;
238 __entry->migratetype = migratetype;
239 ),
240
241 TP_printk("page=%p pfn=%lu order=%u migratetype=%d percpu_refill=%d",
Namhyung Kim9fdd8a82015-04-06 14:36:09 +0900242 __entry->pfn != -1UL ? pfn_to_page(__entry->pfn) : NULL,
243 __entry->pfn != -1UL ? __entry->pfn : 0,
Mel Gorman0d3d0622009-09-21 17:02:44 -0700244 __entry->order,
245 __entry->migratetype,
246 __entry->order == 0)
247);
248
Li Zefan53d04222009-11-26 15:04:10 +0800249DEFINE_EVENT(mm_page, mm_page_alloc_zone_locked,
Mel Gorman0d3d0622009-09-21 17:02:44 -0700250
Li Zefan53d04222009-11-26 15:04:10 +0800251 TP_PROTO(struct page *page, unsigned int order, int migratetype),
252
253 TP_ARGS(page, order, migratetype)
254);
255
Steven Rostedt (Red Hat)633f6f52016-02-19 13:59:54 -0500256TRACE_EVENT(mm_page_pcpu_drain,
Li Zefan53d04222009-11-26 15:04:10 +0800257
258 TP_PROTO(struct page *page, unsigned int order, int migratetype),
Mel Gorman0d3d0622009-09-21 17:02:44 -0700259
260 TP_ARGS(page, order, migratetype),
261
Shreyas B. Prabhu649b8de2015-05-28 15:44:22 -0700262 TP_STRUCT__entry(
263 __field( unsigned long, pfn )
264 __field( unsigned int, order )
265 __field( int, migratetype )
266 ),
267
268 TP_fast_assign(
269 __entry->pfn = page ? page_to_pfn(page) : -1UL;
270 __entry->order = order;
271 __entry->migratetype = migratetype;
272 ),
273
Mel Gorman0d3d0622009-09-21 17:02:44 -0700274 TP_printk("page=%p pfn=%lu order=%d migratetype=%d",
Namhyung Kim9fdd8a82015-04-06 14:36:09 +0900275 pfn_to_page(__entry->pfn), __entry->pfn,
Li Zefan53d04222009-11-26 15:04:10 +0800276 __entry->order, __entry->migratetype)
Mel Gorman0d3d0622009-09-21 17:02:44 -0700277);
278
Mel Gormane0fff1b2009-09-21 17:02:42 -0700279TRACE_EVENT(mm_page_alloc_extfrag,
280
281 TP_PROTO(struct page *page,
KOSAKI Motohiro52c8f6a2013-11-12 15:08:19 -0800282 int alloc_order, int fallback_order,
Vlastimil Babka99592d52015-02-11 15:28:15 -0800283 int alloc_migratetype, int fallback_migratetype),
Mel Gormane0fff1b2009-09-21 17:02:42 -0700284
285 TP_ARGS(page,
286 alloc_order, fallback_order,
Vlastimil Babka99592d52015-02-11 15:28:15 -0800287 alloc_migratetype, fallback_migratetype),
Mel Gormane0fff1b2009-09-21 17:02:42 -0700288
289 TP_STRUCT__entry(
Namhyung Kim9fdd8a82015-04-06 14:36:09 +0900290 __field( unsigned long, pfn )
Mel Gormane0fff1b2009-09-21 17:02:42 -0700291 __field( int, alloc_order )
292 __field( int, fallback_order )
293 __field( int, alloc_migratetype )
294 __field( int, fallback_migratetype )
Srivatsa S. Bhatf92310c2013-09-11 14:20:36 -0700295 __field( int, change_ownership )
Mel Gormane0fff1b2009-09-21 17:02:42 -0700296 ),
297
298 TP_fast_assign(
Namhyung Kim9fdd8a82015-04-06 14:36:09 +0900299 __entry->pfn = page_to_pfn(page);
Mel Gormane0fff1b2009-09-21 17:02:42 -0700300 __entry->alloc_order = alloc_order;
301 __entry->fallback_order = fallback_order;
302 __entry->alloc_migratetype = alloc_migratetype;
303 __entry->fallback_migratetype = fallback_migratetype;
Vlastimil Babka99592d52015-02-11 15:28:15 -0800304 __entry->change_ownership = (alloc_migratetype ==
305 get_pageblock_migratetype(page));
Mel Gormane0fff1b2009-09-21 17:02:42 -0700306 ),
307
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",
Namhyung Kim9fdd8a82015-04-06 14:36:09 +0900309 pfn_to_page(__entry->pfn),
310 __entry->pfn,
Mel Gormane0fff1b2009-09-21 17:02:42 -0700311 __entry->alloc_order,
312 __entry->fallback_order,
313 pageblock_order,
314 __entry->alloc_migratetype,
315 __entry->fallback_migratetype,
316 __entry->fallback_order < pageblock_order,
Srivatsa S. Bhatf92310c2013-09-11 14:20:36 -0700317 __entry->change_ownership)
Mel Gormane0fff1b2009-09-21 17:02:42 -0700318);
319
Steven Rostedta8d154b2009-04-10 09:36:00 -0400320#endif /* _TRACE_KMEM_H */
Steven Rostedtea20d922009-04-10 08:54:16 -0400321
Steven Rostedta8d154b2009-04-10 09:36:00 -0400322/* This part must be outside protection */
323#include <trace/define_trace.h>