1 /* SPDX-License-Identifier: GPL-2.0-or-later */
2 /* FS-Cache tracepoints
4 * Copyright (C) 2016 Red Hat, Inc. All Rights Reserved.
5 * Written by David Howells (dhowells@redhat.com)
8 #define TRACE_SYSTEM fscache
10 #if !defined(_TRACE_FSCACHE_H) || defined(TRACE_HEADER_MULTI_READ)
11 #define _TRACE_FSCACHE_H
13 #include <linux/fscache.h>
14 #include <linux/tracepoint.h>
17 * Define enums for tracing information.
19 #ifndef __FSCACHE_DECLARE_TRACE_ENUMS_ONCE_ONLY
20 #define __FSCACHE_DECLARE_TRACE_ENUMS_ONCE_ONLY
22 enum fscache_cookie_trace
{
23 fscache_cookie_collision
,
24 fscache_cookie_discard
,
25 fscache_cookie_get_acquire_parent
,
26 fscache_cookie_get_attach_object
,
27 fscache_cookie_get_reacquire
,
28 fscache_cookie_get_register_netfs
,
29 fscache_cookie_put_acquire_nobufs
,
30 fscache_cookie_put_dup_netfs
,
31 fscache_cookie_put_relinquish
,
32 fscache_cookie_put_object
,
33 fscache_cookie_put_parent
,
36 enum fscache_page_trace
{
39 fscache_page_maybe_release
,
40 fscache_page_radix_clear_store
,
41 fscache_page_radix_delete
,
42 fscache_page_radix_insert
,
43 fscache_page_radix_pend2store
,
44 fscache_page_radix_set_pend
,
47 fscache_page_write_end
,
48 fscache_page_write_end_pend
,
49 fscache_page_write_end_noc
,
50 fscache_page_write_wait
,
51 fscache_page_trace__nr
54 enum fscache_op_trace
{
56 fscache_op_cancel_all
,
59 fscache_op_enqueue_async
,
60 fscache_op_enqueue_mythread
,
72 enum fscache_page_op_trace
{
73 fscache_page_op_alloc_one
,
74 fscache_page_op_attr_changed
,
75 fscache_page_op_check_consistency
,
76 fscache_page_op_invalidate
,
77 fscache_page_op_retr_multi
,
78 fscache_page_op_retr_one
,
79 fscache_page_op_write_one
,
80 fscache_page_op_trace__nr
86 * Declare tracing information enums and their string mappings for display.
88 #define fscache_cookie_traces \
89 EM(fscache_cookie_collision, "*COLLISION*") \
90 EM(fscache_cookie_discard, "DISCARD") \
91 EM(fscache_cookie_get_acquire_parent, "GET prn") \
92 EM(fscache_cookie_get_attach_object, "GET obj") \
93 EM(fscache_cookie_get_reacquire, "GET raq") \
94 EM(fscache_cookie_get_register_netfs, "GET net") \
95 EM(fscache_cookie_put_acquire_nobufs, "PUT nbf") \
96 EM(fscache_cookie_put_dup_netfs, "PUT dnt") \
97 EM(fscache_cookie_put_relinquish, "PUT rlq") \
98 EM(fscache_cookie_put_object, "PUT obj") \
99 E_(fscache_cookie_put_parent, "PUT prn")
101 #define fscache_page_traces \
102 EM(fscache_page_cached, "Cached ") \
103 EM(fscache_page_inval, "InvalPg") \
104 EM(fscache_page_maybe_release, "MayRels") \
105 EM(fscache_page_uncache, "Uncache") \
106 EM(fscache_page_radix_clear_store, "RxCStr ") \
107 EM(fscache_page_radix_delete, "RxDel ") \
108 EM(fscache_page_radix_insert, "RxIns ") \
109 EM(fscache_page_radix_pend2store, "RxP2S ") \
110 EM(fscache_page_radix_set_pend, "RxSPend ") \
111 EM(fscache_page_write, "WritePg") \
112 EM(fscache_page_write_end, "EndPgWr") \
113 EM(fscache_page_write_end_pend, "EndPgWP") \
114 EM(fscache_page_write_end_noc, "EndPgNC") \
115 E_(fscache_page_write_wait, "WtOnWrt")
117 #define fscache_op_traces \
118 EM(fscache_op_cancel, "Cancel1") \
119 EM(fscache_op_cancel_all, "CancelA") \
120 EM(fscache_op_cancelled, "Canclld") \
121 EM(fscache_op_completed, "Complet") \
122 EM(fscache_op_enqueue_async, "EnqAsyn") \
123 EM(fscache_op_enqueue_mythread, "EnqMyTh") \
124 EM(fscache_op_gc, "GC ") \
125 EM(fscache_op_init, "Init ") \
126 EM(fscache_op_put, "Put ") \
127 EM(fscache_op_run, "Run ") \
128 EM(fscache_op_signal, "Signal ") \
129 EM(fscache_op_submit, "Submit ") \
130 EM(fscache_op_submit_ex, "SubmitX") \
131 E_(fscache_op_work, "Work ")
133 #define fscache_page_op_traces \
134 EM(fscache_page_op_alloc_one, "Alloc1 ") \
135 EM(fscache_page_op_attr_changed, "AttrChg") \
136 EM(fscache_page_op_check_consistency, "CheckCn") \
137 EM(fscache_page_op_invalidate, "Inval ") \
138 EM(fscache_page_op_retr_multi, "RetrMul") \
139 EM(fscache_page_op_retr_one, "Retr1 ") \
140 E_(fscache_page_op_write_one, "Write1 ")
143 * Export enum symbols via userspace.
147 #define EM(a, b) TRACE_DEFINE_ENUM(a);
148 #define E_(a, b) TRACE_DEFINE_ENUM(a);
150 fscache_cookie_traces
;
153 * Now redefine the EM() and E_() macros to map the enums to the strings that
154 * will be printed in the output.
158 #define EM(a, b) { a, b },
159 #define E_(a, b) { a, b }
162 TRACE_EVENT(fscache_cookie
,
163 TP_PROTO(struct fscache_cookie
*cookie
,
164 enum fscache_cookie_trace where
,
167 TP_ARGS(cookie
, where
, usage
),
170 __field(struct fscache_cookie
*, cookie
)
171 __field(struct fscache_cookie
*, parent
)
172 __field(enum fscache_cookie_trace
, where
)
174 __field(int, n_children
)
175 __field(int, n_active
)
180 __entry
->cookie
= cookie
;
181 __entry
->parent
= cookie
->parent
;
182 __entry
->where
= where
;
183 __entry
->usage
= usage
;
184 __entry
->n_children
= atomic_read(&cookie
->n_children
);
185 __entry
->n_active
= atomic_read(&cookie
->n_active
);
186 __entry
->flags
= cookie
->flags
;
189 TP_printk("%s c=%p u=%d p=%p Nc=%d Na=%d f=%02x",
190 __print_symbolic(__entry
->where
, fscache_cookie_traces
),
191 __entry
->cookie
, __entry
->usage
,
192 __entry
->parent
, __entry
->n_children
, __entry
->n_active
,
196 TRACE_EVENT(fscache_netfs
,
197 TP_PROTO(struct fscache_netfs
*netfs
),
202 __field(struct fscache_cookie
*, cookie
)
203 __array(char, name
, 8 )
207 __entry
->cookie
= netfs
->primary_index
;
208 strncpy(__entry
->name
, netfs
->name
, 8);
209 __entry
->name
[7] = 0;
212 TP_printk("c=%p n=%s",
213 __entry
->cookie
, __entry
->name
)
216 TRACE_EVENT(fscache_acquire
,
217 TP_PROTO(struct fscache_cookie
*cookie
),
222 __field(struct fscache_cookie
*, cookie
)
223 __field(struct fscache_cookie
*, parent
)
224 __array(char, name
, 8 )
225 __field(int, p_usage
)
226 __field(int, p_n_children
)
227 __field(u8
, p_flags
)
231 __entry
->cookie
= cookie
;
232 __entry
->parent
= cookie
->parent
;
233 __entry
->p_usage
= atomic_read(&cookie
->parent
->usage
);
234 __entry
->p_n_children
= atomic_read(&cookie
->parent
->n_children
);
235 __entry
->p_flags
= cookie
->parent
->flags
;
236 memcpy(__entry
->name
, cookie
->def
->name
, 8);
237 __entry
->name
[7] = 0;
240 TP_printk("c=%p p=%p pu=%d pc=%d pf=%02x n=%s",
241 __entry
->cookie
, __entry
->parent
, __entry
->p_usage
,
242 __entry
->p_n_children
, __entry
->p_flags
, __entry
->name
)
245 TRACE_EVENT(fscache_relinquish
,
246 TP_PROTO(struct fscache_cookie
*cookie
, bool retire
),
248 TP_ARGS(cookie
, retire
),
251 __field(struct fscache_cookie
*, cookie
)
252 __field(struct fscache_cookie
*, parent
)
254 __field(int, n_children
)
255 __field(int, n_active
)
257 __field(bool, retire
)
261 __entry
->cookie
= cookie
;
262 __entry
->parent
= cookie
->parent
;
263 __entry
->usage
= atomic_read(&cookie
->usage
);
264 __entry
->n_children
= atomic_read(&cookie
->n_children
);
265 __entry
->n_active
= atomic_read(&cookie
->n_active
);
266 __entry
->flags
= cookie
->flags
;
267 __entry
->retire
= retire
;
270 TP_printk("c=%p u=%d p=%p Nc=%d Na=%d f=%02x r=%u",
271 __entry
->cookie
, __entry
->usage
,
272 __entry
->parent
, __entry
->n_children
, __entry
->n_active
,
273 __entry
->flags
, __entry
->retire
)
276 TRACE_EVENT(fscache_enable
,
277 TP_PROTO(struct fscache_cookie
*cookie
),
282 __field(struct fscache_cookie
*, cookie
)
284 __field(int, n_children
)
285 __field(int, n_active
)
290 __entry
->cookie
= cookie
;
291 __entry
->usage
= atomic_read(&cookie
->usage
);
292 __entry
->n_children
= atomic_read(&cookie
->n_children
);
293 __entry
->n_active
= atomic_read(&cookie
->n_active
);
294 __entry
->flags
= cookie
->flags
;
297 TP_printk("c=%p u=%d Nc=%d Na=%d f=%02x",
298 __entry
->cookie
, __entry
->usage
,
299 __entry
->n_children
, __entry
->n_active
, __entry
->flags
)
302 TRACE_EVENT(fscache_disable
,
303 TP_PROTO(struct fscache_cookie
*cookie
),
308 __field(struct fscache_cookie
*, cookie
)
310 __field(int, n_children
)
311 __field(int, n_active
)
316 __entry
->cookie
= cookie
;
317 __entry
->usage
= atomic_read(&cookie
->usage
);
318 __entry
->n_children
= atomic_read(&cookie
->n_children
);
319 __entry
->n_active
= atomic_read(&cookie
->n_active
);
320 __entry
->flags
= cookie
->flags
;
323 TP_printk("c=%p u=%d Nc=%d Na=%d f=%02x",
324 __entry
->cookie
, __entry
->usage
,
325 __entry
->n_children
, __entry
->n_active
, __entry
->flags
)
328 TRACE_EVENT(fscache_osm
,
329 TP_PROTO(struct fscache_object
*object
,
330 const struct fscache_state
*state
,
331 bool wait
, bool oob
, s8 event_num
),
333 TP_ARGS(object
, state
, wait
, oob
, event_num
),
336 __field(struct fscache_cookie
*, cookie
)
337 __field(struct fscache_object
*, object
)
338 __array(char, state
, 8 )
341 __field(s8
, event_num
)
345 __entry
->cookie
= object
->cookie
;
346 __entry
->object
= object
;
347 __entry
->wait
= wait
;
349 __entry
->event_num
= event_num
;
350 memcpy(__entry
->state
, state
->short_name
, 8);
353 TP_printk("c=%p o=%p %s %s%sev=%d",
357 __print_symbolic(__entry
->wait
,
360 __print_symbolic(__entry
->oob
,
366 TRACE_EVENT(fscache_page
,
367 TP_PROTO(struct fscache_cookie
*cookie
, struct page
*page
,
368 enum fscache_page_trace why
),
370 TP_ARGS(cookie
, page
, why
),
373 __field(struct fscache_cookie
*, cookie
)
374 __field(pgoff_t
, page
)
375 __field(enum fscache_page_trace
, why
)
379 __entry
->cookie
= cookie
;
380 __entry
->page
= page
->index
;
384 TP_printk("c=%p %s pg=%lx",
386 __print_symbolic(__entry
->why
, fscache_page_traces
),
390 TRACE_EVENT(fscache_check_page
,
391 TP_PROTO(struct fscache_cookie
*cookie
, struct page
*page
,
394 TP_ARGS(cookie
, page
, val
, n
),
397 __field(struct fscache_cookie
*, cookie
)
398 __field(void *, page
)
399 __field(void *, val
)
404 __entry
->cookie
= cookie
;
405 __entry
->page
= page
;
410 TP_printk("c=%p pg=%p val=%p n=%d",
411 __entry
->cookie
, __entry
->page
, __entry
->val
, __entry
->n
)
414 TRACE_EVENT(fscache_wake_cookie
,
415 TP_PROTO(struct fscache_cookie
*cookie
),
420 __field(struct fscache_cookie
*, cookie
)
424 __entry
->cookie
= cookie
;
427 TP_printk("c=%p", __entry
->cookie
)
430 TRACE_EVENT(fscache_op
,
431 TP_PROTO(struct fscache_cookie
*cookie
, struct fscache_operation
*op
,
432 enum fscache_op_trace why
),
434 TP_ARGS(cookie
, op
, why
),
437 __field(struct fscache_cookie
*, cookie
)
438 __field(struct fscache_operation
*, op
)
439 __field(enum fscache_op_trace
, why
)
443 __entry
->cookie
= cookie
;
448 TP_printk("c=%p op=%p %s",
449 __entry
->cookie
, __entry
->op
,
450 __print_symbolic(__entry
->why
, fscache_op_traces
))
453 TRACE_EVENT(fscache_page_op
,
454 TP_PROTO(struct fscache_cookie
*cookie
, struct page
*page
,
455 struct fscache_operation
*op
, enum fscache_page_op_trace what
),
457 TP_ARGS(cookie
, page
, op
, what
),
460 __field(struct fscache_cookie
*, cookie
)
461 __field(pgoff_t
, page
)
462 __field(struct fscache_operation
*, op
)
463 __field(enum fscache_page_op_trace
, what
)
467 __entry
->cookie
= cookie
;
468 __entry
->page
= page
? page
->index
: 0;
470 __entry
->what
= what
;
473 TP_printk("c=%p %s pg=%lx op=%p",
475 __print_symbolic(__entry
->what
, fscache_page_op_traces
),
476 __entry
->page
, __entry
->op
)
479 TRACE_EVENT(fscache_wrote_page
,
480 TP_PROTO(struct fscache_cookie
*cookie
, struct page
*page
,
481 struct fscache_operation
*op
, int ret
),
483 TP_ARGS(cookie
, page
, op
, ret
),
486 __field(struct fscache_cookie
*, cookie
)
487 __field(pgoff_t
, page
)
488 __field(struct fscache_operation
*, op
)
493 __entry
->cookie
= cookie
;
494 __entry
->page
= page
->index
;
499 TP_printk("c=%p pg=%lx op=%p ret=%d",
500 __entry
->cookie
, __entry
->page
, __entry
->op
, __entry
->ret
)
503 TRACE_EVENT(fscache_gang_lookup
,
504 TP_PROTO(struct fscache_cookie
*cookie
, struct fscache_operation
*op
,
505 void **results
, int n
, pgoff_t store_limit
),
507 TP_ARGS(cookie
, op
, results
, n
, store_limit
),
510 __field(struct fscache_cookie
*, cookie
)
511 __field(struct fscache_operation
*, op
)
512 __field(pgoff_t
, results0
)
514 __field(pgoff_t
, store_limit
)
518 __entry
->cookie
= cookie
;
520 __entry
->results0
= results
[0] ? ((struct page
*)results
[0])->index
: (pgoff_t
)-1;
522 __entry
->store_limit
= store_limit
;
525 TP_printk("c=%p op=%p r0=%lx n=%d sl=%lx",
526 __entry
->cookie
, __entry
->op
, __entry
->results0
, __entry
->n
,
527 __entry
->store_limit
)
530 #endif /* _TRACE_FSCACHE_H */
532 /* This part must be outside protection */
533 #include <trace/define_trace.h>