1 /* SPDX-License-Identifier: GPL-2.0-or-later */
2 /* FS-Cache tracepoints
4 * Copyright (C) 2021 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_cache_trace
{
23 fscache_cache_collision
,
24 fscache_cache_get_acquire
,
25 fscache_cache_new_acquire
,
26 fscache_cache_put_alloc_volume
,
27 fscache_cache_put_cache
,
28 fscache_cache_put_prep_failed
,
29 fscache_cache_put_relinquish
,
30 fscache_cache_put_volume
,
33 enum fscache_volume_trace
{
34 fscache_volume_collision
,
35 fscache_volume_get_cookie
,
36 fscache_volume_get_create_work
,
37 fscache_volume_get_hash_collision
,
38 fscache_volume_get_withdraw
,
40 fscache_volume_new_acquire
,
41 fscache_volume_put_cookie
,
42 fscache_volume_put_create_work
,
43 fscache_volume_put_hash_collision
,
44 fscache_volume_put_relinquish
,
45 fscache_volume_put_withdraw
,
46 fscache_volume_see_create_work
,
47 fscache_volume_see_hash_wake
,
48 fscache_volume_wait_create_work
,
51 enum fscache_cookie_trace
{
52 fscache_cookie_collision
,
53 fscache_cookie_discard
,
54 fscache_cookie_failed
,
55 fscache_cookie_get_attach_object
,
56 fscache_cookie_get_end_access
,
57 fscache_cookie_get_hash_collision
,
58 fscache_cookie_get_inval_work
,
59 fscache_cookie_get_lru
,
60 fscache_cookie_get_use_work
,
61 fscache_cookie_new_acquire
,
62 fscache_cookie_put_hash_collision
,
63 fscache_cookie_put_lru
,
64 fscache_cookie_put_object
,
65 fscache_cookie_put_over_queued
,
66 fscache_cookie_put_relinquish
,
67 fscache_cookie_put_withdrawn
,
68 fscache_cookie_put_work
,
69 fscache_cookie_see_active
,
70 fscache_cookie_see_lru_discard
,
71 fscache_cookie_see_lru_discard_clear
,
72 fscache_cookie_see_lru_do_one
,
73 fscache_cookie_see_relinquish
,
74 fscache_cookie_see_withdraw
,
75 fscache_cookie_see_work
,
78 enum fscache_active_trace
{
80 fscache_active_use_modify
,
84 enum fscache_access_trace
{
85 fscache_access_acquire_volume
,
86 fscache_access_acquire_volume_end
,
87 fscache_access_cache_pin
,
88 fscache_access_cache_unpin
,
89 fscache_access_invalidate_cookie
,
90 fscache_access_invalidate_cookie_end
,
91 fscache_access_io_end
,
92 fscache_access_io_not_live
,
93 fscache_access_io_read
,
94 fscache_access_io_resize
,
95 fscache_access_io_wait
,
96 fscache_access_io_write
,
97 fscache_access_lookup_cookie
,
98 fscache_access_lookup_cookie_end
,
99 fscache_access_lookup_cookie_end_failed
,
100 fscache_access_relinquish_volume
,
101 fscache_access_relinquish_volume_end
,
102 fscache_access_unlive
,
108 * Declare tracing information enums and their string mappings for display.
110 #define fscache_cache_traces \
111 EM(fscache_cache_collision, "*COLLIDE*") \
112 EM(fscache_cache_get_acquire, "GET acq ") \
113 EM(fscache_cache_new_acquire, "NEW acq ") \
114 EM(fscache_cache_put_alloc_volume, "PUT alvol") \
115 EM(fscache_cache_put_cache, "PUT cache") \
116 EM(fscache_cache_put_prep_failed, "PUT pfail") \
117 EM(fscache_cache_put_relinquish, "PUT relnq") \
118 E_(fscache_cache_put_volume, "PUT vol ")
120 #define fscache_volume_traces \
121 EM(fscache_volume_collision, "*COLLIDE*") \
122 EM(fscache_volume_get_cookie, "GET cook ") \
123 EM(fscache_volume_get_create_work, "GET creat") \
124 EM(fscache_volume_get_hash_collision, "GET hcoll") \
125 EM(fscache_volume_get_withdraw, "GET withd") \
126 EM(fscache_volume_free, "FREE ") \
127 EM(fscache_volume_new_acquire, "NEW acq ") \
128 EM(fscache_volume_put_cookie, "PUT cook ") \
129 EM(fscache_volume_put_create_work, "PUT creat") \
130 EM(fscache_volume_put_hash_collision, "PUT hcoll") \
131 EM(fscache_volume_put_relinquish, "PUT relnq") \
132 EM(fscache_volume_put_withdraw, "PUT withd") \
133 EM(fscache_volume_see_create_work, "SEE creat") \
134 EM(fscache_volume_see_hash_wake, "SEE hwake") \
135 E_(fscache_volume_wait_create_work, "WAIT crea")
137 #define fscache_cookie_traces \
138 EM(fscache_cookie_collision, "*COLLIDE*") \
139 EM(fscache_cookie_discard, "DISCARD ") \
140 EM(fscache_cookie_failed, "FAILED ") \
141 EM(fscache_cookie_get_attach_object, "GET attch") \
142 EM(fscache_cookie_get_hash_collision, "GET hcoll") \
143 EM(fscache_cookie_get_end_access, "GQ endac") \
144 EM(fscache_cookie_get_inval_work, "GQ inval") \
145 EM(fscache_cookie_get_lru, "GET lru ") \
146 EM(fscache_cookie_get_use_work, "GQ use ") \
147 EM(fscache_cookie_new_acquire, "NEW acq ") \
148 EM(fscache_cookie_put_hash_collision, "PUT hcoll") \
149 EM(fscache_cookie_put_lru, "PUT lru ") \
150 EM(fscache_cookie_put_object, "PUT obj ") \
151 EM(fscache_cookie_put_over_queued, "PQ overq") \
152 EM(fscache_cookie_put_relinquish, "PUT relnq") \
153 EM(fscache_cookie_put_withdrawn, "PUT wthdn") \
154 EM(fscache_cookie_put_work, "PQ work ") \
155 EM(fscache_cookie_see_active, "- activ") \
156 EM(fscache_cookie_see_lru_discard, "- x-lru") \
157 EM(fscache_cookie_see_lru_discard_clear,"- lrudc") \
158 EM(fscache_cookie_see_lru_do_one, "- lrudo") \
159 EM(fscache_cookie_see_relinquish, "- x-rlq") \
160 EM(fscache_cookie_see_withdraw, "- x-wth") \
161 E_(fscache_cookie_see_work, "- work ")
163 #define fscache_active_traces \
164 EM(fscache_active_use, "USE ") \
165 EM(fscache_active_use_modify, "USE-m ") \
166 E_(fscache_active_unuse, "UNUSE ")
168 #define fscache_access_traces \
169 EM(fscache_access_acquire_volume, "BEGIN acq_vol") \
170 EM(fscache_access_acquire_volume_end, "END acq_vol") \
171 EM(fscache_access_cache_pin, "PIN cache ") \
172 EM(fscache_access_cache_unpin, "UNPIN cache ") \
173 EM(fscache_access_invalidate_cookie, "BEGIN inval ") \
174 EM(fscache_access_invalidate_cookie_end,"END inval ") \
175 EM(fscache_access_io_end, "END io ") \
176 EM(fscache_access_io_not_live, "END io_notl") \
177 EM(fscache_access_io_read, "BEGIN io_read") \
178 EM(fscache_access_io_resize, "BEGIN io_resz") \
179 EM(fscache_access_io_wait, "WAIT io ") \
180 EM(fscache_access_io_write, "BEGIN io_writ") \
181 EM(fscache_access_lookup_cookie, "BEGIN lookup ") \
182 EM(fscache_access_lookup_cookie_end, "END lookup ") \
183 EM(fscache_access_lookup_cookie_end_failed,"END lookupf") \
184 EM(fscache_access_relinquish_volume, "BEGIN rlq_vol") \
185 EM(fscache_access_relinquish_volume_end,"END rlq_vol") \
186 E_(fscache_access_unlive, "END unlive ")
189 * Export enum symbols via userspace.
193 #define EM(a, b) TRACE_DEFINE_ENUM(a);
194 #define E_(a, b) TRACE_DEFINE_ENUM(a);
196 fscache_cache_traces
;
197 fscache_volume_traces
;
198 fscache_cookie_traces
;
199 fscache_access_traces
;
202 * Now redefine the EM() and E_() macros to map the enums to the strings that
203 * will be printed in the output.
207 #define EM(a, b) { a, b },
208 #define E_(a, b) { a, b }
211 TRACE_EVENT(fscache_cache
,
212 TP_PROTO(unsigned int cache_debug_id
,
214 enum fscache_cache_trace where
),
216 TP_ARGS(cache_debug_id
, usage
, where
),
219 __field(unsigned int, cache
)
221 __field(enum fscache_cache_trace
, where
)
225 __entry
->cache
= cache_debug_id
;
226 __entry
->usage
= usage
;
227 __entry
->where
= where
;
230 TP_printk("C=%08x %s r=%d",
232 __print_symbolic(__entry
->where
, fscache_cache_traces
),
236 TRACE_EVENT(fscache_volume
,
237 TP_PROTO(unsigned int volume_debug_id
,
239 enum fscache_volume_trace where
),
241 TP_ARGS(volume_debug_id
, usage
, where
),
244 __field(unsigned int, volume
)
246 __field(enum fscache_volume_trace
, where
)
250 __entry
->volume
= volume_debug_id
;
251 __entry
->usage
= usage
;
252 __entry
->where
= where
;
255 TP_printk("V=%08x %s u=%d",
257 __print_symbolic(__entry
->where
, fscache_volume_traces
),
261 TRACE_EVENT(fscache_cookie
,
262 TP_PROTO(unsigned int cookie_debug_id
,
264 enum fscache_cookie_trace where
),
266 TP_ARGS(cookie_debug_id
, ref
, where
),
269 __field(unsigned int, cookie
)
271 __field(enum fscache_cookie_trace
, where
)
275 __entry
->cookie
= cookie_debug_id
;
277 __entry
->where
= where
;
280 TP_printk("c=%08x %s r=%d",
282 __print_symbolic(__entry
->where
, fscache_cookie_traces
),
286 TRACE_EVENT(fscache_active
,
287 TP_PROTO(unsigned int cookie_debug_id
,
291 enum fscache_active_trace why
),
293 TP_ARGS(cookie_debug_id
, ref
, n_active
, n_accesses
, why
),
296 __field(unsigned int, cookie
)
298 __field(int, n_active
)
299 __field(int, n_accesses
)
300 __field(enum fscache_active_trace
, why
)
304 __entry
->cookie
= cookie_debug_id
;
306 __entry
->n_active
= n_active
;
307 __entry
->n_accesses
= n_accesses
;
311 TP_printk("c=%08x %s r=%d a=%d c=%d",
313 __print_symbolic(__entry
->why
, fscache_active_traces
),
319 TRACE_EVENT(fscache_access_cache
,
320 TP_PROTO(unsigned int cache_debug_id
,
323 enum fscache_access_trace why
),
325 TP_ARGS(cache_debug_id
, ref
, n_accesses
, why
),
328 __field(unsigned int, cache
)
330 __field(int, n_accesses
)
331 __field(enum fscache_access_trace
, why
)
335 __entry
->cache
= cache_debug_id
;
337 __entry
->n_accesses
= n_accesses
;
341 TP_printk("C=%08x %s r=%d a=%d",
343 __print_symbolic(__entry
->why
, fscache_access_traces
),
348 TRACE_EVENT(fscache_access_volume
,
349 TP_PROTO(unsigned int volume_debug_id
,
350 unsigned int cookie_debug_id
,
353 enum fscache_access_trace why
),
355 TP_ARGS(volume_debug_id
, cookie_debug_id
, ref
, n_accesses
, why
),
358 __field(unsigned int, volume
)
359 __field(unsigned int, cookie
)
361 __field(int, n_accesses
)
362 __field(enum fscache_access_trace
, why
)
366 __entry
->volume
= volume_debug_id
;
367 __entry
->cookie
= cookie_debug_id
;
369 __entry
->n_accesses
= n_accesses
;
373 TP_printk("V=%08x c=%08x %s r=%d a=%d",
376 __print_symbolic(__entry
->why
, fscache_access_traces
),
381 TRACE_EVENT(fscache_access
,
382 TP_PROTO(unsigned int cookie_debug_id
,
385 enum fscache_access_trace why
),
387 TP_ARGS(cookie_debug_id
, ref
, n_accesses
, why
),
390 __field(unsigned int, cookie
)
392 __field(int, n_accesses
)
393 __field(enum fscache_access_trace
, why
)
397 __entry
->cookie
= cookie_debug_id
;
399 __entry
->n_accesses
= n_accesses
;
403 TP_printk("c=%08x %s r=%d a=%d",
405 __print_symbolic(__entry
->why
, fscache_access_traces
),
410 TRACE_EVENT(fscache_acquire
,
411 TP_PROTO(struct fscache_cookie
*cookie
),
416 __field(unsigned int, cookie
)
417 __field(unsigned int, volume
)
419 __field(int, v_n_cookies
)
423 __entry
->cookie
= cookie
->debug_id
;
424 __entry
->volume
= cookie
->volume
->debug_id
;
425 __entry
->v_ref
= refcount_read(&cookie
->volume
->ref
);
426 __entry
->v_n_cookies
= atomic_read(&cookie
->volume
->n_cookies
);
429 TP_printk("c=%08x V=%08x vr=%d vc=%d",
431 __entry
->volume
, __entry
->v_ref
, __entry
->v_n_cookies
)
434 TRACE_EVENT(fscache_relinquish
,
435 TP_PROTO(struct fscache_cookie
*cookie
, bool retire
),
437 TP_ARGS(cookie
, retire
),
440 __field(unsigned int, cookie
)
441 __field(unsigned int, volume
)
443 __field(int, n_active
)
445 __field(bool, retire
)
449 __entry
->cookie
= cookie
->debug_id
;
450 __entry
->volume
= cookie
->volume
->debug_id
;
451 __entry
->ref
= refcount_read(&cookie
->ref
);
452 __entry
->n_active
= atomic_read(&cookie
->n_active
);
453 __entry
->flags
= cookie
->flags
;
454 __entry
->retire
= retire
;
457 TP_printk("c=%08x V=%08x r=%d U=%d f=%02x rt=%u",
458 __entry
->cookie
, __entry
->volume
, __entry
->ref
,
459 __entry
->n_active
, __entry
->flags
, __entry
->retire
)
462 TRACE_EVENT(fscache_invalidate
,
463 TP_PROTO(struct fscache_cookie
*cookie
, loff_t new_size
),
465 TP_ARGS(cookie
, new_size
),
468 __field(unsigned int, cookie
)
469 __field(loff_t
, new_size
)
473 __entry
->cookie
= cookie
->debug_id
;
474 __entry
->new_size
= new_size
;
477 TP_printk("c=%08x sz=%llx",
478 __entry
->cookie
, __entry
->new_size
)
481 TRACE_EVENT(fscache_resize
,
482 TP_PROTO(struct fscache_cookie
*cookie
, loff_t new_size
),
484 TP_ARGS(cookie
, new_size
),
487 __field(unsigned int, cookie
)
488 __field(loff_t
, old_size
)
489 __field(loff_t
, new_size
)
493 __entry
->cookie
= cookie
->debug_id
;
494 __entry
->old_size
= cookie
->object_size
;
495 __entry
->new_size
= new_size
;
498 TP_printk("c=%08x os=%08llx sz=%08llx",
504 #endif /* _TRACE_FSCACHE_H */
506 /* This part must be outside protection */
507 #include <trace/define_trace.h>