^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1) /* SPDX-License-Identifier: GPL-2.0 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2) #undef TRACE_SYSTEM
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3) #define TRACE_SYSTEM kmem
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5) #if !defined(_TRACE_KMEM_H) || defined(TRACE_HEADER_MULTI_READ)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6) #define _TRACE_KMEM_H
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8) #include <linux/types.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9) #include <linux/tracepoint.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10) #include <trace/events/mmflags.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 12) DECLARE_EVENT_CLASS(kmem_alloc,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 13)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14) TP_PROTO(unsigned long call_site,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15) const void *ptr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 16) size_t bytes_req,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 17) size_t bytes_alloc,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 18) gfp_t gfp_flags),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 19)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20) TP_ARGS(call_site, ptr, bytes_req, bytes_alloc, gfp_flags),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 21)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 22) TP_STRUCT__entry(
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 23) __field( unsigned long, call_site )
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 24) __field( const void *, ptr )
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 25) __field( size_t, bytes_req )
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 26) __field( size_t, bytes_alloc )
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 27) __field( gfp_t, gfp_flags )
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 28) ),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 29)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 30) TP_fast_assign(
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 31) __entry->call_site = call_site;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 32) __entry->ptr = ptr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 33) __entry->bytes_req = bytes_req;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 34) __entry->bytes_alloc = bytes_alloc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 35) __entry->gfp_flags = gfp_flags;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 36) ),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 37)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 38) TP_printk("call_site=%pS ptr=%p bytes_req=%zu bytes_alloc=%zu gfp_flags=%s",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 39) (void *)__entry->call_site,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 40) __entry->ptr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 41) __entry->bytes_req,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 42) __entry->bytes_alloc,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 43) show_gfp_flags(__entry->gfp_flags))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 44) );
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 45)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 46) DEFINE_EVENT(kmem_alloc, kmalloc,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 47)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 48) TP_PROTO(unsigned long call_site, const void *ptr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 49) size_t bytes_req, size_t bytes_alloc, gfp_t gfp_flags),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 50)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 51) TP_ARGS(call_site, ptr, bytes_req, bytes_alloc, gfp_flags)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 52) );
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 53)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 54) DEFINE_EVENT(kmem_alloc, kmem_cache_alloc,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 55)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 56) TP_PROTO(unsigned long call_site, const void *ptr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 57) size_t bytes_req, size_t bytes_alloc, gfp_t gfp_flags),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 58)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 59) TP_ARGS(call_site, ptr, bytes_req, bytes_alloc, gfp_flags)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 60) );
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 61)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 62) DECLARE_EVENT_CLASS(kmem_alloc_node,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 63)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 64) TP_PROTO(unsigned long call_site,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 65) const void *ptr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 66) size_t bytes_req,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 67) size_t bytes_alloc,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 68) gfp_t gfp_flags,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 69) int node),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 70)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 71) TP_ARGS(call_site, ptr, bytes_req, bytes_alloc, gfp_flags, node),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 72)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 73) TP_STRUCT__entry(
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 74) __field( unsigned long, call_site )
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 75) __field( const void *, ptr )
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 76) __field( size_t, bytes_req )
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 77) __field( size_t, bytes_alloc )
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 78) __field( gfp_t, gfp_flags )
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 79) __field( int, node )
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 80) ),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 81)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 82) TP_fast_assign(
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 83) __entry->call_site = call_site;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 84) __entry->ptr = ptr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 85) __entry->bytes_req = bytes_req;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 86) __entry->bytes_alloc = bytes_alloc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 87) __entry->gfp_flags = gfp_flags;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 88) __entry->node = node;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 89) ),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 90)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 91) TP_printk("call_site=%pS ptr=%p bytes_req=%zu bytes_alloc=%zu gfp_flags=%s node=%d",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 92) (void *)__entry->call_site,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 93) __entry->ptr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 94) __entry->bytes_req,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 95) __entry->bytes_alloc,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 96) show_gfp_flags(__entry->gfp_flags),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 97) __entry->node)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 98) );
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 99)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100) DEFINE_EVENT(kmem_alloc_node, kmalloc_node,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102) TP_PROTO(unsigned long call_site, const void *ptr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103) size_t bytes_req, size_t bytes_alloc,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104) gfp_t gfp_flags, int node),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 105)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 106) TP_ARGS(call_site, ptr, bytes_req, bytes_alloc, gfp_flags, node)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 107) );
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 108)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 109) DEFINE_EVENT(kmem_alloc_node, kmem_cache_alloc_node,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 110)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 111) TP_PROTO(unsigned long call_site, const void *ptr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 112) size_t bytes_req, size_t bytes_alloc,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 113) gfp_t gfp_flags, int node),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 114)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 115) TP_ARGS(call_site, ptr, bytes_req, bytes_alloc, gfp_flags, node)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 116) );
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 117)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 118) DECLARE_EVENT_CLASS(kmem_free,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 119)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 120) TP_PROTO(unsigned long call_site, const void *ptr),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 121)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 122) TP_ARGS(call_site, ptr),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 123)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 124) TP_STRUCT__entry(
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 125) __field( unsigned long, call_site )
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 126) __field( const void *, ptr )
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 127) ),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 128)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 129) TP_fast_assign(
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 130) __entry->call_site = call_site;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 131) __entry->ptr = ptr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 132) ),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 133)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 134) TP_printk("call_site=%pS ptr=%p",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 135) (void *)__entry->call_site, __entry->ptr)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 136) );
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 137)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 138) DEFINE_EVENT(kmem_free, kfree,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 139)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 140) TP_PROTO(unsigned long call_site, const void *ptr),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 141)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 142) TP_ARGS(call_site, ptr)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 143) );
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 144)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 145) DEFINE_EVENT(kmem_free, kmem_cache_free,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 146)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 147) TP_PROTO(unsigned long call_site, const void *ptr),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 148)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 149) TP_ARGS(call_site, ptr)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 150) );
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 151)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 152) TRACE_EVENT(mm_page_free,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 153)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 154) TP_PROTO(struct page *page, unsigned int order),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 155)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 156) TP_ARGS(page, order),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 157)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 158) TP_STRUCT__entry(
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 159) __field( unsigned long, pfn )
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 160) __field( unsigned int, order )
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 161) ),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 162)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 163) TP_fast_assign(
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 164) __entry->pfn = page_to_pfn(page);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 165) __entry->order = order;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 166) ),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 167)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 168) TP_printk("page=%p pfn=%lu order=%d",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 169) pfn_to_page(__entry->pfn),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 170) __entry->pfn,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 171) __entry->order)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 172) );
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 173)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 174) TRACE_EVENT(mm_page_free_batched,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 175)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 176) TP_PROTO(struct page *page),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 177)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 178) TP_ARGS(page),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 179)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 180) TP_STRUCT__entry(
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 181) __field( unsigned long, pfn )
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 182) ),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 183)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 184) TP_fast_assign(
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 185) __entry->pfn = page_to_pfn(page);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 186) ),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 187)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 188) TP_printk("page=%p pfn=%lu order=0",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 189) pfn_to_page(__entry->pfn),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 190) __entry->pfn)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 191) );
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 192)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 193) TRACE_EVENT(mm_page_alloc,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 194)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 195) TP_PROTO(struct page *page, unsigned int order,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 196) gfp_t gfp_flags, int migratetype),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 197)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 198) TP_ARGS(page, order, gfp_flags, migratetype),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 199)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 200) TP_STRUCT__entry(
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 201) __field( unsigned long, pfn )
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 202) __field( unsigned int, order )
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 203) __field( gfp_t, gfp_flags )
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 204) __field( int, migratetype )
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 205) ),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 206)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 207) TP_fast_assign(
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 208) __entry->pfn = page ? page_to_pfn(page) : -1UL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 209) __entry->order = order;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 210) __entry->gfp_flags = gfp_flags;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 211) __entry->migratetype = migratetype;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 212) ),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 213)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 214) TP_printk("page=%p pfn=%lu order=%d migratetype=%d gfp_flags=%s",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 215) __entry->pfn != -1UL ? pfn_to_page(__entry->pfn) : NULL,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 216) __entry->pfn != -1UL ? __entry->pfn : 0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 217) __entry->order,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 218) __entry->migratetype,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 219) show_gfp_flags(__entry->gfp_flags))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 220) );
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 221)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 222) DECLARE_EVENT_CLASS(mm_page,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 223)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 224) TP_PROTO(struct page *page, unsigned int order, int migratetype),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 225)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 226) TP_ARGS(page, order, migratetype),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 227)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 228) TP_STRUCT__entry(
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 229) __field( unsigned long, pfn )
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 230) __field( unsigned int, order )
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 231) __field( int, migratetype )
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 232) ),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 233)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 234) TP_fast_assign(
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 235) __entry->pfn = page ? page_to_pfn(page) : -1UL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 236) __entry->order = order;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 237) __entry->migratetype = migratetype;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 238) ),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 239)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 240) TP_printk("page=%p pfn=%lu order=%u migratetype=%d percpu_refill=%d",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 241) __entry->pfn != -1UL ? pfn_to_page(__entry->pfn) : NULL,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 242) __entry->pfn != -1UL ? __entry->pfn : 0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 243) __entry->order,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 244) __entry->migratetype,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 245) __entry->order == 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 246) );
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 247)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 248) DEFINE_EVENT(mm_page, mm_page_alloc_zone_locked,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 249)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 250) TP_PROTO(struct page *page, unsigned int order, int migratetype),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 251)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 252) TP_ARGS(page, order, migratetype)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 253) );
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 254)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 255) TRACE_EVENT(mm_page_pcpu_drain,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 256)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 257) TP_PROTO(struct page *page, unsigned int order, int migratetype),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 258)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 259) TP_ARGS(page, order, migratetype),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 260)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 261) TP_STRUCT__entry(
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 262) __field( unsigned long, pfn )
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 263) __field( unsigned int, order )
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 264) __field( int, migratetype )
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 265) ),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 266)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 267) TP_fast_assign(
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 268) __entry->pfn = page ? page_to_pfn(page) : -1UL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 269) __entry->order = order;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 270) __entry->migratetype = migratetype;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 271) ),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 272)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 273) TP_printk("page=%p pfn=%lu order=%d migratetype=%d",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 274) pfn_to_page(__entry->pfn), __entry->pfn,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 275) __entry->order, __entry->migratetype)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 276) );
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 277)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 278) TRACE_EVENT(mm_page_alloc_extfrag,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 279)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 280) TP_PROTO(struct page *page,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 281) int alloc_order, int fallback_order,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 282) int alloc_migratetype, int fallback_migratetype),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 283)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 284) TP_ARGS(page,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 285) alloc_order, fallback_order,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 286) alloc_migratetype, fallback_migratetype),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 287)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 288) TP_STRUCT__entry(
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 289) __field( unsigned long, pfn )
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 290) __field( int, alloc_order )
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 291) __field( int, fallback_order )
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 292) __field( int, alloc_migratetype )
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 293) __field( int, fallback_migratetype )
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 294) __field( int, change_ownership )
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 295) ),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 296)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 297) TP_fast_assign(
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 298) __entry->pfn = page_to_pfn(page);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 299) __entry->alloc_order = alloc_order;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 300) __entry->fallback_order = fallback_order;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 301) __entry->alloc_migratetype = alloc_migratetype;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 302) __entry->fallback_migratetype = fallback_migratetype;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 303) __entry->change_ownership = (alloc_migratetype ==
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 304) get_pageblock_migratetype(page));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 305) ),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 306)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 307) 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",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 308) pfn_to_page(__entry->pfn),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 309) __entry->pfn,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 310) __entry->alloc_order,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 311) __entry->fallback_order,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 312) pageblock_order,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 313) __entry->alloc_migratetype,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 314) __entry->fallback_migratetype,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 315) __entry->fallback_order < pageblock_order,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 316) __entry->change_ownership)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 317) );
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 318)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 319) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 320) * Required for uniquely and securely identifying mm in rss_stat tracepoint.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 321) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 322) #ifndef __PTR_TO_HASHVAL
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 323) static unsigned int __maybe_unused mm_ptr_to_hash(const void *ptr)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 324) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 325) int ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 326) unsigned long hashval;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 327)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 328) ret = ptr_to_hashval(ptr, &hashval);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 329) if (ret)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 330) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 331)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 332) /* The hashed value is only 32-bit */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 333) return (unsigned int)hashval;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 334) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 335) #define __PTR_TO_HASHVAL
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 336) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 337)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 338) TRACE_EVENT(rss_stat,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 339)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 340) TP_PROTO(struct mm_struct *mm,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 341) int member,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 342) long count),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 343)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 344) TP_ARGS(mm, member, count),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 345)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 346) TP_STRUCT__entry(
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 347) __field(unsigned int, mm_id)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 348) __field(unsigned int, curr)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 349) __field(int, member)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 350) __field(long, size)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 351) ),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 352)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 353) TP_fast_assign(
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 354) __entry->mm_id = mm_ptr_to_hash(mm);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 355) __entry->curr = !!(current->mm == mm);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 356) __entry->member = member;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 357) __entry->size = (count << PAGE_SHIFT);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 358) ),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 359)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 360) TP_printk("mm_id=%u curr=%d member=%d size=%ldB",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 361) __entry->mm_id,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 362) __entry->curr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 363) __entry->member,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 364) __entry->size)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 365) );
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 366) #endif /* _TRACE_KMEM_H */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 367)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 368) /* This part must be outside protection */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 369) #include <trace/define_trace.h>