1 /* SPDX-License-Identifier: GPL-2.0 */ 2 #undef TRACE_SYSTEM 3 #define TRACE_SYSTEM huge_memory 4 5 #if !defined(__HUGE_MEMORY_H) || defined(TRACE_HEADER_MULTI_READ) 6 #define __HUGE_MEMORY_H 7 8 #include <linux/tracepoint.h> 9 10 #define SCAN_STATUS \ 11 EM( SCAN_FAIL, "failed") \ 12 EM( SCAN_SUCCEED, "succeeded") \ 13 EM( SCAN_PMD_NULL, "pmd_null") \ 14 EM( SCAN_PMD_NONE, "pmd_none") \ 15 EM( SCAN_PMD_MAPPED, "page_pmd_mapped") \ 16 EM( SCAN_EXCEED_NONE_PTE, "exceed_none_pte") \ 17 EM( SCAN_EXCEED_SWAP_PTE, "exceed_swap_pte") \ 18 EM( SCAN_EXCEED_SHARED_PTE, "exceed_shared_pte") \ 19 EM( SCAN_PTE_NON_PRESENT, "pte_non_present") \ 20 EM( SCAN_PTE_UFFD_WP, "pte_uffd_wp") \ 21 EM( SCAN_PTE_MAPPED_HUGEPAGE, "pte_mapped_hugepage") \ 22 EM( SCAN_PAGE_RO, "no_writable_page") \ 23 EM( SCAN_LACK_REFERENCED_PAGE, "lack_referenced_page") \ 24 EM( SCAN_PAGE_NULL, "page_null") \ 25 EM( SCAN_SCAN_ABORT, "scan_aborted") \ 26 EM( SCAN_PAGE_COUNT, "not_suitable_page_count") \ 27 EM( SCAN_PAGE_LRU, "page_not_in_lru") \ 28 EM( SCAN_PAGE_LOCK, "page_locked") \ 29 EM( SCAN_PAGE_ANON, "page_not_anon") \ 30 EM( SCAN_PAGE_COMPOUND, "page_compound") \ 31 EM( SCAN_ANY_PROCESS, "no_process_for_page") \ 32 EM( SCAN_VMA_NULL, "vma_null") \ 33 EM( SCAN_VMA_CHECK, "vma_check_failed") \ 34 EM( SCAN_ADDRESS_RANGE, "not_suitable_address_range") \ 35 EM( SCAN_DEL_PAGE_LRU, "could_not_delete_page_from_lru")\ 36 EM( SCAN_ALLOC_HUGE_PAGE_FAIL, "alloc_huge_page_failed") \ 37 EM( SCAN_CGROUP_CHARGE_FAIL, "ccgroup_charge_failed") \ 38 EM( SCAN_TRUNCATED, "truncated") \ 39 EM( SCAN_PAGE_HAS_PRIVATE, "page_has_private") \ 40 EM( SCAN_STORE_FAILED, "store_failed") \ 41 EM( SCAN_COPY_MC, "copy_poisoned_page") \ 42 EMe(SCAN_PAGE_FILLED, "page_filled") 43 44 #undef EM 45 #undef EMe 46 #define EM(a, b) TRACE_DEFINE_ENUM(a); 47 #define EMe(a, b) TRACE_DEFINE_ENUM(a); 48 49 SCAN_STATUS 50 51 #undef EM 52 #undef EMe 53 #define EM(a, b) {a, b}, 54 #define EMe(a, b) {a, b} 55 56 TRACE_EVENT(mm_khugepaged_scan_pmd, 57 58 TP_PROTO(struct mm_struct *mm, struct page *page, bool writable, 59 int referenced, int none_or_zero, int status, int unmapped), 60 61 TP_ARGS(mm, page, writable, referenced, none_or_zero, status, unmapped), 62 63 TP_STRUCT__entry( 64 __field(struct mm_struct *, mm) 65 __field(unsigned long, pfn) 66 __field(bool, writable) 67 __field(int, referenced) 68 __field(int, none_or_zero) 69 __field(int, status) 70 __field(int, unmapped) 71 ), 72 73 TP_fast_assign( 74 __entry->mm = mm; 75 __entry->pfn = page ? page_to_pfn(page) : -1; 76 __entry->writable = writable; 77 __entry->referenced = referenced; 78 __entry->none_or_zero = none_or_zero; 79 __entry->status = status; 80 __entry->unmapped = unmapped; 81 ), 82 83 TP_printk("mm=%p, scan_pfn=0x%lx, writable=%d, referenced=%d, none_or_zero=%d, status=%s, unmapped=%d", 84 __entry->mm, 85 __entry->pfn, 86 __entry->writable, 87 __entry->referenced, 88 __entry->none_or_zero, 89 __print_symbolic(__entry->status, SCAN_STATUS), 90 __entry->unmapped) 91 ); 92 93 TRACE_EVENT(mm_collapse_huge_page, 94 95 TP_PROTO(struct mm_struct *mm, int isolated, int status), 96 97 TP_ARGS(mm, isolated, status), 98 99 TP_STRUCT__entry( 100 __field(struct mm_struct *, mm) 101 __field(int, isolated) 102 __field(int, status) 103 ), 104 105 TP_fast_assign( 106 __entry->mm = mm; 107 __entry->isolated = isolated; 108 __entry->status = status; 109 ), 110 111 TP_printk("mm=%p, isolated=%d, status=%s", 112 __entry->mm, 113 __entry->isolated, 114 __print_symbolic(__entry->status, SCAN_STATUS)) 115 ); 116 117 TRACE_EVENT(mm_collapse_huge_page_isolate, 118 119 TP_PROTO(struct page *page, int none_or_zero, 120 int referenced, bool writable, int status), 121 122 TP_ARGS(page, none_or_zero, referenced, writable, status), 123 124 TP_STRUCT__entry( 125 __field(unsigned long, pfn) 126 __field(int, none_or_zero) 127 __field(int, referenced) 128 __field(bool, writable) 129 __field(int, status) 130 ), 131 132 TP_fast_assign( 133 __entry->pfn = page ? page_to_pfn(page) : -1; 134 __entry->none_or_zero = none_or_zero; 135 __entry->referenced = referenced; 136 __entry->writable = writable; 137 __entry->status = status; 138 ), 139 140 TP_printk("scan_pfn=0x%lx, none_or_zero=%d, referenced=%d, writable=%d, status=%s", 141 __entry->pfn, 142 __entry->none_or_zero, 143 __entry->referenced, 144 __entry->writable, 145 __print_symbolic(__entry->status, SCAN_STATUS)) 146 ); 147 148 TRACE_EVENT(mm_collapse_huge_page_swapin, 149 150 TP_PROTO(struct mm_struct *mm, int swapped_in, int referenced, int ret), 151 152 TP_ARGS(mm, swapped_in, referenced, ret), 153 154 TP_STRUCT__entry( 155 __field(struct mm_struct *, mm) 156 __field(int, swapped_in) 157 __field(int, referenced) 158 __field(int, ret) 159 ), 160 161 TP_fast_assign( 162 __entry->mm = mm; 163 __entry->swapped_in = swapped_in; 164 __entry->referenced = referenced; 165 __entry->ret = ret; 166 ), 167 168 TP_printk("mm=%p, swapped_in=%d, referenced=%d, ret=%d", 169 __entry->mm, 170 __entry->swapped_in, 171 __entry->referenced, 172 __entry->ret) 173 ); 174 175 TRACE_EVENT(mm_khugepaged_scan_file, 176 177 TP_PROTO(struct mm_struct *mm, struct page *page, struct file *file, 178 int present, int swap, int result), 179 180 TP_ARGS(mm, page, file, present, swap, result), 181 182 TP_STRUCT__entry( 183 __field(struct mm_struct *, mm) 184 __field(unsigned long, pfn) 185 __string(filename, file->f_path.dentry->d_iname) 186 __field(int, present) 187 __field(int, swap) 188 __field(int, result) 189 ), 190 191 TP_fast_assign( 192 __entry->mm = mm; 193 __entry->pfn = page ? page_to_pfn(page) : -1; 194 __assign_str(filename, file->f_path.dentry->d_iname); 195 __entry->present = present; 196 __entry->swap = swap; 197 __entry->result = result; 198 ), 199 200 TP_printk("mm=%p, scan_pfn=0x%lx, filename=%s, present=%d, swap=%d, result=%s", 201 __entry->mm, 202 __entry->pfn, 203 __get_str(filename), 204 __entry->present, 205 __entry->swap, 206 __print_symbolic(__entry->result, SCAN_STATUS)) 207 ); 208 209 TRACE_EVENT(mm_khugepaged_collapse_file, 210 TP_PROTO(struct mm_struct *mm, struct page *hpage, pgoff_t index, 211 bool is_shmem, unsigned long addr, struct file *file, 212 int nr, int result), 213 TP_ARGS(mm, hpage, index, addr, is_shmem, file, nr, result), 214 TP_STRUCT__entry( 215 __field(struct mm_struct *, mm) 216 __field(unsigned long, hpfn) 217 __field(pgoff_t, index) 218 __field(unsigned long, addr) 219 __field(bool, is_shmem) 220 __string(filename, file->f_path.dentry->d_iname) 221 __field(int, nr) 222 __field(int, result) 223 ), 224 225 TP_fast_assign( 226 __entry->mm = mm; 227 __entry->hpfn = hpage ? page_to_pfn(hpage) : -1; 228 __entry->index = index; 229 __entry->addr = addr; 230 __entry->is_shmem = is_shmem; 231 __assign_str(filename, file->f_path.dentry->d_iname); 232 __entry->nr = nr; 233 __entry->result = result; 234 ), 235 236 TP_printk("mm=%p, hpage_pfn=0x%lx, index=%ld, addr=%ld, is_shmem=%d, filename=%s, nr=%d, result=%s", 237 __entry->mm, 238 __entry->hpfn, 239 __entry->index, 240 __entry->addr, 241 __entry->is_shmem, 242 __get_str(filename), 243 __entry->nr, 244 __print_symbolic(__entry->result, SCAN_STATUS)) 245 ); 246 247 #endif /* __HUGE_MEMORY_H */ 248 #include <trace/define_trace.h> 249