Merge tag 'trace-printf-v6.13' of git://git.kernel.org/pub/scm/linux/kernel/git/trace...
[drm/drm-misc.git] / include / trace / events / ksm.h
blobe728647b5d268ef7fa79a81972ff25a913b783e9
1 /* SPDX-License-Identifier: GPL-2.0 */
2 #undef TRACE_SYSTEM
3 #define TRACE_SYSTEM ksm
5 #if !defined(_TRACE_KSM_H) || defined(TRACE_HEADER_MULTI_READ)
6 #define _TRACE_KSM_H
8 #include <linux/tracepoint.h>
10 /**
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),
24 TP_STRUCT__entry(
25 __field(int, seq)
26 __field(u32, rmap_entries)
29 TP_fast_assign(
30 __entry->seq = seq;
31 __entry->rmap_entries = rmap_entries;
34 TP_printk("seq %d rmap size %d",
35 __entry->seq, __entry->rmap_entries)
38 /**
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)
53 /**
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)
68 /**
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,
77 TP_PROTO(void *mm),
79 TP_ARGS(mm),
81 TP_STRUCT__entry(
82 __field(void *, mm)
85 TP_fast_assign(
86 __entry->mm = mm;
89 TP_printk("mm %p", __entry->mm)
92 /**
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,
101 TP_PROTO(void *mm),
103 TP_ARGS(mm)
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,
115 TP_PROTO(void *mm),
117 TP_ARGS(mm)
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
126 * @err: success
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),
136 TP_STRUCT__entry(
137 __field(unsigned long, pfn)
138 __field(void *, rmap_item)
139 __field(void *, mm)
140 __field(int, err)
143 TP_fast_assign(
144 __entry->pfn = pfn;
145 __entry->rmap_item = rmap_item;
146 __entry->mm = mm;
147 __entry->err = err;
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
161 * @err: success
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),
171 TP_STRUCT__entry(
172 __field(void *, ksm_page)
173 __field(unsigned long, pfn)
174 __field(void *, rmap_item)
175 __field(void *, mm)
176 __field(int, err)
179 TP_fast_assign(
180 __entry->ksm_page = ksm_page;
181 __entry->pfn = pfn;
182 __entry->rmap_item = rmap_item;
183 __entry->mm = mm;
184 __entry->err = err;
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),
203 TP_ARGS(pfn),
205 TP_STRUCT__entry(
206 __field(unsigned long, pfn)
209 TP_fast_assign(
210 __entry->pfn = pfn;
213 TP_printk("pfn %lu", __entry->pfn)
217 * ksm_remove_rmap_item - called after a rmap_item has been removed from the
218 * stable tree
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),
232 TP_STRUCT__entry(
233 __field(unsigned long, pfn)
234 __field(void *, rmap_item)
235 __field(void *, mm)
238 TP_fast_assign(
239 __entry->pfn = pfn;
240 __entry->rmap_item = rmap_item;
241 __entry->mm = mm;
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),
264 TP_STRUCT__entry(
265 __field(s64, scan_time)
266 __field(unsigned long, pages_to_scan)
267 __field(unsigned int, cpu_percent)
270 TP_fast_assign(
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>