1 /* FS-Cache tracepoints
3 * Copyright (C) 2016 Red Hat, Inc. All Rights Reserved.
4 * Written by David Howells (dhowells@redhat.com)
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public Licence
8 * as published by the Free Software Foundation; either version
9 * 2 of the Licence, or (at your option) any later version.
12 #define TRACE_SYSTEM fscache
14 #if !defined(_TRACE_FSCACHE_H) || defined(TRACE_HEADER_MULTI_READ)
15 #define _TRACE_FSCACHE_H
17 #include <linux/fscache.h>
18 #include <linux/tracepoint.h>
21 * Define enums for tracing information.
23 #ifndef __FSCACHE_DECLARE_TRACE_ENUMS_ONCE_ONLY
24 #define __FSCACHE_DECLARE_TRACE_ENUMS_ONCE_ONLY
26 enum fscache_cookie_trace
{
27 fscache_cookie_collision
,
28 fscache_cookie_discard
,
29 fscache_cookie_get_acquire_parent
,
30 fscache_cookie_get_attach_object
,
31 fscache_cookie_get_reacquire
,
32 fscache_cookie_get_register_netfs
,
33 fscache_cookie_put_acquire_nobufs
,
34 fscache_cookie_put_dup_netfs
,
35 fscache_cookie_put_relinquish
,
36 fscache_cookie_put_object
,
37 fscache_cookie_put_parent
,
40 enum fscache_page_trace
{
43 fscache_page_maybe_release
,
44 fscache_page_radix_clear_store
,
45 fscache_page_radix_delete
,
46 fscache_page_radix_insert
,
47 fscache_page_radix_pend2store
,
48 fscache_page_radix_set_pend
,
51 fscache_page_write_end
,
52 fscache_page_write_end_pend
,
53 fscache_page_write_end_noc
,
54 fscache_page_write_wait
,
55 fscache_page_trace__nr
58 enum fscache_op_trace
{
60 fscache_op_cancel_all
,
63 fscache_op_enqueue_async
,
64 fscache_op_enqueue_mythread
,
76 enum fscache_page_op_trace
{
77 fscache_page_op_alloc_one
,
78 fscache_page_op_attr_changed
,
79 fscache_page_op_check_consistency
,
80 fscache_page_op_invalidate
,
81 fscache_page_op_retr_multi
,
82 fscache_page_op_retr_one
,
83 fscache_page_op_write_one
,
84 fscache_page_op_trace__nr
90 * Declare tracing information enums and their string mappings for display.
92 #define fscache_cookie_traces \
93 EM(fscache_cookie_collision, "*COLLISION*") \
94 EM(fscache_cookie_discard, "DISCARD") \
95 EM(fscache_cookie_get_acquire_parent, "GET prn") \
96 EM(fscache_cookie_get_attach_object, "GET obj") \
97 EM(fscache_cookie_get_reacquire, "GET raq") \
98 EM(fscache_cookie_get_register_netfs, "GET net") \
99 EM(fscache_cookie_put_acquire_nobufs, "PUT nbf") \
100 EM(fscache_cookie_put_dup_netfs, "PUT dnt") \
101 EM(fscache_cookie_put_relinquish, "PUT rlq") \
102 EM(fscache_cookie_put_object, "PUT obj") \
103 E_(fscache_cookie_put_parent, "PUT prn")
105 #define fscache_page_traces \
106 EM(fscache_page_cached, "Cached ") \
107 EM(fscache_page_inval, "InvalPg") \
108 EM(fscache_page_maybe_release, "MayRels") \
109 EM(fscache_page_uncache, "Uncache") \
110 EM(fscache_page_radix_clear_store, "RxCStr ") \
111 EM(fscache_page_radix_delete, "RxDel ") \
112 EM(fscache_page_radix_insert, "RxIns ") \
113 EM(fscache_page_radix_pend2store, "RxP2S ") \
114 EM(fscache_page_radix_set_pend, "RxSPend ") \
115 EM(fscache_page_write, "WritePg") \
116 EM(fscache_page_write_end, "EndPgWr") \
117 EM(fscache_page_write_end_pend, "EndPgWP") \
118 EM(fscache_page_write_end_noc, "EndPgNC") \
119 E_(fscache_page_write_wait, "WtOnWrt")
121 #define fscache_op_traces \
122 EM(fscache_op_cancel, "Cancel1") \
123 EM(fscache_op_cancel_all, "CancelA") \
124 EM(fscache_op_cancelled, "Canclld") \
125 EM(fscache_op_completed, "Complet") \
126 EM(fscache_op_enqueue_async, "EnqAsyn") \
127 EM(fscache_op_enqueue_mythread, "EnqMyTh") \
128 EM(fscache_op_gc, "GC ") \
129 EM(fscache_op_init, "Init ") \
130 EM(fscache_op_put, "Put ") \
131 EM(fscache_op_run, "Run ") \
132 EM(fscache_op_signal, "Signal ") \
133 EM(fscache_op_submit, "Submit ") \
134 EM(fscache_op_submit_ex, "SubmitX") \
135 E_(fscache_op_work, "Work ")
137 #define fscache_page_op_traces \
138 EM(fscache_page_op_alloc_one, "Alloc1 ") \
139 EM(fscache_page_op_attr_changed, "AttrChg") \
140 EM(fscache_page_op_check_consistency, "CheckCn") \
141 EM(fscache_page_op_invalidate, "Inval ") \
142 EM(fscache_page_op_retr_multi, "RetrMul") \
143 EM(fscache_page_op_retr_one, "Retr1 ") \
144 E_(fscache_page_op_write_one, "Write1 ")
147 * Export enum symbols via userspace.
151 #define EM(a, b) TRACE_DEFINE_ENUM(a);
152 #define E_(a, b) TRACE_DEFINE_ENUM(a);
154 fscache_cookie_traces
;
157 * Now redefine the EM() and E_() macros to map the enums to the strings that
158 * will be printed in the output.
162 #define EM(a, b) { a, b },
163 #define E_(a, b) { a, b }
166 TRACE_EVENT(fscache_cookie
,
167 TP_PROTO(struct fscache_cookie
*cookie
,
168 enum fscache_cookie_trace where
,
171 TP_ARGS(cookie
, where
, usage
),
174 __field(struct fscache_cookie
*, cookie
)
175 __field(struct fscache_cookie
*, parent
)
176 __field(enum fscache_cookie_trace
, where
)
178 __field(int, n_children
)
179 __field(int, n_active
)
184 __entry
->cookie
= cookie
;
185 __entry
->parent
= cookie
->parent
;
186 __entry
->where
= where
;
187 __entry
->usage
= usage
;
188 __entry
->n_children
= atomic_read(&cookie
->n_children
);
189 __entry
->n_active
= atomic_read(&cookie
->n_active
);
190 __entry
->flags
= cookie
->flags
;
193 TP_printk("%s c=%p u=%d p=%p Nc=%d Na=%d f=%02x",
194 __print_symbolic(__entry
->where
, fscache_cookie_traces
),
195 __entry
->cookie
, __entry
->usage
,
196 __entry
->parent
, __entry
->n_children
, __entry
->n_active
,
200 TRACE_EVENT(fscache_netfs
,
201 TP_PROTO(struct fscache_netfs
*netfs
),
206 __field(struct fscache_cookie
*, cookie
)
207 __array(char, name
, 8 )
211 __entry
->cookie
= netfs
->primary_index
;
212 strncpy(__entry
->name
, netfs
->name
, 8);
213 __entry
->name
[7] = 0;
216 TP_printk("c=%p n=%s",
217 __entry
->cookie
, __entry
->name
)
220 TRACE_EVENT(fscache_acquire
,
221 TP_PROTO(struct fscache_cookie
*cookie
),
226 __field(struct fscache_cookie
*, cookie
)
227 __field(struct fscache_cookie
*, parent
)
228 __array(char, name
, 8 )
229 __field(int, p_usage
)
230 __field(int, p_n_children
)
231 __field(u8
, p_flags
)
235 __entry
->cookie
= cookie
;
236 __entry
->parent
= cookie
->parent
;
237 __entry
->p_usage
= atomic_read(&cookie
->parent
->usage
);
238 __entry
->p_n_children
= atomic_read(&cookie
->parent
->n_children
);
239 __entry
->p_flags
= cookie
->parent
->flags
;
240 memcpy(__entry
->name
, cookie
->def
->name
, 8);
241 __entry
->name
[7] = 0;
244 TP_printk("c=%p p=%p pu=%d pc=%d pf=%02x n=%s",
245 __entry
->cookie
, __entry
->parent
, __entry
->p_usage
,
246 __entry
->p_n_children
, __entry
->p_flags
, __entry
->name
)
249 TRACE_EVENT(fscache_relinquish
,
250 TP_PROTO(struct fscache_cookie
*cookie
, bool retire
),
252 TP_ARGS(cookie
, retire
),
255 __field(struct fscache_cookie
*, cookie
)
256 __field(struct fscache_cookie
*, parent
)
258 __field(int, n_children
)
259 __field(int, n_active
)
261 __field(bool, retire
)
265 __entry
->cookie
= cookie
;
266 __entry
->parent
= cookie
->parent
;
267 __entry
->usage
= atomic_read(&cookie
->usage
);
268 __entry
->n_children
= atomic_read(&cookie
->n_children
);
269 __entry
->n_active
= atomic_read(&cookie
->n_active
);
270 __entry
->flags
= cookie
->flags
;
271 __entry
->retire
= retire
;
274 TP_printk("c=%p u=%d p=%p Nc=%d Na=%d f=%02x r=%u",
275 __entry
->cookie
, __entry
->usage
,
276 __entry
->parent
, __entry
->n_children
, __entry
->n_active
,
277 __entry
->flags
, __entry
->retire
)
280 TRACE_EVENT(fscache_enable
,
281 TP_PROTO(struct fscache_cookie
*cookie
),
286 __field(struct fscache_cookie
*, cookie
)
288 __field(int, n_children
)
289 __field(int, n_active
)
294 __entry
->cookie
= cookie
;
295 __entry
->usage
= atomic_read(&cookie
->usage
);
296 __entry
->n_children
= atomic_read(&cookie
->n_children
);
297 __entry
->n_active
= atomic_read(&cookie
->n_active
);
298 __entry
->flags
= cookie
->flags
;
301 TP_printk("c=%p u=%d Nc=%d Na=%d f=%02x",
302 __entry
->cookie
, __entry
->usage
,
303 __entry
->n_children
, __entry
->n_active
, __entry
->flags
)
306 TRACE_EVENT(fscache_disable
,
307 TP_PROTO(struct fscache_cookie
*cookie
),
312 __field(struct fscache_cookie
*, cookie
)
314 __field(int, n_children
)
315 __field(int, n_active
)
320 __entry
->cookie
= cookie
;
321 __entry
->usage
= atomic_read(&cookie
->usage
);
322 __entry
->n_children
= atomic_read(&cookie
->n_children
);
323 __entry
->n_active
= atomic_read(&cookie
->n_active
);
324 __entry
->flags
= cookie
->flags
;
327 TP_printk("c=%p u=%d Nc=%d Na=%d f=%02x",
328 __entry
->cookie
, __entry
->usage
,
329 __entry
->n_children
, __entry
->n_active
, __entry
->flags
)
332 TRACE_EVENT(fscache_osm
,
333 TP_PROTO(struct fscache_object
*object
,
334 const struct fscache_state
*state
,
335 bool wait
, bool oob
, s8 event_num
),
337 TP_ARGS(object
, state
, wait
, oob
, event_num
),
340 __field(struct fscache_cookie
*, cookie
)
341 __field(struct fscache_object
*, object
)
342 __array(char, state
, 8 )
345 __field(s8
, event_num
)
349 __entry
->cookie
= object
->cookie
;
350 __entry
->object
= object
;
351 __entry
->wait
= wait
;
353 __entry
->event_num
= event_num
;
354 memcpy(__entry
->state
, state
->short_name
, 8);
357 TP_printk("c=%p o=%p %s %s%sev=%d",
361 __print_symbolic(__entry
->wait
,
364 __print_symbolic(__entry
->oob
,
370 TRACE_EVENT(fscache_page
,
371 TP_PROTO(struct fscache_cookie
*cookie
, struct page
*page
,
372 enum fscache_page_trace why
),
374 TP_ARGS(cookie
, page
, why
),
377 __field(struct fscache_cookie
*, cookie
)
378 __field(pgoff_t
, page
)
379 __field(enum fscache_page_trace
, why
)
383 __entry
->cookie
= cookie
;
384 __entry
->page
= page
->index
;
388 TP_printk("c=%p %s pg=%lx",
390 __print_symbolic(__entry
->why
, fscache_page_traces
),
394 TRACE_EVENT(fscache_check_page
,
395 TP_PROTO(struct fscache_cookie
*cookie
, struct page
*page
,
398 TP_ARGS(cookie
, page
, val
, n
),
401 __field(struct fscache_cookie
*, cookie
)
402 __field(void *, page
)
403 __field(void *, val
)
408 __entry
->cookie
= cookie
;
409 __entry
->page
= page
;
414 TP_printk("c=%p pg=%p val=%p n=%d",
415 __entry
->cookie
, __entry
->page
, __entry
->val
, __entry
->n
)
418 TRACE_EVENT(fscache_wake_cookie
,
419 TP_PROTO(struct fscache_cookie
*cookie
),
424 __field(struct fscache_cookie
*, cookie
)
428 __entry
->cookie
= cookie
;
431 TP_printk("c=%p", __entry
->cookie
)
434 TRACE_EVENT(fscache_op
,
435 TP_PROTO(struct fscache_cookie
*cookie
, struct fscache_operation
*op
,
436 enum fscache_op_trace why
),
438 TP_ARGS(cookie
, op
, why
),
441 __field(struct fscache_cookie
*, cookie
)
442 __field(struct fscache_operation
*, op
)
443 __field(enum fscache_op_trace
, why
)
447 __entry
->cookie
= cookie
;
452 TP_printk("c=%p op=%p %s",
453 __entry
->cookie
, __entry
->op
,
454 __print_symbolic(__entry
->why
, fscache_op_traces
))
457 TRACE_EVENT(fscache_page_op
,
458 TP_PROTO(struct fscache_cookie
*cookie
, struct page
*page
,
459 struct fscache_operation
*op
, enum fscache_page_op_trace what
),
461 TP_ARGS(cookie
, page
, op
, what
),
464 __field(struct fscache_cookie
*, cookie
)
465 __field(pgoff_t
, page
)
466 __field(struct fscache_operation
*, op
)
467 __field(enum fscache_page_op_trace
, what
)
471 __entry
->cookie
= cookie
;
472 __entry
->page
= page
? page
->index
: 0;
474 __entry
->what
= what
;
477 TP_printk("c=%p %s pg=%lx op=%p",
479 __print_symbolic(__entry
->what
, fscache_page_op_traces
),
480 __entry
->page
, __entry
->op
)
483 TRACE_EVENT(fscache_wrote_page
,
484 TP_PROTO(struct fscache_cookie
*cookie
, struct page
*page
,
485 struct fscache_operation
*op
, int ret
),
487 TP_ARGS(cookie
, page
, op
, ret
),
490 __field(struct fscache_cookie
*, cookie
)
491 __field(pgoff_t
, page
)
492 __field(struct fscache_operation
*, op
)
497 __entry
->cookie
= cookie
;
498 __entry
->page
= page
->index
;
503 TP_printk("c=%p pg=%lx op=%p ret=%d",
504 __entry
->cookie
, __entry
->page
, __entry
->op
, __entry
->ret
)
507 TRACE_EVENT(fscache_gang_lookup
,
508 TP_PROTO(struct fscache_cookie
*cookie
, struct fscache_operation
*op
,
509 void **results
, int n
, pgoff_t store_limit
),
511 TP_ARGS(cookie
, op
, results
, n
, store_limit
),
514 __field(struct fscache_cookie
*, cookie
)
515 __field(struct fscache_operation
*, op
)
516 __field(pgoff_t
, results0
)
518 __field(pgoff_t
, store_limit
)
522 __entry
->cookie
= cookie
;
524 __entry
->results0
= results
[0] ? ((struct page
*)results
[0])->index
: (pgoff_t
)-1;
526 __entry
->store_limit
= store_limit
;
529 TP_printk("c=%p op=%p r0=%lx n=%d sl=%lx",
530 __entry
->cookie
, __entry
->op
, __entry
->results0
, __entry
->n
,
531 __entry
->store_limit
)
534 #endif /* _TRACE_FSCACHE_H */
536 /* This part must be outside protection */
537 #include <trace/define_trace.h>