1 /* SPDX-License-Identifier: GPL-2.0 */
3 #define TRACE_SYSTEM ksm
5 #if !defined(_TRACE_KSM_H) || defined(TRACE_HEADER_MULTI_READ)
8 #include <linux/tracepoint.h>
11 * ksm_scan_template - called for start / stop scan
13 * @seq: sequence number of scan
14 * @rmap_entries: actual number of rmap entries
16 * Allows to trace the start / stop of a ksm scan.
18 DECLARE_EVENT_CLASS(ksm_scan_template
,
20 TP_PROTO(int seq
, u32 rmap_entries
),
22 TP_ARGS(seq
, rmap_entries
),
26 __field(u32
, rmap_entries
)
31 __entry
->rmap_entries
= rmap_entries
;
34 TP_printk("seq %d rmap size %d",
35 __entry
->seq
, __entry
->rmap_entries
)
39 * ksm_start_scan - called after a new ksm scan is started
41 * @seq: sequence number of scan
42 * @rmap_entries: actual number of rmap entries
44 * Allows to trace the start of a ksm scan.
46 DEFINE_EVENT(ksm_scan_template
, ksm_start_scan
,
48 TP_PROTO(int seq
, u32 rmap_entries
),
50 TP_ARGS(seq
, rmap_entries
)
54 * ksm_stop_scan - called after a new ksm scan has completed
56 * @seq: sequence number of scan
57 * @rmap_entries: actual number of rmap entries
59 * Allows to trace the completion of a ksm scan.
61 DEFINE_EVENT(ksm_scan_template
, ksm_stop_scan
,
63 TP_PROTO(int seq
, u32 rmap_entries
),
65 TP_ARGS(seq
, rmap_entries
)
69 * ksm_enter - called after a new process has been added / removed from ksm
71 * @mm: address of the mm object of the process
73 * Allows to trace the when a process has been added or removed from ksm.
75 DECLARE_EVENT_CLASS(ksm_enter_exit_template
,
89 TP_printk("mm %p", __entry
->mm
)
93 * ksm_enter - called after a new process has been added to ksm
95 * @mm: address of the mm object of the process
97 * Allows to trace the when a process has been added to ksm.
99 DEFINE_EVENT(ksm_enter_exit_template
, ksm_enter
,
107 * ksm_exit - called after a new process has been removed from ksm
109 * @mm: address of the mm object of the process
111 * Allows to trace the when a process has been removed from ksm.
113 DEFINE_EVENT(ksm_enter_exit_template
, ksm_exit
,
121 * ksm_merge_one_page - called after a page has been merged
123 * @pfn: page frame number of ksm page
124 * @rmap_item: address of rmap_item object
125 * @mm: address of the process mm struct
128 * Allows to trace the ksm merging of individual pages.
130 TRACE_EVENT(ksm_merge_one_page
,
132 TP_PROTO(unsigned long pfn
, void *rmap_item
, void *mm
, int err
),
134 TP_ARGS(pfn
, rmap_item
, mm
, err
),
137 __field(unsigned long, pfn
)
138 __field(void *, rmap_item
)
145 __entry
->rmap_item
= rmap_item
;
150 TP_printk("ksm pfn %lu rmap_item %p mm %p error %d",
151 __entry
->pfn
, __entry
->rmap_item
, __entry
->mm
, __entry
->err
)
155 * ksm_merge_with_ksm_page - called after a page has been merged with a ksm page
157 * @ksm_page: address ksm page
158 * @pfn: page frame number of ksm page
159 * @rmap_item: address of rmap_item object
160 * @mm: address of the mm object of the process
163 * Allows to trace the merging of a page with a ksm page.
165 TRACE_EVENT(ksm_merge_with_ksm_page
,
167 TP_PROTO(void *ksm_page
, unsigned long pfn
, void *rmap_item
, void *mm
, int err
),
169 TP_ARGS(ksm_page
, pfn
, rmap_item
, mm
, err
),
172 __field(void *, ksm_page
)
173 __field(unsigned long, pfn
)
174 __field(void *, rmap_item
)
180 __entry
->ksm_page
= ksm_page
;
182 __entry
->rmap_item
= rmap_item
;
187 TP_printk("%spfn %lu rmap_item %p mm %p error %d",
188 (__entry
->ksm_page
? "ksm " : ""),
189 __entry
->pfn
, __entry
->rmap_item
, __entry
->mm
, __entry
->err
)
193 * ksm_remove_ksm_page - called after a ksm page has been removed
195 * @pfn: page frame number of ksm page
197 * Allows to trace the removing of stable ksm pages.
199 TRACE_EVENT(ksm_remove_ksm_page
,
201 TP_PROTO(unsigned long pfn
),
206 __field(unsigned long, pfn
)
213 TP_printk("pfn %lu", __entry
->pfn
)
217 * ksm_remove_rmap_item - called after a rmap_item has been removed from the
220 * @pfn: page frame number of ksm page
221 * @rmap_item: address of rmap_item object
222 * @mm: address of the process mm struct
224 * Allows to trace the removal of pages from the stable tree list.
226 TRACE_EVENT(ksm_remove_rmap_item
,
228 TP_PROTO(unsigned long pfn
, void *rmap_item
, void *mm
),
230 TP_ARGS(pfn
, rmap_item
, mm
),
233 __field(unsigned long, pfn
)
234 __field(void *, rmap_item
)
240 __entry
->rmap_item
= rmap_item
;
244 TP_printk("pfn %lu rmap_item %p mm %p",
245 __entry
->pfn
, __entry
->rmap_item
, __entry
->mm
)
249 * ksm_advisor - called after the advisor has run
251 * @scan_time: scan time in seconds
252 * @pages_to_scan: new pages_to_scan value
253 * @cpu_percent: cpu usage in percent
255 * Allows to trace the ksm advisor.
257 TRACE_EVENT(ksm_advisor
,
259 TP_PROTO(s64 scan_time
, unsigned long pages_to_scan
,
260 unsigned int cpu_percent
),
262 TP_ARGS(scan_time
, pages_to_scan
, cpu_percent
),
265 __field(s64
, scan_time
)
266 __field(unsigned long, pages_to_scan
)
267 __field(unsigned int, cpu_percent
)
271 __entry
->scan_time
= scan_time
;
272 __entry
->pages_to_scan
= pages_to_scan
;
273 __entry
->cpu_percent
= cpu_percent
;
276 TP_printk("ksm scan time %lld pages_to_scan %lu cpu percent %u",
277 __entry
->scan_time
, __entry
->pages_to_scan
,
278 __entry
->cpu_percent
)
281 #endif /* _TRACE_KSM_H */
283 /* This part must be outside protection */
284 #include <trace/define_trace.h>