1 /* SPDX-License-Identifier: GPL-2.0 */
3 #define TRACE_SYSTEM huge_memory
5 #if !defined(__HUGE_MEMORY_H) || defined(TRACE_HEADER_MULTI_READ)
6 #define __HUGE_MEMORY_H
8 #include <linux/tracepoint.h>
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")
46 #define EM(a, b) TRACE_DEFINE_ENUM(a);
47 #define EMe(a, b) TRACE_DEFINE_ENUM(a);
53 #define EM(a, b) {a, b},
54 #define EMe(a, b) {a, b}
56 TRACE_EVENT(mm_khugepaged_scan_pmd
,
58 TP_PROTO(struct mm_struct
*mm
, struct page
*page
, bool writable
,
59 int referenced
, int none_or_zero
, int status
, int unmapped
),
61 TP_ARGS(mm
, page
, writable
, referenced
, none_or_zero
, status
, unmapped
),
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
)
70 __field(int, unmapped
)
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
;
83 TP_printk("mm=%p, scan_pfn=0x%lx, writable=%d, referenced=%d, none_or_zero=%d, status=%s, unmapped=%d",
88 __entry
->none_or_zero
,
89 __print_symbolic(__entry
->status
, SCAN_STATUS
),
93 TRACE_EVENT(mm_collapse_huge_page
,
95 TP_PROTO(struct mm_struct
*mm
, int isolated
, int status
),
97 TP_ARGS(mm
, isolated
, status
),
100 __field(struct mm_struct
*, mm
)
101 __field(int, isolated
)
107 __entry
->isolated
= isolated
;
108 __entry
->status
= status
;
111 TP_printk("mm=%p, isolated=%d, status=%s",
114 __print_symbolic(__entry
->status
, SCAN_STATUS
))
117 TRACE_EVENT(mm_collapse_huge_page_isolate
,
119 TP_PROTO(struct page
*page
, int none_or_zero
,
120 int referenced
, bool writable
, int status
),
122 TP_ARGS(page
, none_or_zero
, referenced
, writable
, status
),
125 __field(unsigned long, pfn
)
126 __field(int, none_or_zero
)
127 __field(int, referenced
)
128 __field(bool, writable
)
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
;
140 TP_printk("scan_pfn=0x%lx, none_or_zero=%d, referenced=%d, writable=%d, status=%s",
142 __entry
->none_or_zero
,
145 __print_symbolic(__entry
->status
, SCAN_STATUS
))
148 TRACE_EVENT(mm_collapse_huge_page_swapin
,
150 TP_PROTO(struct mm_struct
*mm
, int swapped_in
, int referenced
, int ret
),
152 TP_ARGS(mm
, swapped_in
, referenced
, ret
),
155 __field(struct mm_struct
*, mm
)
156 __field(int, swapped_in
)
157 __field(int, referenced
)
163 __entry
->swapped_in
= swapped_in
;
164 __entry
->referenced
= referenced
;
168 TP_printk("mm=%p, swapped_in=%d, referenced=%d, ret=%d",
175 TRACE_EVENT(mm_khugepaged_scan_file
,
177 TP_PROTO(struct mm_struct
*mm
, struct folio
*folio
, struct file
*file
,
178 int present
, int swap
, int result
),
180 TP_ARGS(mm
, folio
, file
, present
, swap
, result
),
183 __field(struct mm_struct
*, mm
)
184 __field(unsigned long, pfn
)
185 __string(filename
, file
->f_path
.dentry
->d_iname
)
186 __field(int, present
)
193 __entry
->pfn
= folio
? folio_pfn(folio
) : -1;
194 __assign_str(filename
);
195 __entry
->present
= present
;
196 __entry
->swap
= swap
;
197 __entry
->result
= result
;
200 TP_printk("mm=%p, scan_pfn=0x%lx, filename=%s, present=%d, swap=%d, result=%s",
206 __print_symbolic(__entry
->result
, SCAN_STATUS
))
209 TRACE_EVENT(mm_khugepaged_collapse_file
,
210 TP_PROTO(struct mm_struct
*mm
, struct folio
*new_folio
, pgoff_t index
,
211 unsigned long addr
, bool is_shmem
, struct file
*file
,
213 TP_ARGS(mm
, new_folio
, index
, addr
, is_shmem
, file
, nr
, result
),
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
)
227 __entry
->hpfn
= new_folio
? folio_pfn(new_folio
) : -1;
228 __entry
->index
= index
;
229 __entry
->addr
= addr
;
230 __entry
->is_shmem
= is_shmem
;
231 __assign_str(filename
);
233 __entry
->result
= result
;
236 TP_printk("mm=%p, hpage_pfn=0x%lx, index=%ld, addr=%lx, is_shmem=%d, filename=%s, nr=%d, result=%s",
244 __print_symbolic(__entry
->result
, SCAN_STATUS
))
247 #endif /* __HUGE_MEMORY_H */
248 #include <trace/define_trace.h>