Merge tag 'trace-printf-v6.13' of git://git.kernel.org/pub/scm/linux/kernel/git/trace...
[drm/drm-misc.git] / include / trace / events / fscache.h
blobf1a73aa83fbbfbf454e13256156abee735ed213f
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)
6 */
7 #undef TRACE_SYSTEM
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,
39 fscache_volume_free,
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 {
79 fscache_active_use,
80 fscache_active_use_modify,
81 fscache_active_unuse,
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,
105 #endif
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.
191 #undef EM
192 #undef E_
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.
205 #undef EM
206 #undef E_
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,
213 int usage,
214 enum fscache_cache_trace where),
216 TP_ARGS(cache_debug_id, usage, where),
218 TP_STRUCT__entry(
219 __field(unsigned int, cache )
220 __field(int, usage )
221 __field(enum fscache_cache_trace, where )
224 TP_fast_assign(
225 __entry->cache = cache_debug_id;
226 __entry->usage = usage;
227 __entry->where = where;
230 TP_printk("C=%08x %s r=%d",
231 __entry->cache,
232 __print_symbolic(__entry->where, fscache_cache_traces),
233 __entry->usage)
236 TRACE_EVENT(fscache_volume,
237 TP_PROTO(unsigned int volume_debug_id,
238 int usage,
239 enum fscache_volume_trace where),
241 TP_ARGS(volume_debug_id, usage, where),
243 TP_STRUCT__entry(
244 __field(unsigned int, volume )
245 __field(int, usage )
246 __field(enum fscache_volume_trace, where )
249 TP_fast_assign(
250 __entry->volume = volume_debug_id;
251 __entry->usage = usage;
252 __entry->where = where;
255 TP_printk("V=%08x %s u=%d",
256 __entry->volume,
257 __print_symbolic(__entry->where, fscache_volume_traces),
258 __entry->usage)
261 TRACE_EVENT(fscache_cookie,
262 TP_PROTO(unsigned int cookie_debug_id,
263 int ref,
264 enum fscache_cookie_trace where),
266 TP_ARGS(cookie_debug_id, ref, where),
268 TP_STRUCT__entry(
269 __field(unsigned int, cookie )
270 __field(int, ref )
271 __field(enum fscache_cookie_trace, where )
274 TP_fast_assign(
275 __entry->cookie = cookie_debug_id;
276 __entry->ref = ref;
277 __entry->where = where;
280 TP_printk("c=%08x %s r=%d",
281 __entry->cookie,
282 __print_symbolic(__entry->where, fscache_cookie_traces),
283 __entry->ref)
286 TRACE_EVENT(fscache_active,
287 TP_PROTO(unsigned int cookie_debug_id,
288 int ref,
289 int n_active,
290 int n_accesses,
291 enum fscache_active_trace why),
293 TP_ARGS(cookie_debug_id, ref, n_active, n_accesses, why),
295 TP_STRUCT__entry(
296 __field(unsigned int, cookie )
297 __field(int, ref )
298 __field(int, n_active )
299 __field(int, n_accesses )
300 __field(enum fscache_active_trace, why )
303 TP_fast_assign(
304 __entry->cookie = cookie_debug_id;
305 __entry->ref = ref;
306 __entry->n_active = n_active;
307 __entry->n_accesses = n_accesses;
308 __entry->why = why;
311 TP_printk("c=%08x %s r=%d a=%d c=%d",
312 __entry->cookie,
313 __print_symbolic(__entry->why, fscache_active_traces),
314 __entry->ref,
315 __entry->n_accesses,
316 __entry->n_active)
319 TRACE_EVENT(fscache_access_cache,
320 TP_PROTO(unsigned int cache_debug_id,
321 int ref,
322 int n_accesses,
323 enum fscache_access_trace why),
325 TP_ARGS(cache_debug_id, ref, n_accesses, why),
327 TP_STRUCT__entry(
328 __field(unsigned int, cache )
329 __field(int, ref )
330 __field(int, n_accesses )
331 __field(enum fscache_access_trace, why )
334 TP_fast_assign(
335 __entry->cache = cache_debug_id;
336 __entry->ref = ref;
337 __entry->n_accesses = n_accesses;
338 __entry->why = why;
341 TP_printk("C=%08x %s r=%d a=%d",
342 __entry->cache,
343 __print_symbolic(__entry->why, fscache_access_traces),
344 __entry->ref,
345 __entry->n_accesses)
348 TRACE_EVENT(fscache_access_volume,
349 TP_PROTO(unsigned int volume_debug_id,
350 unsigned int cookie_debug_id,
351 int ref,
352 int n_accesses,
353 enum fscache_access_trace why),
355 TP_ARGS(volume_debug_id, cookie_debug_id, ref, n_accesses, why),
357 TP_STRUCT__entry(
358 __field(unsigned int, volume )
359 __field(unsigned int, cookie )
360 __field(int, ref )
361 __field(int, n_accesses )
362 __field(enum fscache_access_trace, why )
365 TP_fast_assign(
366 __entry->volume = volume_debug_id;
367 __entry->cookie = cookie_debug_id;
368 __entry->ref = ref;
369 __entry->n_accesses = n_accesses;
370 __entry->why = why;
373 TP_printk("V=%08x c=%08x %s r=%d a=%d",
374 __entry->volume,
375 __entry->cookie,
376 __print_symbolic(__entry->why, fscache_access_traces),
377 __entry->ref,
378 __entry->n_accesses)
381 TRACE_EVENT(fscache_access,
382 TP_PROTO(unsigned int cookie_debug_id,
383 int ref,
384 int n_accesses,
385 enum fscache_access_trace why),
387 TP_ARGS(cookie_debug_id, ref, n_accesses, why),
389 TP_STRUCT__entry(
390 __field(unsigned int, cookie )
391 __field(int, ref )
392 __field(int, n_accesses )
393 __field(enum fscache_access_trace, why )
396 TP_fast_assign(
397 __entry->cookie = cookie_debug_id;
398 __entry->ref = ref;
399 __entry->n_accesses = n_accesses;
400 __entry->why = why;
403 TP_printk("c=%08x %s r=%d a=%d",
404 __entry->cookie,
405 __print_symbolic(__entry->why, fscache_access_traces),
406 __entry->ref,
407 __entry->n_accesses)
410 TRACE_EVENT(fscache_acquire,
411 TP_PROTO(struct fscache_cookie *cookie),
413 TP_ARGS(cookie),
415 TP_STRUCT__entry(
416 __field(unsigned int, cookie )
417 __field(unsigned int, volume )
418 __field(int, v_ref )
419 __field(int, v_n_cookies )
422 TP_fast_assign(
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",
430 __entry->cookie,
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),
439 TP_STRUCT__entry(
440 __field(unsigned int, cookie )
441 __field(unsigned int, volume )
442 __field(int, ref )
443 __field(int, n_active )
444 __field(u8, flags )
445 __field(bool, retire )
448 TP_fast_assign(
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),
467 TP_STRUCT__entry(
468 __field(unsigned int, cookie )
469 __field(loff_t, new_size )
472 TP_fast_assign(
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),
486 TP_STRUCT__entry(
487 __field(unsigned int, cookie )
488 __field(loff_t, old_size )
489 __field(loff_t, new_size )
492 TP_fast_assign(
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",
499 __entry->cookie,
500 __entry->old_size,
501 __entry->new_size)
504 #endif /* _TRACE_FSCACHE_H */
506 /* This part must be outside protection */
507 #include <trace/define_trace.h>