xref: /openbmc/linux/include/trace/events/fscache.h (revision 23e12e28)
11e1236b8SDavid Howells /* SPDX-License-Identifier: GPL-2.0-or-later */
21e1236b8SDavid Howells /* FS-Cache tracepoints
31e1236b8SDavid Howells  *
41e1236b8SDavid Howells  * Copyright (C) 2021 Red Hat, Inc. All Rights Reserved.
51e1236b8SDavid Howells  * Written by David Howells (dhowells@redhat.com)
61e1236b8SDavid Howells  */
71e1236b8SDavid Howells #undef TRACE_SYSTEM
81e1236b8SDavid Howells #define TRACE_SYSTEM fscache
91e1236b8SDavid Howells 
101e1236b8SDavid Howells #if !defined(_TRACE_FSCACHE_H) || defined(TRACE_HEADER_MULTI_READ)
111e1236b8SDavid Howells #define _TRACE_FSCACHE_H
121e1236b8SDavid Howells 
131e1236b8SDavid Howells #include <linux/fscache.h>
141e1236b8SDavid Howells #include <linux/tracepoint.h>
151e1236b8SDavid Howells 
161e1236b8SDavid Howells /*
171e1236b8SDavid Howells  * Define enums for tracing information.
181e1236b8SDavid Howells  */
191e1236b8SDavid Howells #ifndef __FSCACHE_DECLARE_TRACE_ENUMS_ONCE_ONLY
201e1236b8SDavid Howells #define __FSCACHE_DECLARE_TRACE_ENUMS_ONCE_ONLY
211e1236b8SDavid Howells 
229549332dSDavid Howells enum fscache_cache_trace {
239549332dSDavid Howells 	fscache_cache_collision,
249549332dSDavid Howells 	fscache_cache_get_acquire,
259549332dSDavid Howells 	fscache_cache_new_acquire,
2662ab6335SDavid Howells 	fscache_cache_put_alloc_volume,
279549332dSDavid Howells 	fscache_cache_put_cache,
289549332dSDavid Howells 	fscache_cache_put_prep_failed,
299549332dSDavid Howells 	fscache_cache_put_relinquish,
3062ab6335SDavid Howells 	fscache_cache_put_volume,
3162ab6335SDavid Howells };
3262ab6335SDavid Howells 
3362ab6335SDavid Howells enum fscache_volume_trace {
3462ab6335SDavid Howells 	fscache_volume_collision,
3562ab6335SDavid Howells 	fscache_volume_get_cookie,
3662ab6335SDavid Howells 	fscache_volume_get_create_work,
3762ab6335SDavid Howells 	fscache_volume_get_hash_collision,
3862ab6335SDavid Howells 	fscache_volume_free,
3962ab6335SDavid Howells 	fscache_volume_new_acquire,
4062ab6335SDavid Howells 	fscache_volume_put_cookie,
4162ab6335SDavid Howells 	fscache_volume_put_create_work,
4262ab6335SDavid Howells 	fscache_volume_put_hash_collision,
4362ab6335SDavid Howells 	fscache_volume_put_relinquish,
4462ab6335SDavid Howells 	fscache_volume_see_create_work,
4562ab6335SDavid Howells 	fscache_volume_see_hash_wake,
469549332dSDavid Howells };
479549332dSDavid Howells 
487f3283abSDavid Howells enum fscache_cookie_trace {
497f3283abSDavid Howells 	fscache_cookie_collision,
507f3283abSDavid Howells 	fscache_cookie_discard,
517f3283abSDavid Howells 	fscache_cookie_get_end_access,
527f3283abSDavid Howells 	fscache_cookie_get_hash_collision,
537f3283abSDavid Howells 	fscache_cookie_new_acquire,
547f3283abSDavid Howells 	fscache_cookie_put_hash_collision,
557f3283abSDavid Howells 	fscache_cookie_put_over_queued,
567f3283abSDavid Howells 	fscache_cookie_put_relinquish,
577f3283abSDavid Howells 	fscache_cookie_put_withdrawn,
587f3283abSDavid Howells 	fscache_cookie_put_work,
597f3283abSDavid Howells 	fscache_cookie_see_active,
607f3283abSDavid Howells 	fscache_cookie_see_relinquish,
617f3283abSDavid Howells 	fscache_cookie_see_withdraw,
627f3283abSDavid Howells 	fscache_cookie_see_work,
637f3283abSDavid Howells };
647f3283abSDavid Howells 
65*23e12e28SDavid Howells enum fscache_access_trace {
66*23e12e28SDavid Howells 	fscache_access_cache_pin,
67*23e12e28SDavid Howells 	fscache_access_cache_unpin,
68*23e12e28SDavid Howells 	fscache_access_unlive,
69*23e12e28SDavid Howells };
70*23e12e28SDavid Howells 
711e1236b8SDavid Howells #endif
721e1236b8SDavid Howells 
731e1236b8SDavid Howells /*
741e1236b8SDavid Howells  * Declare tracing information enums and their string mappings for display.
751e1236b8SDavid Howells  */
769549332dSDavid Howells #define fscache_cache_traces						\
779549332dSDavid Howells 	EM(fscache_cache_collision,		"*COLLIDE*")		\
789549332dSDavid Howells 	EM(fscache_cache_get_acquire,		"GET acq  ")		\
799549332dSDavid Howells 	EM(fscache_cache_new_acquire,		"NEW acq  ")		\
8062ab6335SDavid Howells 	EM(fscache_cache_put_alloc_volume,	"PUT alvol")		\
819549332dSDavid Howells 	EM(fscache_cache_put_cache,		"PUT cache")		\
829549332dSDavid Howells 	EM(fscache_cache_put_prep_failed,	"PUT pfail")		\
8362ab6335SDavid Howells 	EM(fscache_cache_put_relinquish,	"PUT relnq")		\
8462ab6335SDavid Howells 	E_(fscache_cache_put_volume,		"PUT vol  ")
8562ab6335SDavid Howells 
8662ab6335SDavid Howells #define fscache_volume_traces						\
8762ab6335SDavid Howells 	EM(fscache_volume_collision,		"*COLLIDE*")		\
8862ab6335SDavid Howells 	EM(fscache_volume_get_cookie,		"GET cook ")		\
8962ab6335SDavid Howells 	EM(fscache_volume_get_create_work,	"GET creat")		\
9062ab6335SDavid Howells 	EM(fscache_volume_get_hash_collision,	"GET hcoll")		\
9162ab6335SDavid Howells 	EM(fscache_volume_free,			"FREE     ")		\
9262ab6335SDavid Howells 	EM(fscache_volume_new_acquire,		"NEW acq  ")		\
9362ab6335SDavid Howells 	EM(fscache_volume_put_cookie,		"PUT cook ")		\
9462ab6335SDavid Howells 	EM(fscache_volume_put_create_work,	"PUT creat")		\
9562ab6335SDavid Howells 	EM(fscache_volume_put_hash_collision,	"PUT hcoll")		\
9662ab6335SDavid Howells 	EM(fscache_volume_put_relinquish,	"PUT relnq")		\
9762ab6335SDavid Howells 	EM(fscache_volume_see_create_work,	"SEE creat")		\
9862ab6335SDavid Howells 	E_(fscache_volume_see_hash_wake,	"SEE hwake")
991e1236b8SDavid Howells 
1007f3283abSDavid Howells #define fscache_cookie_traces						\
1017f3283abSDavid Howells 	EM(fscache_cookie_collision,		"*COLLIDE*")		\
1027f3283abSDavid Howells 	EM(fscache_cookie_discard,		"DISCARD  ")		\
1037f3283abSDavid Howells 	EM(fscache_cookie_get_hash_collision,	"GET hcoll")		\
1047f3283abSDavid Howells 	EM(fscache_cookie_get_end_access,	"GQ  endac")		\
1057f3283abSDavid Howells 	EM(fscache_cookie_new_acquire,		"NEW acq  ")		\
1067f3283abSDavid Howells 	EM(fscache_cookie_put_hash_collision,	"PUT hcoll")		\
1077f3283abSDavid Howells 	EM(fscache_cookie_put_over_queued,	"PQ  overq")		\
1087f3283abSDavid Howells 	EM(fscache_cookie_put_relinquish,	"PUT relnq")		\
1097f3283abSDavid Howells 	EM(fscache_cookie_put_withdrawn,	"PUT wthdn")		\
1107f3283abSDavid Howells 	EM(fscache_cookie_put_work,		"PQ  work ")		\
1117f3283abSDavid Howells 	EM(fscache_cookie_see_active,		"-   activ")		\
1127f3283abSDavid Howells 	EM(fscache_cookie_see_relinquish,	"-   x-rlq")		\
1137f3283abSDavid Howells 	EM(fscache_cookie_see_withdraw,		"-   x-wth")		\
1147f3283abSDavid Howells 	E_(fscache_cookie_see_work,		"-   work ")
1157f3283abSDavid Howells 
116*23e12e28SDavid Howells #define fscache_access_traces		\
117*23e12e28SDavid Howells 	EM(fscache_access_cache_pin,		"PIN   cache  ")	\
118*23e12e28SDavid Howells 	EM(fscache_access_cache_unpin,		"UNPIN cache  ")	\
119*23e12e28SDavid Howells 	E_(fscache_access_unlive,		"END   unlive ")
120*23e12e28SDavid Howells 
1211e1236b8SDavid Howells /*
1221e1236b8SDavid Howells  * Export enum symbols via userspace.
1231e1236b8SDavid Howells  */
1241e1236b8SDavid Howells #undef EM
1251e1236b8SDavid Howells #undef E_
1261e1236b8SDavid Howells #define EM(a, b) TRACE_DEFINE_ENUM(a);
1271e1236b8SDavid Howells #define E_(a, b) TRACE_DEFINE_ENUM(a);
1281e1236b8SDavid Howells 
1299549332dSDavid Howells fscache_cache_traces;
13062ab6335SDavid Howells fscache_volume_traces;
1317f3283abSDavid Howells fscache_cookie_traces;
132*23e12e28SDavid Howells fscache_access_traces;
1339549332dSDavid Howells 
1341e1236b8SDavid Howells /*
1351e1236b8SDavid Howells  * Now redefine the EM() and E_() macros to map the enums to the strings that
1361e1236b8SDavid Howells  * will be printed in the output.
1371e1236b8SDavid Howells  */
1381e1236b8SDavid Howells #undef EM
1391e1236b8SDavid Howells #undef E_
1401e1236b8SDavid Howells #define EM(a, b)	{ a, b },
1411e1236b8SDavid Howells #define E_(a, b)	{ a, b }
1421e1236b8SDavid Howells 
1431e1236b8SDavid Howells 
1449549332dSDavid Howells TRACE_EVENT(fscache_cache,
1459549332dSDavid Howells 	    TP_PROTO(unsigned int cache_debug_id,
1469549332dSDavid Howells 		     int usage,
1479549332dSDavid Howells 		     enum fscache_cache_trace where),
1489549332dSDavid Howells 
1499549332dSDavid Howells 	    TP_ARGS(cache_debug_id, usage, where),
1509549332dSDavid Howells 
1519549332dSDavid Howells 	    TP_STRUCT__entry(
1529549332dSDavid Howells 		    __field(unsigned int,		cache		)
1539549332dSDavid Howells 		    __field(int,			usage		)
1549549332dSDavid Howells 		    __field(enum fscache_cache_trace,	where		)
1559549332dSDavid Howells 			     ),
1569549332dSDavid Howells 
1579549332dSDavid Howells 	    TP_fast_assign(
1589549332dSDavid Howells 		    __entry->cache	= cache_debug_id;
1599549332dSDavid Howells 		    __entry->usage	= usage;
1609549332dSDavid Howells 		    __entry->where	= where;
1619549332dSDavid Howells 			   ),
1629549332dSDavid Howells 
1639549332dSDavid Howells 	    TP_printk("C=%08x %s r=%d",
1649549332dSDavid Howells 		      __entry->cache,
1659549332dSDavid Howells 		      __print_symbolic(__entry->where, fscache_cache_traces),
1669549332dSDavid Howells 		      __entry->usage)
1679549332dSDavid Howells 	    );
1689549332dSDavid Howells 
16962ab6335SDavid Howells TRACE_EVENT(fscache_volume,
17062ab6335SDavid Howells 	    TP_PROTO(unsigned int volume_debug_id,
17162ab6335SDavid Howells 		     int usage,
17262ab6335SDavid Howells 		     enum fscache_volume_trace where),
17362ab6335SDavid Howells 
17462ab6335SDavid Howells 	    TP_ARGS(volume_debug_id, usage, where),
17562ab6335SDavid Howells 
17662ab6335SDavid Howells 	    TP_STRUCT__entry(
17762ab6335SDavid Howells 		    __field(unsigned int,		volume		)
17862ab6335SDavid Howells 		    __field(int,			usage		)
17962ab6335SDavid Howells 		    __field(enum fscache_volume_trace,	where		)
18062ab6335SDavid Howells 			     ),
18162ab6335SDavid Howells 
18262ab6335SDavid Howells 	    TP_fast_assign(
18362ab6335SDavid Howells 		    __entry->volume	= volume_debug_id;
18462ab6335SDavid Howells 		    __entry->usage	= usage;
18562ab6335SDavid Howells 		    __entry->where	= where;
18662ab6335SDavid Howells 			   ),
18762ab6335SDavid Howells 
18862ab6335SDavid Howells 	    TP_printk("V=%08x %s u=%d",
18962ab6335SDavid Howells 		      __entry->volume,
19062ab6335SDavid Howells 		      __print_symbolic(__entry->where, fscache_volume_traces),
19162ab6335SDavid Howells 		      __entry->usage)
19262ab6335SDavid Howells 	    );
19362ab6335SDavid Howells 
1947f3283abSDavid Howells TRACE_EVENT(fscache_cookie,
1957f3283abSDavid Howells 	    TP_PROTO(unsigned int cookie_debug_id,
1967f3283abSDavid Howells 		     int ref,
1977f3283abSDavid Howells 		     enum fscache_cookie_trace where),
1987f3283abSDavid Howells 
1997f3283abSDavid Howells 	    TP_ARGS(cookie_debug_id, ref, where),
2007f3283abSDavid Howells 
2017f3283abSDavid Howells 	    TP_STRUCT__entry(
2027f3283abSDavid Howells 		    __field(unsigned int,		cookie		)
2037f3283abSDavid Howells 		    __field(int,			ref		)
2047f3283abSDavid Howells 		    __field(enum fscache_cookie_trace,	where		)
2057f3283abSDavid Howells 			     ),
2067f3283abSDavid Howells 
2077f3283abSDavid Howells 	    TP_fast_assign(
2087f3283abSDavid Howells 		    __entry->cookie	= cookie_debug_id;
2097f3283abSDavid Howells 		    __entry->ref	= ref;
2107f3283abSDavid Howells 		    __entry->where	= where;
2117f3283abSDavid Howells 			   ),
2127f3283abSDavid Howells 
2137f3283abSDavid Howells 	    TP_printk("c=%08x %s r=%d",
2147f3283abSDavid Howells 		      __entry->cookie,
2157f3283abSDavid Howells 		      __print_symbolic(__entry->where, fscache_cookie_traces),
2167f3283abSDavid Howells 		      __entry->ref)
2177f3283abSDavid Howells 	    );
2187f3283abSDavid Howells 
219*23e12e28SDavid Howells TRACE_EVENT(fscache_access_cache,
220*23e12e28SDavid Howells 	    TP_PROTO(unsigned int cache_debug_id,
221*23e12e28SDavid Howells 		     int ref,
222*23e12e28SDavid Howells 		     int n_accesses,
223*23e12e28SDavid Howells 		     enum fscache_access_trace why),
224*23e12e28SDavid Howells 
225*23e12e28SDavid Howells 	    TP_ARGS(cache_debug_id, ref, n_accesses, why),
226*23e12e28SDavid Howells 
227*23e12e28SDavid Howells 	    TP_STRUCT__entry(
228*23e12e28SDavid Howells 		    __field(unsigned int,		cache		)
229*23e12e28SDavid Howells 		    __field(int,			ref		)
230*23e12e28SDavid Howells 		    __field(int,			n_accesses	)
231*23e12e28SDavid Howells 		    __field(enum fscache_access_trace,	why		)
232*23e12e28SDavid Howells 			     ),
233*23e12e28SDavid Howells 
234*23e12e28SDavid Howells 	    TP_fast_assign(
235*23e12e28SDavid Howells 		    __entry->cache	= cache_debug_id;
236*23e12e28SDavid Howells 		    __entry->ref	= ref;
237*23e12e28SDavid Howells 		    __entry->n_accesses	= n_accesses;
238*23e12e28SDavid Howells 		    __entry->why	= why;
239*23e12e28SDavid Howells 			   ),
240*23e12e28SDavid Howells 
241*23e12e28SDavid Howells 	    TP_printk("C=%08x %s r=%d a=%d",
242*23e12e28SDavid Howells 		      __entry->cache,
243*23e12e28SDavid Howells 		      __print_symbolic(__entry->why, fscache_access_traces),
244*23e12e28SDavid Howells 		      __entry->ref,
245*23e12e28SDavid Howells 		      __entry->n_accesses)
246*23e12e28SDavid Howells 	    );
247*23e12e28SDavid Howells 
2487f3283abSDavid Howells TRACE_EVENT(fscache_acquire,
2497f3283abSDavid Howells 	    TP_PROTO(struct fscache_cookie *cookie),
2507f3283abSDavid Howells 
2517f3283abSDavid Howells 	    TP_ARGS(cookie),
2527f3283abSDavid Howells 
2537f3283abSDavid Howells 	    TP_STRUCT__entry(
2547f3283abSDavid Howells 		    __field(unsigned int,		cookie		)
2557f3283abSDavid Howells 		    __field(unsigned int,		volume		)
2567f3283abSDavid Howells 		    __field(int,			v_ref		)
2577f3283abSDavid Howells 		    __field(int,			v_n_cookies	)
2587f3283abSDavid Howells 			     ),
2597f3283abSDavid Howells 
2607f3283abSDavid Howells 	    TP_fast_assign(
2617f3283abSDavid Howells 		    __entry->cookie		= cookie->debug_id;
2627f3283abSDavid Howells 		    __entry->volume		= cookie->volume->debug_id;
2637f3283abSDavid Howells 		    __entry->v_ref		= refcount_read(&cookie->volume->ref);
2647f3283abSDavid Howells 		    __entry->v_n_cookies	= atomic_read(&cookie->volume->n_cookies);
2657f3283abSDavid Howells 			   ),
2667f3283abSDavid Howells 
2677f3283abSDavid Howells 	    TP_printk("c=%08x V=%08x vr=%d vc=%d",
2687f3283abSDavid Howells 		      __entry->cookie,
2697f3283abSDavid Howells 		      __entry->volume, __entry->v_ref, __entry->v_n_cookies)
2707f3283abSDavid Howells 	    );
2717f3283abSDavid Howells 
2727f3283abSDavid Howells TRACE_EVENT(fscache_relinquish,
2737f3283abSDavid Howells 	    TP_PROTO(struct fscache_cookie *cookie, bool retire),
2747f3283abSDavid Howells 
2757f3283abSDavid Howells 	    TP_ARGS(cookie, retire),
2767f3283abSDavid Howells 
2777f3283abSDavid Howells 	    TP_STRUCT__entry(
2787f3283abSDavid Howells 		    __field(unsigned int,		cookie		)
2797f3283abSDavid Howells 		    __field(unsigned int,		volume		)
2807f3283abSDavid Howells 		    __field(int,			ref		)
2817f3283abSDavid Howells 		    __field(int,			n_active	)
2827f3283abSDavid Howells 		    __field(u8,				flags		)
2837f3283abSDavid Howells 		    __field(bool,			retire		)
2847f3283abSDavid Howells 			     ),
2857f3283abSDavid Howells 
2867f3283abSDavid Howells 	    TP_fast_assign(
2877f3283abSDavid Howells 		    __entry->cookie	= cookie->debug_id;
2887f3283abSDavid Howells 		    __entry->volume	= cookie->volume->debug_id;
2897f3283abSDavid Howells 		    __entry->ref	= refcount_read(&cookie->ref);
2907f3283abSDavid Howells 		    __entry->n_active	= atomic_read(&cookie->n_active);
2917f3283abSDavid Howells 		    __entry->flags	= cookie->flags;
2927f3283abSDavid Howells 		    __entry->retire	= retire;
2937f3283abSDavid Howells 			   ),
2947f3283abSDavid Howells 
2957f3283abSDavid Howells 	    TP_printk("c=%08x V=%08x r=%d U=%d f=%02x rt=%u",
2967f3283abSDavid Howells 		      __entry->cookie, __entry->volume, __entry->ref,
2977f3283abSDavid Howells 		      __entry->n_active, __entry->flags, __entry->retire)
2987f3283abSDavid Howells 	    );
2997f3283abSDavid Howells 
3001e1236b8SDavid Howells #endif /* _TRACE_FSCACHE_H */
3011e1236b8SDavid Howells 
3021e1236b8SDavid Howells /* This part must be outside protection */
3031e1236b8SDavid Howells #include <trace/define_trace.h>
304