]> git.proxmox.com Git - mirror_ubuntu-jammy-kernel.git/blob - include/trace/events/fscache.h
Merge tag 'scsi-fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/jejb/scsi
[mirror_ubuntu-jammy-kernel.git] / include / trace / events / fscache.h
1 /* SPDX-License-Identifier: GPL-2.0-or-later */
2 /* FS-Cache tracepoints
3 *
4 * Copyright (C) 2016 Red Hat, Inc. All Rights Reserved.
5 * Written by David Howells (dhowells@redhat.com)
6 */
7 #undef TRACE_SYSTEM
8 #define TRACE_SYSTEM fscache
9
10 #if !defined(_TRACE_FSCACHE_H) || defined(TRACE_HEADER_MULTI_READ)
11 #define _TRACE_FSCACHE_H
12
13 #include <linux/fscache.h>
14 #include <linux/tracepoint.h>
15
16 /*
17 * Define enums for tracing information.
18 */
19 #ifndef __FSCACHE_DECLARE_TRACE_ENUMS_ONCE_ONLY
20 #define __FSCACHE_DECLARE_TRACE_ENUMS_ONCE_ONLY
21
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,
34 };
35
36 enum fscache_page_trace {
37 fscache_page_cached,
38 fscache_page_inval,
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,
45 fscache_page_uncache,
46 fscache_page_write,
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
52 };
53
54 enum fscache_op_trace {
55 fscache_op_cancel,
56 fscache_op_cancel_all,
57 fscache_op_cancelled,
58 fscache_op_completed,
59 fscache_op_enqueue_async,
60 fscache_op_enqueue_mythread,
61 fscache_op_gc,
62 fscache_op_init,
63 fscache_op_put,
64 fscache_op_run,
65 fscache_op_signal,
66 fscache_op_submit,
67 fscache_op_submit_ex,
68 fscache_op_work,
69 fscache_op_trace__nr
70 };
71
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
81 };
82
83 #endif
84
85 /*
86 * Declare tracing information enums and their string mappings for display.
87 */
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")
100
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")
116
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 ")
132
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 ")
141
142 /*
143 * Export enum symbols via userspace.
144 */
145 #undef EM
146 #undef E_
147 #define EM(a, b) TRACE_DEFINE_ENUM(a);
148 #define E_(a, b) TRACE_DEFINE_ENUM(a);
149
150 fscache_cookie_traces;
151
152 /*
153 * Now redefine the EM() and E_() macros to map the enums to the strings that
154 * will be printed in the output.
155 */
156 #undef EM
157 #undef E_
158 #define EM(a, b) { a, b },
159 #define E_(a, b) { a, b }
160
161
162 TRACE_EVENT(fscache_cookie,
163 TP_PROTO(unsigned int cookie_debug_id,
164 int ref,
165 enum fscache_cookie_trace where),
166
167 TP_ARGS(cookie_debug_id, ref, where),
168
169 TP_STRUCT__entry(
170 __field(unsigned int, cookie )
171 __field(enum fscache_cookie_trace, where )
172 __field(int, ref )
173 ),
174
175 TP_fast_assign(
176 __entry->cookie = cookie_debug_id;
177 __entry->where = where;
178 __entry->ref = ref;
179 ),
180
181 TP_printk("%s c=%08x r=%d",
182 __print_symbolic(__entry->where, fscache_cookie_traces),
183 __entry->cookie, __entry->ref)
184 );
185
186 TRACE_EVENT(fscache_netfs,
187 TP_PROTO(struct fscache_netfs *netfs),
188
189 TP_ARGS(netfs),
190
191 TP_STRUCT__entry(
192 __field(unsigned int, cookie )
193 __array(char, name, 8 )
194 ),
195
196 TP_fast_assign(
197 __entry->cookie = netfs->primary_index->debug_id;
198 strncpy(__entry->name, netfs->name, 8);
199 __entry->name[7] = 0;
200 ),
201
202 TP_printk("c=%08x n=%s",
203 __entry->cookie, __entry->name)
204 );
205
206 TRACE_EVENT(fscache_acquire,
207 TP_PROTO(struct fscache_cookie *cookie),
208
209 TP_ARGS(cookie),
210
211 TP_STRUCT__entry(
212 __field(unsigned int, cookie )
213 __field(unsigned int, parent )
214 __array(char, name, 8 )
215 __field(int, p_ref )
216 __field(int, p_n_children )
217 __field(u8, p_flags )
218 ),
219
220 TP_fast_assign(
221 __entry->cookie = cookie->debug_id;
222 __entry->parent = cookie->parent->debug_id;
223 __entry->p_ref = refcount_read(&cookie->parent->ref);
224 __entry->p_n_children = atomic_read(&cookie->parent->n_children);
225 __entry->p_flags = cookie->parent->flags;
226 memcpy(__entry->name, cookie->def->name, 8);
227 __entry->name[7] = 0;
228 ),
229
230 TP_printk("c=%08x p=%08x pr=%d pc=%d pf=%02x n=%s",
231 __entry->cookie, __entry->parent, __entry->p_ref,
232 __entry->p_n_children, __entry->p_flags, __entry->name)
233 );
234
235 TRACE_EVENT(fscache_relinquish,
236 TP_PROTO(struct fscache_cookie *cookie, bool retire),
237
238 TP_ARGS(cookie, retire),
239
240 TP_STRUCT__entry(
241 __field(unsigned int, cookie )
242 __field(unsigned int, parent )
243 __field(int, ref )
244 __field(int, n_children )
245 __field(int, n_active )
246 __field(u8, flags )
247 __field(bool, retire )
248 ),
249
250 TP_fast_assign(
251 __entry->cookie = cookie->debug_id;
252 __entry->parent = cookie->parent->debug_id;
253 __entry->ref = refcount_read(&cookie->ref);
254 __entry->n_children = atomic_read(&cookie->n_children);
255 __entry->n_active = atomic_read(&cookie->n_active);
256 __entry->flags = cookie->flags;
257 __entry->retire = retire;
258 ),
259
260 TP_printk("c=%08x r=%d p=%08x Nc=%d Na=%d f=%02x r=%u",
261 __entry->cookie, __entry->ref,
262 __entry->parent, __entry->n_children, __entry->n_active,
263 __entry->flags, __entry->retire)
264 );
265
266 TRACE_EVENT(fscache_enable,
267 TP_PROTO(struct fscache_cookie *cookie),
268
269 TP_ARGS(cookie),
270
271 TP_STRUCT__entry(
272 __field(unsigned int, cookie )
273 __field(int, ref )
274 __field(int, n_children )
275 __field(int, n_active )
276 __field(u8, flags )
277 ),
278
279 TP_fast_assign(
280 __entry->cookie = cookie->debug_id;
281 __entry->ref = refcount_read(&cookie->ref);
282 __entry->n_children = atomic_read(&cookie->n_children);
283 __entry->n_active = atomic_read(&cookie->n_active);
284 __entry->flags = cookie->flags;
285 ),
286
287 TP_printk("c=%08x r=%d Nc=%d Na=%d f=%02x",
288 __entry->cookie, __entry->ref,
289 __entry->n_children, __entry->n_active, __entry->flags)
290 );
291
292 TRACE_EVENT(fscache_disable,
293 TP_PROTO(struct fscache_cookie *cookie),
294
295 TP_ARGS(cookie),
296
297 TP_STRUCT__entry(
298 __field(unsigned int, cookie )
299 __field(int, ref )
300 __field(int, n_children )
301 __field(int, n_active )
302 __field(u8, flags )
303 ),
304
305 TP_fast_assign(
306 __entry->cookie = cookie->debug_id;
307 __entry->ref = refcount_read(&cookie->ref);
308 __entry->n_children = atomic_read(&cookie->n_children);
309 __entry->n_active = atomic_read(&cookie->n_active);
310 __entry->flags = cookie->flags;
311 ),
312
313 TP_printk("c=%08x r=%d Nc=%d Na=%d f=%02x",
314 __entry->cookie, __entry->ref,
315 __entry->n_children, __entry->n_active, __entry->flags)
316 );
317
318 TRACE_EVENT(fscache_osm,
319 TP_PROTO(struct fscache_object *object,
320 const struct fscache_state *state,
321 bool wait, bool oob, s8 event_num),
322
323 TP_ARGS(object, state, wait, oob, event_num),
324
325 TP_STRUCT__entry(
326 __field(unsigned int, cookie )
327 __field(unsigned int, object )
328 __array(char, state, 8 )
329 __field(bool, wait )
330 __field(bool, oob )
331 __field(s8, event_num )
332 ),
333
334 TP_fast_assign(
335 __entry->cookie = object->cookie->debug_id;
336 __entry->object = object->debug_id;
337 __entry->wait = wait;
338 __entry->oob = oob;
339 __entry->event_num = event_num;
340 memcpy(__entry->state, state->short_name, 8);
341 ),
342
343 TP_printk("c=%08x o=%08d %s %s%sev=%d",
344 __entry->cookie,
345 __entry->object,
346 __entry->state,
347 __print_symbolic(__entry->wait,
348 { true, "WAIT" },
349 { false, "WORK" }),
350 __print_symbolic(__entry->oob,
351 { true, " OOB " },
352 { false, " " }),
353 __entry->event_num)
354 );
355
356 TRACE_EVENT(fscache_page,
357 TP_PROTO(struct fscache_cookie *cookie, struct page *page,
358 enum fscache_page_trace why),
359
360 TP_ARGS(cookie, page, why),
361
362 TP_STRUCT__entry(
363 __field(unsigned int, cookie )
364 __field(pgoff_t, page )
365 __field(enum fscache_page_trace, why )
366 ),
367
368 TP_fast_assign(
369 __entry->cookie = cookie->debug_id;
370 __entry->page = page->index;
371 __entry->why = why;
372 ),
373
374 TP_printk("c=%08x %s pg=%lx",
375 __entry->cookie,
376 __print_symbolic(__entry->why, fscache_page_traces),
377 __entry->page)
378 );
379
380 TRACE_EVENT(fscache_check_page,
381 TP_PROTO(struct fscache_cookie *cookie, struct page *page,
382 void *val, int n),
383
384 TP_ARGS(cookie, page, val, n),
385
386 TP_STRUCT__entry(
387 __field(unsigned int, cookie )
388 __field(void *, page )
389 __field(void *, val )
390 __field(int, n )
391 ),
392
393 TP_fast_assign(
394 __entry->cookie = cookie->debug_id;
395 __entry->page = page;
396 __entry->val = val;
397 __entry->n = n;
398 ),
399
400 TP_printk("c=%08x pg=%p val=%p n=%d",
401 __entry->cookie, __entry->page, __entry->val, __entry->n)
402 );
403
404 TRACE_EVENT(fscache_wake_cookie,
405 TP_PROTO(struct fscache_cookie *cookie),
406
407 TP_ARGS(cookie),
408
409 TP_STRUCT__entry(
410 __field(unsigned int, cookie )
411 ),
412
413 TP_fast_assign(
414 __entry->cookie = cookie->debug_id;
415 ),
416
417 TP_printk("c=%08x", __entry->cookie)
418 );
419
420 TRACE_EVENT(fscache_op,
421 TP_PROTO(struct fscache_cookie *cookie, struct fscache_operation *op,
422 enum fscache_op_trace why),
423
424 TP_ARGS(cookie, op, why),
425
426 TP_STRUCT__entry(
427 __field(unsigned int, cookie )
428 __field(unsigned int, op )
429 __field(enum fscache_op_trace, why )
430 ),
431
432 TP_fast_assign(
433 __entry->cookie = cookie ? cookie->debug_id : 0;
434 __entry->op = op->debug_id;
435 __entry->why = why;
436 ),
437
438 TP_printk("c=%08x op=%08x %s",
439 __entry->cookie, __entry->op,
440 __print_symbolic(__entry->why, fscache_op_traces))
441 );
442
443 TRACE_EVENT(fscache_page_op,
444 TP_PROTO(struct fscache_cookie *cookie, struct page *page,
445 struct fscache_operation *op, enum fscache_page_op_trace what),
446
447 TP_ARGS(cookie, page, op, what),
448
449 TP_STRUCT__entry(
450 __field(unsigned int, cookie )
451 __field(unsigned int, op )
452 __field(pgoff_t, page )
453 __field(enum fscache_page_op_trace, what )
454 ),
455
456 TP_fast_assign(
457 __entry->cookie = cookie->debug_id;
458 __entry->page = page ? page->index : 0;
459 __entry->op = op->debug_id;
460 __entry->what = what;
461 ),
462
463 TP_printk("c=%08x %s pg=%lx op=%08x",
464 __entry->cookie,
465 __print_symbolic(__entry->what, fscache_page_op_traces),
466 __entry->page, __entry->op)
467 );
468
469 TRACE_EVENT(fscache_wrote_page,
470 TP_PROTO(struct fscache_cookie *cookie, struct page *page,
471 struct fscache_operation *op, int ret),
472
473 TP_ARGS(cookie, page, op, ret),
474
475 TP_STRUCT__entry(
476 __field(unsigned int, cookie )
477 __field(unsigned int, op )
478 __field(pgoff_t, page )
479 __field(int, ret )
480 ),
481
482 TP_fast_assign(
483 __entry->cookie = cookie->debug_id;
484 __entry->page = page->index;
485 __entry->op = op->debug_id;
486 __entry->ret = ret;
487 ),
488
489 TP_printk("c=%08x pg=%lx op=%08x ret=%d",
490 __entry->cookie, __entry->page, __entry->op, __entry->ret)
491 );
492
493 TRACE_EVENT(fscache_gang_lookup,
494 TP_PROTO(struct fscache_cookie *cookie, struct fscache_operation *op,
495 void **results, int n, pgoff_t store_limit),
496
497 TP_ARGS(cookie, op, results, n, store_limit),
498
499 TP_STRUCT__entry(
500 __field(unsigned int, cookie )
501 __field(unsigned int, op )
502 __field(pgoff_t, results0 )
503 __field(int, n )
504 __field(pgoff_t, store_limit )
505 ),
506
507 TP_fast_assign(
508 __entry->cookie = cookie->debug_id;
509 __entry->op = op->debug_id;
510 __entry->results0 = results[0] ? ((struct page *)results[0])->index : (pgoff_t)-1;
511 __entry->n = n;
512 __entry->store_limit = store_limit;
513 ),
514
515 TP_printk("c=%08x op=%08x r0=%lx n=%d sl=%lx",
516 __entry->cookie, __entry->op, __entry->results0, __entry->n,
517 __entry->store_limit)
518 );
519
520 #endif /* _TRACE_FSCACHE_H */
521
522 /* This part must be outside protection */
523 #include <trace/define_trace.h>