Greg Kroah-Hartman | b244131 | 2017-11-01 15:07:57 +0100 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0 */ |
Li Zefan | d0b6e04 | 2009-07-13 10:33:21 +0800 | [diff] [blame] | 2 | #undef TRACE_SYSTEM |
| 3 | #define TRACE_SYSTEM kmem |
| 4 | |
Steven Rostedt | ea20d92 | 2009-04-10 08:54:16 -0400 | [diff] [blame] | 5 | #if !defined(_TRACE_KMEM_H) || defined(TRACE_HEADER_MULTI_READ) |
Zhaolei | 02af61b | 2009-04-10 14:26:18 +0800 | [diff] [blame] | 6 | #define _TRACE_KMEM_H |
Eduard - Gabriel Munteanu | b9ce08c | 2008-08-10 20:14:03 +0300 | [diff] [blame] | 7 | |
| 8 | #include <linux/types.h> |
Zhaolei | fc182a4 | 2009-04-10 14:27:38 +0800 | [diff] [blame] | 9 | #include <linux/tracepoint.h> |
Vlastimil Babka | 420adbe9 | 2016-03-15 14:55:52 -0700 | [diff] [blame] | 10 | #include <trace/events/mmflags.h> |
Steven Rostedt | 62ba180 | 2009-05-15 16:16:30 -0400 | [diff] [blame] | 11 | |
Li Zefan | 53d0422 | 2009-11-26 15:04:10 +0800 | [diff] [blame] | 12 | DECLARE_EVENT_CLASS(kmem_alloc, |
Steven Rostedt | ea20d92 | 2009-04-10 08:54:16 -0400 | [diff] [blame] | 13 | |
| 14 | TP_PROTO(unsigned long call_site, |
| 15 | const void *ptr, |
| 16 | size_t bytes_req, |
| 17 | size_t bytes_alloc, |
| 18 | gfp_t gfp_flags), |
| 19 | |
| 20 | TP_ARGS(call_site, ptr, bytes_req, bytes_alloc, gfp_flags), |
| 21 | |
| 22 | TP_STRUCT__entry( |
| 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 ) |
| 28 | ), |
| 29 | |
| 30 | TP_fast_assign( |
| 31 | __entry->call_site = call_site; |
| 32 | __entry->ptr = ptr; |
| 33 | __entry->bytes_req = bytes_req; |
| 34 | __entry->bytes_alloc = bytes_alloc; |
| 35 | __entry->gfp_flags = gfp_flags; |
| 36 | ), |
| 37 | |
Changbin Du | f7d6316 | 2019-09-14 18:32:15 +0800 | [diff] [blame] | 38 | TP_printk("call_site=%pS ptr=%p bytes_req=%zu bytes_alloc=%zu gfp_flags=%s", |
| 39 | (void *)__entry->call_site, |
Steven Rostedt | ea20d92 | 2009-04-10 08:54:16 -0400 | [diff] [blame] | 40 | __entry->ptr, |
| 41 | __entry->bytes_req, |
| 42 | __entry->bytes_alloc, |
Steven Rostedt | 62ba180 | 2009-05-15 16:16:30 -0400 | [diff] [blame] | 43 | show_gfp_flags(__entry->gfp_flags)) |
Steven Rostedt | ea20d92 | 2009-04-10 08:54:16 -0400 | [diff] [blame] | 44 | ); |
| 45 | |
Li Zefan | 53d0422 | 2009-11-26 15:04:10 +0800 | [diff] [blame] | 46 | DEFINE_EVENT(kmem_alloc, kmalloc, |
Steven Rostedt | ea20d92 | 2009-04-10 08:54:16 -0400 | [diff] [blame] | 47 | |
Li Zefan | 53d0422 | 2009-11-26 15:04:10 +0800 | [diff] [blame] | 48 | TP_PROTO(unsigned long call_site, const void *ptr, |
| 49 | size_t bytes_req, size_t bytes_alloc, gfp_t gfp_flags), |
Steven Rostedt | ea20d92 | 2009-04-10 08:54:16 -0400 | [diff] [blame] | 50 | |
Li Zefan | 53d0422 | 2009-11-26 15:04:10 +0800 | [diff] [blame] | 51 | TP_ARGS(call_site, ptr, bytes_req, bytes_alloc, gfp_flags) |
Steven Rostedt | ea20d92 | 2009-04-10 08:54:16 -0400 | [diff] [blame] | 52 | ); |
| 53 | |
Li Zefan | 53d0422 | 2009-11-26 15:04:10 +0800 | [diff] [blame] | 54 | DEFINE_EVENT(kmem_alloc, kmem_cache_alloc, |
| 55 | |
| 56 | TP_PROTO(unsigned long call_site, const void *ptr, |
| 57 | size_t bytes_req, size_t bytes_alloc, gfp_t gfp_flags), |
| 58 | |
| 59 | TP_ARGS(call_site, ptr, bytes_req, bytes_alloc, gfp_flags) |
| 60 | ); |
| 61 | |
| 62 | DECLARE_EVENT_CLASS(kmem_alloc_node, |
Steven Rostedt | ea20d92 | 2009-04-10 08:54:16 -0400 | [diff] [blame] | 63 | |
| 64 | TP_PROTO(unsigned long call_site, |
| 65 | const void *ptr, |
| 66 | size_t bytes_req, |
| 67 | size_t bytes_alloc, |
| 68 | gfp_t gfp_flags, |
| 69 | int node), |
| 70 | |
| 71 | TP_ARGS(call_site, ptr, bytes_req, bytes_alloc, gfp_flags, node), |
| 72 | |
| 73 | TP_STRUCT__entry( |
| 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 ) |
| 79 | __field( int, node ) |
| 80 | ), |
| 81 | |
| 82 | TP_fast_assign( |
| 83 | __entry->call_site = call_site; |
| 84 | __entry->ptr = ptr; |
| 85 | __entry->bytes_req = bytes_req; |
| 86 | __entry->bytes_alloc = bytes_alloc; |
| 87 | __entry->gfp_flags = gfp_flags; |
| 88 | __entry->node = node; |
| 89 | ), |
| 90 | |
Junyong Sun | 7e168b9 | 2020-01-30 22:13:48 -0800 | [diff] [blame] | 91 | TP_printk("call_site=%pS ptr=%p bytes_req=%zu bytes_alloc=%zu gfp_flags=%s node=%d", |
| 92 | (void *)__entry->call_site, |
Steven Rostedt | ea20d92 | 2009-04-10 08:54:16 -0400 | [diff] [blame] | 93 | __entry->ptr, |
| 94 | __entry->bytes_req, |
| 95 | __entry->bytes_alloc, |
Steven Rostedt | 62ba180 | 2009-05-15 16:16:30 -0400 | [diff] [blame] | 96 | show_gfp_flags(__entry->gfp_flags), |
Steven Rostedt | ea20d92 | 2009-04-10 08:54:16 -0400 | [diff] [blame] | 97 | __entry->node) |
| 98 | ); |
| 99 | |
Li Zefan | 53d0422 | 2009-11-26 15:04:10 +0800 | [diff] [blame] | 100 | DEFINE_EVENT(kmem_alloc_node, kmalloc_node, |
Steven Rostedt | ea20d92 | 2009-04-10 08:54:16 -0400 | [diff] [blame] | 101 | |
Li Zefan | 53d0422 | 2009-11-26 15:04:10 +0800 | [diff] [blame] | 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), |
Steven Rostedt | ea20d92 | 2009-04-10 08:54:16 -0400 | [diff] [blame] | 105 | |
Li Zefan | 53d0422 | 2009-11-26 15:04:10 +0800 | [diff] [blame] | 106 | TP_ARGS(call_site, ptr, bytes_req, bytes_alloc, gfp_flags, node) |
Steven Rostedt | ea20d92 | 2009-04-10 08:54:16 -0400 | [diff] [blame] | 107 | ); |
| 108 | |
Li Zefan | 53d0422 | 2009-11-26 15:04:10 +0800 | [diff] [blame] | 109 | DEFINE_EVENT(kmem_alloc_node, kmem_cache_alloc_node, |
| 110 | |
| 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), |
| 114 | |
| 115 | TP_ARGS(call_site, ptr, bytes_req, bytes_alloc, gfp_flags, node) |
| 116 | ); |
| 117 | |
Jacob Wen | 3544de8e | 2021-02-24 12:00:55 -0800 | [diff] [blame] | 118 | TRACE_EVENT(kfree, |
Steven Rostedt | ea20d92 | 2009-04-10 08:54:16 -0400 | [diff] [blame] | 119 | |
| 120 | TP_PROTO(unsigned long call_site, const void *ptr), |
| 121 | |
| 122 | TP_ARGS(call_site, ptr), |
| 123 | |
| 124 | TP_STRUCT__entry( |
| 125 | __field( unsigned long, call_site ) |
| 126 | __field( const void *, ptr ) |
| 127 | ), |
| 128 | |
| 129 | TP_fast_assign( |
| 130 | __entry->call_site = call_site; |
| 131 | __entry->ptr = ptr; |
| 132 | ), |
| 133 | |
Changbin Du | f7d6316 | 2019-09-14 18:32:15 +0800 | [diff] [blame] | 134 | TP_printk("call_site=%pS ptr=%p", |
| 135 | (void *)__entry->call_site, __entry->ptr) |
Steven Rostedt | ea20d92 | 2009-04-10 08:54:16 -0400 | [diff] [blame] | 136 | ); |
| 137 | |
Jacob Wen | 3544de8e | 2021-02-24 12:00:55 -0800 | [diff] [blame] | 138 | TRACE_EVENT(kmem_cache_free, |
Steven Rostedt | ea20d92 | 2009-04-10 08:54:16 -0400 | [diff] [blame] | 139 | |
Jacob Wen | 3544de8e | 2021-02-24 12:00:55 -0800 | [diff] [blame] | 140 | TP_PROTO(unsigned long call_site, const void *ptr, const char *name), |
Steven Rostedt | ea20d92 | 2009-04-10 08:54:16 -0400 | [diff] [blame] | 141 | |
Jacob Wen | 3544de8e | 2021-02-24 12:00:55 -0800 | [diff] [blame] | 142 | TP_ARGS(call_site, ptr, name), |
Steven Rostedt | ea20d92 | 2009-04-10 08:54:16 -0400 | [diff] [blame] | 143 | |
Jacob Wen | 3544de8e | 2021-02-24 12:00:55 -0800 | [diff] [blame] | 144 | TP_STRUCT__entry( |
| 145 | __field( unsigned long, call_site ) |
| 146 | __field( const void *, ptr ) |
Steven Rostedt (VMware) | d814567 | 2021-02-25 12:49:58 -0500 | [diff] [blame] | 147 | __string( name, name ) |
Jacob Wen | 3544de8e | 2021-02-24 12:00:55 -0800 | [diff] [blame] | 148 | ), |
Steven Rostedt | ea20d92 | 2009-04-10 08:54:16 -0400 | [diff] [blame] | 149 | |
Jacob Wen | 3544de8e | 2021-02-24 12:00:55 -0800 | [diff] [blame] | 150 | TP_fast_assign( |
| 151 | __entry->call_site = call_site; |
| 152 | __entry->ptr = ptr; |
Steven Rostedt (VMware) | d814567 | 2021-02-25 12:49:58 -0500 | [diff] [blame] | 153 | __assign_str(name, name); |
Jacob Wen | 3544de8e | 2021-02-24 12:00:55 -0800 | [diff] [blame] | 154 | ), |
Steven Rostedt | ea20d92 | 2009-04-10 08:54:16 -0400 | [diff] [blame] | 155 | |
Jacob Wen | 3544de8e | 2021-02-24 12:00:55 -0800 | [diff] [blame] | 156 | TP_printk("call_site=%pS ptr=%p name=%s", |
Steven Rostedt (VMware) | d814567 | 2021-02-25 12:49:58 -0500 | [diff] [blame] | 157 | (void *)__entry->call_site, __entry->ptr, __get_str(name)) |
Steven Rostedt | ea20d92 | 2009-04-10 08:54:16 -0400 | [diff] [blame] | 158 | ); |
Mel Gorman | 4b4f278 | 2009-09-21 17:02:41 -0700 | [diff] [blame] | 159 | |
Steven Rostedt (Red Hat) | 633f6f5 | 2016-02-19 13:59:54 -0500 | [diff] [blame] | 160 | TRACE_EVENT(mm_page_free, |
Mel Gorman | 4b4f278 | 2009-09-21 17:02:41 -0700 | [diff] [blame] | 161 | |
| 162 | TP_PROTO(struct page *page, unsigned int order), |
| 163 | |
| 164 | TP_ARGS(page, order), |
| 165 | |
| 166 | TP_STRUCT__entry( |
Namhyung Kim | 9fdd8a8 | 2015-04-06 14:36:09 +0900 | [diff] [blame] | 167 | __field( unsigned long, pfn ) |
Mel Gorman | 4b4f278 | 2009-09-21 17:02:41 -0700 | [diff] [blame] | 168 | __field( unsigned int, order ) |
| 169 | ), |
| 170 | |
| 171 | TP_fast_assign( |
Namhyung Kim | 9fdd8a8 | 2015-04-06 14:36:09 +0900 | [diff] [blame] | 172 | __entry->pfn = page_to_pfn(page); |
Mel Gorman | 4b4f278 | 2009-09-21 17:02:41 -0700 | [diff] [blame] | 173 | __entry->order = order; |
| 174 | ), |
| 175 | |
Vincent Whitchurch | 53d884a | 2021-06-28 19:40:08 -0700 | [diff] [blame] | 176 | TP_printk("page=%p pfn=0x%lx order=%d", |
Namhyung Kim | 9fdd8a8 | 2015-04-06 14:36:09 +0900 | [diff] [blame] | 177 | pfn_to_page(__entry->pfn), |
| 178 | __entry->pfn, |
Mel Gorman | 4b4f278 | 2009-09-21 17:02:41 -0700 | [diff] [blame] | 179 | __entry->order) |
| 180 | ); |
| 181 | |
Konstantin Khlebnikov | b413d48 | 2012-01-10 15:07:09 -0800 | [diff] [blame] | 182 | TRACE_EVENT(mm_page_free_batched, |
Mel Gorman | 4b4f278 | 2009-09-21 17:02:41 -0700 | [diff] [blame] | 183 | |
Mel Gorman | 2d4894b | 2017-11-15 17:37:59 -0800 | [diff] [blame] | 184 | TP_PROTO(struct page *page), |
Mel Gorman | 4b4f278 | 2009-09-21 17:02:41 -0700 | [diff] [blame] | 185 | |
Mel Gorman | 2d4894b | 2017-11-15 17:37:59 -0800 | [diff] [blame] | 186 | TP_ARGS(page), |
Mel Gorman | 4b4f278 | 2009-09-21 17:02:41 -0700 | [diff] [blame] | 187 | |
| 188 | TP_STRUCT__entry( |
Namhyung Kim | 9fdd8a8 | 2015-04-06 14:36:09 +0900 | [diff] [blame] | 189 | __field( unsigned long, pfn ) |
Mel Gorman | 4b4f278 | 2009-09-21 17:02:41 -0700 | [diff] [blame] | 190 | ), |
| 191 | |
| 192 | TP_fast_assign( |
Namhyung Kim | 9fdd8a8 | 2015-04-06 14:36:09 +0900 | [diff] [blame] | 193 | __entry->pfn = page_to_pfn(page); |
Mel Gorman | 4b4f278 | 2009-09-21 17:02:41 -0700 | [diff] [blame] | 194 | ), |
| 195 | |
Vincent Whitchurch | 53d884a | 2021-06-28 19:40:08 -0700 | [diff] [blame] | 196 | TP_printk("page=%p pfn=0x%lx order=0", |
Namhyung Kim | 9fdd8a8 | 2015-04-06 14:36:09 +0900 | [diff] [blame] | 197 | pfn_to_page(__entry->pfn), |
Mel Gorman | 2d4894b | 2017-11-15 17:37:59 -0800 | [diff] [blame] | 198 | __entry->pfn) |
Mel Gorman | 4b4f278 | 2009-09-21 17:02:41 -0700 | [diff] [blame] | 199 | ); |
| 200 | |
| 201 | TRACE_EVENT(mm_page_alloc, |
| 202 | |
| 203 | TP_PROTO(struct page *page, unsigned int order, |
| 204 | gfp_t gfp_flags, int migratetype), |
| 205 | |
| 206 | TP_ARGS(page, order, gfp_flags, migratetype), |
| 207 | |
| 208 | TP_STRUCT__entry( |
Namhyung Kim | 9fdd8a8 | 2015-04-06 14:36:09 +0900 | [diff] [blame] | 209 | __field( unsigned long, pfn ) |
Mel Gorman | 4b4f278 | 2009-09-21 17:02:41 -0700 | [diff] [blame] | 210 | __field( unsigned int, order ) |
| 211 | __field( gfp_t, gfp_flags ) |
| 212 | __field( int, migratetype ) |
| 213 | ), |
| 214 | |
| 215 | TP_fast_assign( |
Namhyung Kim | 9fdd8a8 | 2015-04-06 14:36:09 +0900 | [diff] [blame] | 216 | __entry->pfn = page ? page_to_pfn(page) : -1UL; |
Mel Gorman | 4b4f278 | 2009-09-21 17:02:41 -0700 | [diff] [blame] | 217 | __entry->order = order; |
| 218 | __entry->gfp_flags = gfp_flags; |
| 219 | __entry->migratetype = migratetype; |
| 220 | ), |
| 221 | |
Vincent Whitchurch | 53d884a | 2021-06-28 19:40:08 -0700 | [diff] [blame] | 222 | TP_printk("page=%p pfn=0x%lx order=%d migratetype=%d gfp_flags=%s", |
Namhyung Kim | 9fdd8a8 | 2015-04-06 14:36:09 +0900 | [diff] [blame] | 223 | __entry->pfn != -1UL ? pfn_to_page(__entry->pfn) : NULL, |
| 224 | __entry->pfn != -1UL ? __entry->pfn : 0, |
Mel Gorman | 4b4f278 | 2009-09-21 17:02:41 -0700 | [diff] [blame] | 225 | __entry->order, |
| 226 | __entry->migratetype, |
| 227 | show_gfp_flags(__entry->gfp_flags)) |
| 228 | ); |
| 229 | |
Li Zefan | 53d0422 | 2009-11-26 15:04:10 +0800 | [diff] [blame] | 230 | DECLARE_EVENT_CLASS(mm_page, |
Mel Gorman | 0d3d062 | 2009-09-21 17:02:44 -0700 | [diff] [blame] | 231 | |
| 232 | TP_PROTO(struct page *page, unsigned int order, int migratetype), |
| 233 | |
| 234 | TP_ARGS(page, order, migratetype), |
| 235 | |
| 236 | TP_STRUCT__entry( |
Namhyung Kim | 9fdd8a8 | 2015-04-06 14:36:09 +0900 | [diff] [blame] | 237 | __field( unsigned long, pfn ) |
Mel Gorman | 0d3d062 | 2009-09-21 17:02:44 -0700 | [diff] [blame] | 238 | __field( unsigned int, order ) |
| 239 | __field( int, migratetype ) |
| 240 | ), |
| 241 | |
| 242 | TP_fast_assign( |
Namhyung Kim | 9fdd8a8 | 2015-04-06 14:36:09 +0900 | [diff] [blame] | 243 | __entry->pfn = page ? page_to_pfn(page) : -1UL; |
Mel Gorman | 0d3d062 | 2009-09-21 17:02:44 -0700 | [diff] [blame] | 244 | __entry->order = order; |
| 245 | __entry->migratetype = migratetype; |
| 246 | ), |
| 247 | |
Vincent Whitchurch | 53d884a | 2021-06-28 19:40:08 -0700 | [diff] [blame] | 248 | TP_printk("page=%p pfn=0x%lx order=%u migratetype=%d percpu_refill=%d", |
Namhyung Kim | 9fdd8a8 | 2015-04-06 14:36:09 +0900 | [diff] [blame] | 249 | __entry->pfn != -1UL ? pfn_to_page(__entry->pfn) : NULL, |
| 250 | __entry->pfn != -1UL ? __entry->pfn : 0, |
Mel Gorman | 0d3d062 | 2009-09-21 17:02:44 -0700 | [diff] [blame] | 251 | __entry->order, |
| 252 | __entry->migratetype, |
| 253 | __entry->order == 0) |
| 254 | ); |
| 255 | |
Li Zefan | 53d0422 | 2009-11-26 15:04:10 +0800 | [diff] [blame] | 256 | DEFINE_EVENT(mm_page, mm_page_alloc_zone_locked, |
Mel Gorman | 0d3d062 | 2009-09-21 17:02:44 -0700 | [diff] [blame] | 257 | |
Li Zefan | 53d0422 | 2009-11-26 15:04:10 +0800 | [diff] [blame] | 258 | TP_PROTO(struct page *page, unsigned int order, int migratetype), |
| 259 | |
| 260 | TP_ARGS(page, order, migratetype) |
| 261 | ); |
| 262 | |
Steven Rostedt (Red Hat) | 633f6f5 | 2016-02-19 13:59:54 -0500 | [diff] [blame] | 263 | TRACE_EVENT(mm_page_pcpu_drain, |
Li Zefan | 53d0422 | 2009-11-26 15:04:10 +0800 | [diff] [blame] | 264 | |
| 265 | TP_PROTO(struct page *page, unsigned int order, int migratetype), |
Mel Gorman | 0d3d062 | 2009-09-21 17:02:44 -0700 | [diff] [blame] | 266 | |
| 267 | TP_ARGS(page, order, migratetype), |
| 268 | |
Shreyas B. Prabhu | 649b8de | 2015-05-28 15:44:22 -0700 | [diff] [blame] | 269 | TP_STRUCT__entry( |
| 270 | __field( unsigned long, pfn ) |
| 271 | __field( unsigned int, order ) |
| 272 | __field( int, migratetype ) |
| 273 | ), |
| 274 | |
| 275 | TP_fast_assign( |
| 276 | __entry->pfn = page ? page_to_pfn(page) : -1UL; |
| 277 | __entry->order = order; |
| 278 | __entry->migratetype = migratetype; |
| 279 | ), |
| 280 | |
Vincent Whitchurch | 53d884a | 2021-06-28 19:40:08 -0700 | [diff] [blame] | 281 | TP_printk("page=%p pfn=0x%lx order=%d migratetype=%d", |
Namhyung Kim | 9fdd8a8 | 2015-04-06 14:36:09 +0900 | [diff] [blame] | 282 | pfn_to_page(__entry->pfn), __entry->pfn, |
Li Zefan | 53d0422 | 2009-11-26 15:04:10 +0800 | [diff] [blame] | 283 | __entry->order, __entry->migratetype) |
Mel Gorman | 0d3d062 | 2009-09-21 17:02:44 -0700 | [diff] [blame] | 284 | ); |
| 285 | |
Mel Gorman | e0fff1b | 2009-09-21 17:02:42 -0700 | [diff] [blame] | 286 | TRACE_EVENT(mm_page_alloc_extfrag, |
| 287 | |
| 288 | TP_PROTO(struct page *page, |
KOSAKI Motohiro | 52c8f6a | 2013-11-12 15:08:19 -0800 | [diff] [blame] | 289 | int alloc_order, int fallback_order, |
Vlastimil Babka | 99592d5 | 2015-02-11 15:28:15 -0800 | [diff] [blame] | 290 | int alloc_migratetype, int fallback_migratetype), |
Mel Gorman | e0fff1b | 2009-09-21 17:02:42 -0700 | [diff] [blame] | 291 | |
| 292 | TP_ARGS(page, |
| 293 | alloc_order, fallback_order, |
Vlastimil Babka | 99592d5 | 2015-02-11 15:28:15 -0800 | [diff] [blame] | 294 | alloc_migratetype, fallback_migratetype), |
Mel Gorman | e0fff1b | 2009-09-21 17:02:42 -0700 | [diff] [blame] | 295 | |
| 296 | TP_STRUCT__entry( |
Namhyung Kim | 9fdd8a8 | 2015-04-06 14:36:09 +0900 | [diff] [blame] | 297 | __field( unsigned long, pfn ) |
Mel Gorman | e0fff1b | 2009-09-21 17:02:42 -0700 | [diff] [blame] | 298 | __field( int, alloc_order ) |
| 299 | __field( int, fallback_order ) |
| 300 | __field( int, alloc_migratetype ) |
| 301 | __field( int, fallback_migratetype ) |
Srivatsa S. Bhat | f92310c | 2013-09-11 14:20:36 -0700 | [diff] [blame] | 302 | __field( int, change_ownership ) |
Mel Gorman | e0fff1b | 2009-09-21 17:02:42 -0700 | [diff] [blame] | 303 | ), |
| 304 | |
| 305 | TP_fast_assign( |
Namhyung Kim | 9fdd8a8 | 2015-04-06 14:36:09 +0900 | [diff] [blame] | 306 | __entry->pfn = page_to_pfn(page); |
Mel Gorman | e0fff1b | 2009-09-21 17:02:42 -0700 | [diff] [blame] | 307 | __entry->alloc_order = alloc_order; |
| 308 | __entry->fallback_order = fallback_order; |
| 309 | __entry->alloc_migratetype = alloc_migratetype; |
| 310 | __entry->fallback_migratetype = fallback_migratetype; |
Vlastimil Babka | 99592d5 | 2015-02-11 15:28:15 -0800 | [diff] [blame] | 311 | __entry->change_ownership = (alloc_migratetype == |
| 312 | get_pageblock_migratetype(page)); |
Mel Gorman | e0fff1b | 2009-09-21 17:02:42 -0700 | [diff] [blame] | 313 | ), |
| 314 | |
Vincent Whitchurch | 53d884a | 2021-06-28 19:40:08 -0700 | [diff] [blame] | 315 | TP_printk("page=%p pfn=0x%lx alloc_order=%d fallback_order=%d pageblock_order=%d alloc_migratetype=%d fallback_migratetype=%d fragmenting=%d change_ownership=%d", |
Namhyung Kim | 9fdd8a8 | 2015-04-06 14:36:09 +0900 | [diff] [blame] | 316 | pfn_to_page(__entry->pfn), |
| 317 | __entry->pfn, |
Mel Gorman | e0fff1b | 2009-09-21 17:02:42 -0700 | [diff] [blame] | 318 | __entry->alloc_order, |
| 319 | __entry->fallback_order, |
| 320 | pageblock_order, |
| 321 | __entry->alloc_migratetype, |
| 322 | __entry->fallback_migratetype, |
| 323 | __entry->fallback_order < pageblock_order, |
Srivatsa S. Bhat | f92310c | 2013-09-11 14:20:36 -0700 | [diff] [blame] | 324 | __entry->change_ownership) |
Mel Gorman | e0fff1b | 2009-09-21 17:02:42 -0700 | [diff] [blame] | 325 | ); |
| 326 | |
Joel Fernandes (Google) | e4dcad2 | 2019-11-30 17:50:33 -0800 | [diff] [blame] | 327 | /* |
| 328 | * Required for uniquely and securely identifying mm in rss_stat tracepoint. |
| 329 | */ |
| 330 | #ifndef __PTR_TO_HASHVAL |
| 331 | static unsigned int __maybe_unused mm_ptr_to_hash(const void *ptr) |
| 332 | { |
| 333 | int ret; |
| 334 | unsigned long hashval; |
| 335 | |
| 336 | ret = ptr_to_hashval(ptr, &hashval); |
| 337 | if (ret) |
| 338 | return 0; |
| 339 | |
| 340 | /* The hashed value is only 32-bit */ |
| 341 | return (unsigned int)hashval; |
| 342 | } |
| 343 | #define __PTR_TO_HASHVAL |
| 344 | #endif |
| 345 | |
Ovidiu Panait | f900110 | 2021-04-29 22:57:26 -0700 | [diff] [blame] | 346 | #define TRACE_MM_PAGES \ |
| 347 | EM(MM_FILEPAGES) \ |
| 348 | EM(MM_ANONPAGES) \ |
| 349 | EM(MM_SWAPENTS) \ |
| 350 | EMe(MM_SHMEMPAGES) |
| 351 | |
| 352 | #undef EM |
| 353 | #undef EMe |
| 354 | |
| 355 | #define EM(a) TRACE_DEFINE_ENUM(a); |
| 356 | #define EMe(a) TRACE_DEFINE_ENUM(a); |
| 357 | |
| 358 | TRACE_MM_PAGES |
| 359 | |
| 360 | #undef EM |
| 361 | #undef EMe |
| 362 | |
| 363 | #define EM(a) { a, #a }, |
| 364 | #define EMe(a) { a, #a } |
| 365 | |
Joel Fernandes (Google) | b3d1411 | 2019-11-30 17:50:30 -0800 | [diff] [blame] | 366 | TRACE_EVENT(rss_stat, |
| 367 | |
Joel Fernandes (Google) | e4dcad2 | 2019-11-30 17:50:33 -0800 | [diff] [blame] | 368 | TP_PROTO(struct mm_struct *mm, |
| 369 | int member, |
Joel Fernandes (Google) | b3d1411 | 2019-11-30 17:50:30 -0800 | [diff] [blame] | 370 | long count), |
| 371 | |
Joel Fernandes (Google) | e4dcad2 | 2019-11-30 17:50:33 -0800 | [diff] [blame] | 372 | TP_ARGS(mm, member, count), |
Joel Fernandes (Google) | b3d1411 | 2019-11-30 17:50:30 -0800 | [diff] [blame] | 373 | |
| 374 | TP_STRUCT__entry( |
Joel Fernandes (Google) | e4dcad2 | 2019-11-30 17:50:33 -0800 | [diff] [blame] | 375 | __field(unsigned int, mm_id) |
| 376 | __field(unsigned int, curr) |
Joel Fernandes (Google) | b3d1411 | 2019-11-30 17:50:30 -0800 | [diff] [blame] | 377 | __field(int, member) |
| 378 | __field(long, size) |
| 379 | ), |
| 380 | |
| 381 | TP_fast_assign( |
Joel Fernandes (Google) | e4dcad2 | 2019-11-30 17:50:33 -0800 | [diff] [blame] | 382 | __entry->mm_id = mm_ptr_to_hash(mm); |
| 383 | __entry->curr = !!(current->mm == mm); |
Joel Fernandes (Google) | b3d1411 | 2019-11-30 17:50:30 -0800 | [diff] [blame] | 384 | __entry->member = member; |
| 385 | __entry->size = (count << PAGE_SHIFT); |
| 386 | ), |
| 387 | |
Ovidiu Panait | f900110 | 2021-04-29 22:57:26 -0700 | [diff] [blame] | 388 | TP_printk("mm_id=%u curr=%d type=%s size=%ldB", |
Joel Fernandes (Google) | e4dcad2 | 2019-11-30 17:50:33 -0800 | [diff] [blame] | 389 | __entry->mm_id, |
| 390 | __entry->curr, |
Ovidiu Panait | f900110 | 2021-04-29 22:57:26 -0700 | [diff] [blame] | 391 | __print_symbolic(__entry->member, TRACE_MM_PAGES), |
Joel Fernandes (Google) | b3d1411 | 2019-11-30 17:50:30 -0800 | [diff] [blame] | 392 | __entry->size) |
| 393 | ); |
Steven Rostedt | a8d154b | 2009-04-10 09:36:00 -0400 | [diff] [blame] | 394 | #endif /* _TRACE_KMEM_H */ |
Steven Rostedt | ea20d92 | 2009-04-10 08:54:16 -0400 | [diff] [blame] | 395 | |
Steven Rostedt | a8d154b | 2009-04-10 09:36:00 -0400 | [diff] [blame] | 396 | /* This part must be outside protection */ |
| 397 | #include <trace/define_trace.h> |