1d0b6e04aSLi Zefan #undef TRACE_SYSTEM 2d0b6e04aSLi Zefan #define TRACE_SYSTEM kmem 3d0b6e04aSLi Zefan 4ad8d75ffSSteven Rostedt #if !defined(_TRACE_KMEM_H) || defined(TRACE_HEADER_MULTI_READ) 5ad8d75ffSSteven Rostedt #define _TRACE_KMEM_H 6ad8d75ffSSteven Rostedt 7ad8d75ffSSteven Rostedt #include <linux/types.h> 8ad8d75ffSSteven Rostedt #include <linux/tracepoint.h> 9a1ce3928SDavid Howells #include <trace/events/gfpflags.h> 1062ba180eSSteven Rostedt 1153d0422cSLi Zefan DECLARE_EVENT_CLASS(kmem_alloc, 12ad8d75ffSSteven Rostedt 13ad8d75ffSSteven Rostedt TP_PROTO(unsigned long call_site, 14ad8d75ffSSteven Rostedt const void *ptr, 15ad8d75ffSSteven Rostedt size_t bytes_req, 16ad8d75ffSSteven Rostedt size_t bytes_alloc, 17ad8d75ffSSteven Rostedt gfp_t gfp_flags), 18ad8d75ffSSteven Rostedt 19ad8d75ffSSteven Rostedt TP_ARGS(call_site, ptr, bytes_req, bytes_alloc, gfp_flags), 20ad8d75ffSSteven Rostedt 21ad8d75ffSSteven Rostedt TP_STRUCT__entry( 22ad8d75ffSSteven Rostedt __field( unsigned long, call_site ) 23ad8d75ffSSteven Rostedt __field( const void *, ptr ) 24ad8d75ffSSteven Rostedt __field( size_t, bytes_req ) 25ad8d75ffSSteven Rostedt __field( size_t, bytes_alloc ) 26ad8d75ffSSteven Rostedt __field( gfp_t, gfp_flags ) 27ad8d75ffSSteven Rostedt ), 28ad8d75ffSSteven Rostedt 29ad8d75ffSSteven Rostedt TP_fast_assign( 30ad8d75ffSSteven Rostedt __entry->call_site = call_site; 31ad8d75ffSSteven Rostedt __entry->ptr = ptr; 32ad8d75ffSSteven Rostedt __entry->bytes_req = bytes_req; 33ad8d75ffSSteven Rostedt __entry->bytes_alloc = bytes_alloc; 34ad8d75ffSSteven Rostedt __entry->gfp_flags = gfp_flags; 35ad8d75ffSSteven Rostedt ), 36ad8d75ffSSteven Rostedt 3762ba180eSSteven Rostedt TP_printk("call_site=%lx ptr=%p bytes_req=%zu bytes_alloc=%zu gfp_flags=%s", 38ad8d75ffSSteven Rostedt __entry->call_site, 39ad8d75ffSSteven Rostedt __entry->ptr, 40ad8d75ffSSteven Rostedt __entry->bytes_req, 41ad8d75ffSSteven Rostedt __entry->bytes_alloc, 4262ba180eSSteven Rostedt show_gfp_flags(__entry->gfp_flags)) 43ad8d75ffSSteven Rostedt ); 44ad8d75ffSSteven Rostedt 4553d0422cSLi Zefan DEFINE_EVENT(kmem_alloc, kmalloc, 46ad8d75ffSSteven Rostedt 4753d0422cSLi Zefan TP_PROTO(unsigned long call_site, const void *ptr, 4853d0422cSLi Zefan size_t bytes_req, size_t bytes_alloc, gfp_t gfp_flags), 49ad8d75ffSSteven Rostedt 5053d0422cSLi Zefan TP_ARGS(call_site, ptr, bytes_req, bytes_alloc, gfp_flags) 51ad8d75ffSSteven Rostedt ); 52ad8d75ffSSteven Rostedt 5353d0422cSLi Zefan DEFINE_EVENT(kmem_alloc, kmem_cache_alloc, 5453d0422cSLi Zefan 5553d0422cSLi Zefan TP_PROTO(unsigned long call_site, const void *ptr, 5653d0422cSLi Zefan size_t bytes_req, size_t bytes_alloc, gfp_t gfp_flags), 5753d0422cSLi Zefan 5853d0422cSLi Zefan TP_ARGS(call_site, ptr, bytes_req, bytes_alloc, gfp_flags) 5953d0422cSLi Zefan ); 6053d0422cSLi Zefan 6153d0422cSLi Zefan DECLARE_EVENT_CLASS(kmem_alloc_node, 62ad8d75ffSSteven Rostedt 63ad8d75ffSSteven Rostedt TP_PROTO(unsigned long call_site, 64ad8d75ffSSteven Rostedt const void *ptr, 65ad8d75ffSSteven Rostedt size_t bytes_req, 66ad8d75ffSSteven Rostedt size_t bytes_alloc, 67ad8d75ffSSteven Rostedt gfp_t gfp_flags, 68ad8d75ffSSteven Rostedt int node), 69ad8d75ffSSteven Rostedt 70ad8d75ffSSteven Rostedt TP_ARGS(call_site, ptr, bytes_req, bytes_alloc, gfp_flags, node), 71ad8d75ffSSteven Rostedt 72ad8d75ffSSteven Rostedt TP_STRUCT__entry( 73ad8d75ffSSteven Rostedt __field( unsigned long, call_site ) 74ad8d75ffSSteven Rostedt __field( const void *, ptr ) 75ad8d75ffSSteven Rostedt __field( size_t, bytes_req ) 76ad8d75ffSSteven Rostedt __field( size_t, bytes_alloc ) 77ad8d75ffSSteven Rostedt __field( gfp_t, gfp_flags ) 78ad8d75ffSSteven Rostedt __field( int, node ) 79ad8d75ffSSteven Rostedt ), 80ad8d75ffSSteven Rostedt 81ad8d75ffSSteven Rostedt TP_fast_assign( 82ad8d75ffSSteven Rostedt __entry->call_site = call_site; 83ad8d75ffSSteven Rostedt __entry->ptr = ptr; 84ad8d75ffSSteven Rostedt __entry->bytes_req = bytes_req; 85ad8d75ffSSteven Rostedt __entry->bytes_alloc = bytes_alloc; 86ad8d75ffSSteven Rostedt __entry->gfp_flags = gfp_flags; 87ad8d75ffSSteven Rostedt __entry->node = node; 88ad8d75ffSSteven Rostedt ), 89ad8d75ffSSteven Rostedt 9062ba180eSSteven Rostedt TP_printk("call_site=%lx ptr=%p bytes_req=%zu bytes_alloc=%zu gfp_flags=%s node=%d", 91ad8d75ffSSteven Rostedt __entry->call_site, 92ad8d75ffSSteven Rostedt __entry->ptr, 93ad8d75ffSSteven Rostedt __entry->bytes_req, 94ad8d75ffSSteven Rostedt __entry->bytes_alloc, 9562ba180eSSteven Rostedt show_gfp_flags(__entry->gfp_flags), 96ad8d75ffSSteven Rostedt __entry->node) 97ad8d75ffSSteven Rostedt ); 98ad8d75ffSSteven Rostedt 9953d0422cSLi Zefan DEFINE_EVENT(kmem_alloc_node, kmalloc_node, 100ad8d75ffSSteven Rostedt 10153d0422cSLi Zefan TP_PROTO(unsigned long call_site, const void *ptr, 10253d0422cSLi Zefan size_t bytes_req, size_t bytes_alloc, 10353d0422cSLi Zefan gfp_t gfp_flags, int node), 104ad8d75ffSSteven Rostedt 10553d0422cSLi Zefan TP_ARGS(call_site, ptr, bytes_req, bytes_alloc, gfp_flags, node) 106ad8d75ffSSteven Rostedt ); 107ad8d75ffSSteven Rostedt 10853d0422cSLi Zefan DEFINE_EVENT(kmem_alloc_node, kmem_cache_alloc_node, 10953d0422cSLi Zefan 11053d0422cSLi Zefan TP_PROTO(unsigned long call_site, const void *ptr, 11153d0422cSLi Zefan size_t bytes_req, size_t bytes_alloc, 11253d0422cSLi Zefan gfp_t gfp_flags, int node), 11353d0422cSLi Zefan 11453d0422cSLi Zefan TP_ARGS(call_site, ptr, bytes_req, bytes_alloc, gfp_flags, node) 11553d0422cSLi Zefan ); 11653d0422cSLi Zefan 11753d0422cSLi Zefan DECLARE_EVENT_CLASS(kmem_free, 118ad8d75ffSSteven Rostedt 119ad8d75ffSSteven Rostedt TP_PROTO(unsigned long call_site, const void *ptr), 120ad8d75ffSSteven Rostedt 121ad8d75ffSSteven Rostedt TP_ARGS(call_site, ptr), 122ad8d75ffSSteven Rostedt 123ad8d75ffSSteven Rostedt TP_STRUCT__entry( 124ad8d75ffSSteven Rostedt __field( unsigned long, call_site ) 125ad8d75ffSSteven Rostedt __field( const void *, ptr ) 126ad8d75ffSSteven Rostedt ), 127ad8d75ffSSteven Rostedt 128ad8d75ffSSteven Rostedt TP_fast_assign( 129ad8d75ffSSteven Rostedt __entry->call_site = call_site; 130ad8d75ffSSteven Rostedt __entry->ptr = ptr; 131ad8d75ffSSteven Rostedt ), 132ad8d75ffSSteven Rostedt 133ad8d75ffSSteven Rostedt TP_printk("call_site=%lx ptr=%p", __entry->call_site, __entry->ptr) 134ad8d75ffSSteven Rostedt ); 135ad8d75ffSSteven Rostedt 13653d0422cSLi Zefan DEFINE_EVENT(kmem_free, kfree, 137ad8d75ffSSteven Rostedt 138ad8d75ffSSteven Rostedt TP_PROTO(unsigned long call_site, const void *ptr), 139ad8d75ffSSteven Rostedt 14053d0422cSLi Zefan TP_ARGS(call_site, ptr) 14153d0422cSLi Zefan ); 142ad8d75ffSSteven Rostedt 143e5feb1ebSShreyas B. Prabhu DEFINE_EVENT_CONDITION(kmem_free, kmem_cache_free, 144ad8d75ffSSteven Rostedt 14553d0422cSLi Zefan TP_PROTO(unsigned long call_site, const void *ptr), 146ad8d75ffSSteven Rostedt 147e5feb1ebSShreyas B. Prabhu TP_ARGS(call_site, ptr), 148e5feb1ebSShreyas B. Prabhu 149e5feb1ebSShreyas B. Prabhu /* 150e5feb1ebSShreyas B. Prabhu * This trace can be potentially called from an offlined cpu. 151e5feb1ebSShreyas B. Prabhu * Since trace points use RCU and RCU should not be used from 152e5feb1ebSShreyas B. Prabhu * offline cpus, filter such calls out. 153e5feb1ebSShreyas B. Prabhu * While this trace can be called from a preemptable section, 154e5feb1ebSShreyas B. Prabhu * it has no impact on the condition since tasks can migrate 155e5feb1ebSShreyas B. Prabhu * only from online cpus to other online cpus. Thus its safe 156e5feb1ebSShreyas B. Prabhu * to use raw_smp_processor_id. 157e5feb1ebSShreyas B. Prabhu */ 158e5feb1ebSShreyas B. Prabhu TP_CONDITION(cpu_online(raw_smp_processor_id())) 159ad8d75ffSSteven Rostedt ); 1604b4f278cSMel Gorman 1611f0c27b5SShreyas B. Prabhu TRACE_EVENT_CONDITION(mm_page_free, 1624b4f278cSMel Gorman 1634b4f278cSMel Gorman TP_PROTO(struct page *page, unsigned int order), 1644b4f278cSMel Gorman 1654b4f278cSMel Gorman TP_ARGS(page, order), 1664b4f278cSMel Gorman 1671f0c27b5SShreyas B. Prabhu 1681f0c27b5SShreyas B. Prabhu /* 1691f0c27b5SShreyas B. Prabhu * This trace can be potentially called from an offlined cpu. 1701f0c27b5SShreyas B. Prabhu * Since trace points use RCU and RCU should not be used from 1711f0c27b5SShreyas B. Prabhu * offline cpus, filter such calls out. 1721f0c27b5SShreyas B. Prabhu * While this trace can be called from a preemptable section, 1731f0c27b5SShreyas B. Prabhu * it has no impact on the condition since tasks can migrate 1741f0c27b5SShreyas B. Prabhu * only from online cpus to other online cpus. Thus its safe 1751f0c27b5SShreyas B. Prabhu * to use raw_smp_processor_id. 1761f0c27b5SShreyas B. Prabhu */ 1771f0c27b5SShreyas B. Prabhu TP_CONDITION(cpu_online(raw_smp_processor_id())), 1781f0c27b5SShreyas B. Prabhu 1794b4f278cSMel Gorman TP_STRUCT__entry( 1809fdd8a87SNamhyung Kim __field( unsigned long, pfn ) 1814b4f278cSMel Gorman __field( unsigned int, order ) 1824b4f278cSMel Gorman ), 1834b4f278cSMel Gorman 1844b4f278cSMel Gorman TP_fast_assign( 1859fdd8a87SNamhyung Kim __entry->pfn = page_to_pfn(page); 1864b4f278cSMel Gorman __entry->order = order; 1874b4f278cSMel Gorman ), 1884b4f278cSMel Gorman 1894b4f278cSMel Gorman TP_printk("page=%p pfn=%lu order=%d", 1909fdd8a87SNamhyung Kim pfn_to_page(__entry->pfn), 1919fdd8a87SNamhyung Kim __entry->pfn, 1924b4f278cSMel Gorman __entry->order) 1934b4f278cSMel Gorman ); 1944b4f278cSMel Gorman 195b413d48aSKonstantin Khlebnikov TRACE_EVENT(mm_page_free_batched, 1964b4f278cSMel Gorman 1974b4f278cSMel Gorman TP_PROTO(struct page *page, int cold), 1984b4f278cSMel Gorman 1994b4f278cSMel Gorman TP_ARGS(page, cold), 2004b4f278cSMel Gorman 2014b4f278cSMel Gorman TP_STRUCT__entry( 2029fdd8a87SNamhyung Kim __field( unsigned long, pfn ) 2034b4f278cSMel Gorman __field( int, cold ) 2044b4f278cSMel Gorman ), 2054b4f278cSMel Gorman 2064b4f278cSMel Gorman TP_fast_assign( 2079fdd8a87SNamhyung Kim __entry->pfn = page_to_pfn(page); 2084b4f278cSMel Gorman __entry->cold = cold; 2094b4f278cSMel Gorman ), 2104b4f278cSMel Gorman 2114b4f278cSMel Gorman TP_printk("page=%p pfn=%lu order=0 cold=%d", 2129fdd8a87SNamhyung Kim pfn_to_page(__entry->pfn), 2139fdd8a87SNamhyung Kim __entry->pfn, 2144b4f278cSMel Gorman __entry->cold) 2154b4f278cSMel Gorman ); 2164b4f278cSMel Gorman 2174b4f278cSMel Gorman TRACE_EVENT(mm_page_alloc, 2184b4f278cSMel Gorman 2194b4f278cSMel Gorman TP_PROTO(struct page *page, unsigned int order, 2204b4f278cSMel Gorman gfp_t gfp_flags, int migratetype), 2214b4f278cSMel Gorman 2224b4f278cSMel Gorman TP_ARGS(page, order, gfp_flags, migratetype), 2234b4f278cSMel Gorman 2244b4f278cSMel Gorman TP_STRUCT__entry( 2259fdd8a87SNamhyung Kim __field( unsigned long, pfn ) 2264b4f278cSMel Gorman __field( unsigned int, order ) 2274b4f278cSMel Gorman __field( gfp_t, gfp_flags ) 2284b4f278cSMel Gorman __field( int, migratetype ) 2294b4f278cSMel Gorman ), 2304b4f278cSMel Gorman 2314b4f278cSMel Gorman TP_fast_assign( 2329fdd8a87SNamhyung Kim __entry->pfn = page ? page_to_pfn(page) : -1UL; 2334b4f278cSMel Gorman __entry->order = order; 2344b4f278cSMel Gorman __entry->gfp_flags = gfp_flags; 2354b4f278cSMel Gorman __entry->migratetype = migratetype; 2364b4f278cSMel Gorman ), 2374b4f278cSMel Gorman 2384b4f278cSMel Gorman TP_printk("page=%p pfn=%lu order=%d migratetype=%d gfp_flags=%s", 2399fdd8a87SNamhyung Kim __entry->pfn != -1UL ? pfn_to_page(__entry->pfn) : NULL, 2409fdd8a87SNamhyung Kim __entry->pfn != -1UL ? __entry->pfn : 0, 2414b4f278cSMel Gorman __entry->order, 2424b4f278cSMel Gorman __entry->migratetype, 2434b4f278cSMel Gorman show_gfp_flags(__entry->gfp_flags)) 2444b4f278cSMel Gorman ); 2454b4f278cSMel Gorman 24653d0422cSLi Zefan DECLARE_EVENT_CLASS(mm_page, 2470d3d062aSMel Gorman 2480d3d062aSMel Gorman TP_PROTO(struct page *page, unsigned int order, int migratetype), 2490d3d062aSMel Gorman 2500d3d062aSMel Gorman TP_ARGS(page, order, migratetype), 2510d3d062aSMel Gorman 2520d3d062aSMel Gorman TP_STRUCT__entry( 2539fdd8a87SNamhyung Kim __field( unsigned long, pfn ) 2540d3d062aSMel Gorman __field( unsigned int, order ) 2550d3d062aSMel Gorman __field( int, migratetype ) 2560d3d062aSMel Gorman ), 2570d3d062aSMel Gorman 2580d3d062aSMel Gorman TP_fast_assign( 2599fdd8a87SNamhyung Kim __entry->pfn = page ? page_to_pfn(page) : -1UL; 2600d3d062aSMel Gorman __entry->order = order; 2610d3d062aSMel Gorman __entry->migratetype = migratetype; 2620d3d062aSMel Gorman ), 2630d3d062aSMel Gorman 2640d3d062aSMel Gorman TP_printk("page=%p pfn=%lu order=%u migratetype=%d percpu_refill=%d", 2659fdd8a87SNamhyung Kim __entry->pfn != -1UL ? pfn_to_page(__entry->pfn) : NULL, 2669fdd8a87SNamhyung Kim __entry->pfn != -1UL ? __entry->pfn : 0, 2670d3d062aSMel Gorman __entry->order, 2680d3d062aSMel Gorman __entry->migratetype, 2690d3d062aSMel Gorman __entry->order == 0) 2700d3d062aSMel Gorman ); 2710d3d062aSMel Gorman 27253d0422cSLi Zefan DEFINE_EVENT(mm_page, mm_page_alloc_zone_locked, 2730d3d062aSMel Gorman 27453d0422cSLi Zefan TP_PROTO(struct page *page, unsigned int order, int migratetype), 27553d0422cSLi Zefan 27653d0422cSLi Zefan TP_ARGS(page, order, migratetype) 27753d0422cSLi Zefan ); 27853d0422cSLi Zefan 27953d0422cSLi Zefan DEFINE_EVENT_PRINT(mm_page, mm_page_pcpu_drain, 28053d0422cSLi Zefan 28153d0422cSLi Zefan TP_PROTO(struct page *page, unsigned int order, int migratetype), 2820d3d062aSMel Gorman 2830d3d062aSMel Gorman TP_ARGS(page, order, migratetype), 2840d3d062aSMel Gorman 2850d3d062aSMel Gorman TP_printk("page=%p pfn=%lu order=%d migratetype=%d", 2869fdd8a87SNamhyung Kim pfn_to_page(__entry->pfn), __entry->pfn, 28753d0422cSLi Zefan __entry->order, __entry->migratetype) 2880d3d062aSMel Gorman ); 2890d3d062aSMel Gorman 290e0fff1bdSMel Gorman TRACE_EVENT(mm_page_alloc_extfrag, 291e0fff1bdSMel Gorman 292e0fff1bdSMel Gorman TP_PROTO(struct page *page, 293e0fff1bdSMel Gorman int alloc_order, int fallback_order, 29499592d59SVlastimil Babka int alloc_migratetype, int fallback_migratetype), 295e0fff1bdSMel Gorman 296e0fff1bdSMel Gorman TP_ARGS(page, 297e0fff1bdSMel Gorman alloc_order, fallback_order, 29899592d59SVlastimil Babka alloc_migratetype, fallback_migratetype), 299e0fff1bdSMel Gorman 300e0fff1bdSMel Gorman TP_STRUCT__entry( 3019fdd8a87SNamhyung Kim __field( unsigned long, pfn ) 302e0fff1bdSMel Gorman __field( int, alloc_order ) 303e0fff1bdSMel Gorman __field( int, fallback_order ) 304e0fff1bdSMel Gorman __field( int, alloc_migratetype ) 305e0fff1bdSMel Gorman __field( int, fallback_migratetype ) 306f92310c1SSrivatsa S. Bhat __field( int, change_ownership ) 307e0fff1bdSMel Gorman ), 308e0fff1bdSMel Gorman 309e0fff1bdSMel Gorman TP_fast_assign( 3109fdd8a87SNamhyung Kim __entry->pfn = page_to_pfn(page); 311e0fff1bdSMel Gorman __entry->alloc_order = alloc_order; 312e0fff1bdSMel Gorman __entry->fallback_order = fallback_order; 313e0fff1bdSMel Gorman __entry->alloc_migratetype = alloc_migratetype; 314e0fff1bdSMel Gorman __entry->fallback_migratetype = fallback_migratetype; 31599592d59SVlastimil Babka __entry->change_ownership = (alloc_migratetype == 31699592d59SVlastimil Babka get_pageblock_migratetype(page)); 317e0fff1bdSMel Gorman ), 318e0fff1bdSMel Gorman 319e0fff1bdSMel Gorman 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", 3209fdd8a87SNamhyung Kim pfn_to_page(__entry->pfn), 3219fdd8a87SNamhyung Kim __entry->pfn, 322e0fff1bdSMel Gorman __entry->alloc_order, 323e0fff1bdSMel Gorman __entry->fallback_order, 324e0fff1bdSMel Gorman pageblock_order, 325e0fff1bdSMel Gorman __entry->alloc_migratetype, 326e0fff1bdSMel Gorman __entry->fallback_migratetype, 327e0fff1bdSMel Gorman __entry->fallback_order < pageblock_order, 328f92310c1SSrivatsa S. Bhat __entry->change_ownership) 329e0fff1bdSMel Gorman ); 330e0fff1bdSMel Gorman 331ad8d75ffSSteven Rostedt #endif /* _TRACE_KMEM_H */ 332ad8d75ffSSteven Rostedt 333ad8d75ffSSteven Rostedt /* This part must be outside protection */ 334ad8d75ffSSteven Rostedt #include <trace/define_trace.h> 335