1 /* SPDX-License-Identifier: GPL-2.0 */ 2 #undef TRACE_SYSTEM 3 #define TRACE_SYSTEM migrate 4 5 #if !defined(_TRACE_MIGRATE_H) || defined(TRACE_HEADER_MULTI_READ) 6 #define _TRACE_MIGRATE_H 7 8 #include <linux/tracepoint.h> 9 10 #define MIGRATE_MODE \ 11 EM( MIGRATE_ASYNC, "MIGRATE_ASYNC") \ 12 EM( MIGRATE_SYNC_LIGHT, "MIGRATE_SYNC_LIGHT") \ 13 EMe(MIGRATE_SYNC, "MIGRATE_SYNC") 14 15 16 #define MIGRATE_REASON \ 17 EM( MR_COMPACTION, "compaction") \ 18 EM( MR_MEMORY_FAILURE, "memory_failure") \ 19 EM( MR_MEMORY_HOTPLUG, "memory_hotplug") \ 20 EM( MR_SYSCALL, "syscall_or_cpuset") \ 21 EM( MR_MEMPOLICY_MBIND, "mempolicy_mbind") \ 22 EM( MR_NUMA_MISPLACED, "numa_misplaced") \ 23 EM( MR_CONTIG_RANGE, "contig_range") \ 24 EM( MR_LONGTERM_PIN, "longterm_pin") \ 25 EMe(MR_DEMOTION, "demotion") 26 27 /* 28 * First define the enums in the above macros to be exported to userspace 29 * via TRACE_DEFINE_ENUM(). 30 */ 31 #undef EM 32 #undef EMe 33 #define EM(a, b) TRACE_DEFINE_ENUM(a); 34 #define EMe(a, b) TRACE_DEFINE_ENUM(a); 35 36 MIGRATE_MODE 37 MIGRATE_REASON 38 39 /* 40 * Now redefine the EM() and EMe() macros to map the enums to the strings 41 * that will be printed in the output. 42 */ 43 #undef EM 44 #undef EMe 45 #define EM(a, b) {a, b}, 46 #define EMe(a, b) {a, b} 47 48 TRACE_EVENT(mm_migrate_pages, 49 50 TP_PROTO(unsigned long succeeded, unsigned long failed, 51 unsigned long thp_succeeded, unsigned long thp_failed, 52 unsigned long thp_split, unsigned long large_folio_split, 53 enum migrate_mode mode, int reason), 54 55 TP_ARGS(succeeded, failed, thp_succeeded, thp_failed, 56 thp_split, large_folio_split, mode, reason), 57 58 TP_STRUCT__entry( 59 __field( unsigned long, succeeded) 60 __field( unsigned long, failed) 61 __field( unsigned long, thp_succeeded) 62 __field( unsigned long, thp_failed) 63 __field( unsigned long, thp_split) 64 __field( unsigned long, large_folio_split) 65 __field( enum migrate_mode, mode) 66 __field( int, reason) 67 ), 68 69 TP_fast_assign( 70 __entry->succeeded = succeeded; 71 __entry->failed = failed; 72 __entry->thp_succeeded = thp_succeeded; 73 __entry->thp_failed = thp_failed; 74 __entry->thp_split = thp_split; 75 __entry->large_folio_split = large_folio_split; 76 __entry->mode = mode; 77 __entry->reason = reason; 78 ), 79 80 TP_printk("nr_succeeded=%lu nr_failed=%lu nr_thp_succeeded=%lu nr_thp_failed=%lu nr_thp_split=%lu nr_split=%lu mode=%s reason=%s", 81 __entry->succeeded, 82 __entry->failed, 83 __entry->thp_succeeded, 84 __entry->thp_failed, 85 __entry->thp_split, 86 __entry->large_folio_split, 87 __print_symbolic(__entry->mode, MIGRATE_MODE), 88 __print_symbolic(__entry->reason, MIGRATE_REASON)) 89 ); 90 91 TRACE_EVENT(mm_migrate_pages_start, 92 93 TP_PROTO(enum migrate_mode mode, int reason), 94 95 TP_ARGS(mode, reason), 96 97 TP_STRUCT__entry( 98 __field(enum migrate_mode, mode) 99 __field(int, reason) 100 ), 101 102 TP_fast_assign( 103 __entry->mode = mode; 104 __entry->reason = reason; 105 ), 106 107 TP_printk("mode=%s reason=%s", 108 __print_symbolic(__entry->mode, MIGRATE_MODE), 109 __print_symbolic(__entry->reason, MIGRATE_REASON)) 110 ); 111 112 DECLARE_EVENT_CLASS(migration_pte, 113 114 TP_PROTO(unsigned long addr, unsigned long pte, int order), 115 116 TP_ARGS(addr, pte, order), 117 118 TP_STRUCT__entry( 119 __field(unsigned long, addr) 120 __field(unsigned long, pte) 121 __field(int, order) 122 ), 123 124 TP_fast_assign( 125 __entry->addr = addr; 126 __entry->pte = pte; 127 __entry->order = order; 128 ), 129 130 TP_printk("addr=%lx, pte=%lx order=%d", __entry->addr, __entry->pte, __entry->order) 131 ); 132 133 DEFINE_EVENT(migration_pte, set_migration_pte, 134 TP_PROTO(unsigned long addr, unsigned long pte, int order), 135 TP_ARGS(addr, pte, order) 136 ); 137 138 DEFINE_EVENT(migration_pte, remove_migration_pte, 139 TP_PROTO(unsigned long addr, unsigned long pte, int order), 140 TP_ARGS(addr, pte, order) 141 ); 142 143 #endif /* _TRACE_MIGRATE_H */ 144 145 /* This part must be outside protection */ 146 #include <trace/define_trace.h> 147