xref: /openbmc/linux/include/trace/events/fscache.h (revision 62ab6335)
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,
26*62ab6335SDavid 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,
30*62ab6335SDavid Howells 	fscache_cache_put_volume,
31*62ab6335SDavid Howells };
32*62ab6335SDavid Howells 
33*62ab6335SDavid Howells enum fscache_volume_trace {
34*62ab6335SDavid Howells 	fscache_volume_collision,
35*62ab6335SDavid Howells 	fscache_volume_get_cookie,
36*62ab6335SDavid Howells 	fscache_volume_get_create_work,
37*62ab6335SDavid Howells 	fscache_volume_get_hash_collision,
38*62ab6335SDavid Howells 	fscache_volume_free,
39*62ab6335SDavid Howells 	fscache_volume_new_acquire,
40*62ab6335SDavid Howells 	fscache_volume_put_cookie,
41*62ab6335SDavid Howells 	fscache_volume_put_create_work,
42*62ab6335SDavid Howells 	fscache_volume_put_hash_collision,
43*62ab6335SDavid Howells 	fscache_volume_put_relinquish,
44*62ab6335SDavid Howells 	fscache_volume_see_create_work,
45*62ab6335SDavid Howells 	fscache_volume_see_hash_wake,
469549332dSDavid Howells };
479549332dSDavid Howells 
481e1236b8SDavid Howells #endif
491e1236b8SDavid Howells 
501e1236b8SDavid Howells /*
511e1236b8SDavid Howells  * Declare tracing information enums and their string mappings for display.
521e1236b8SDavid Howells  */
539549332dSDavid Howells #define fscache_cache_traces						\
549549332dSDavid Howells 	EM(fscache_cache_collision,		"*COLLIDE*")		\
559549332dSDavid Howells 	EM(fscache_cache_get_acquire,		"GET acq  ")		\
569549332dSDavid Howells 	EM(fscache_cache_new_acquire,		"NEW acq  ")		\
57*62ab6335SDavid Howells 	EM(fscache_cache_put_alloc_volume,	"PUT alvol")		\
589549332dSDavid Howells 	EM(fscache_cache_put_cache,		"PUT cache")		\
599549332dSDavid Howells 	EM(fscache_cache_put_prep_failed,	"PUT pfail")		\
60*62ab6335SDavid Howells 	EM(fscache_cache_put_relinquish,	"PUT relnq")		\
61*62ab6335SDavid Howells 	E_(fscache_cache_put_volume,		"PUT vol  ")
62*62ab6335SDavid Howells 
63*62ab6335SDavid Howells #define fscache_volume_traces						\
64*62ab6335SDavid Howells 	EM(fscache_volume_collision,		"*COLLIDE*")		\
65*62ab6335SDavid Howells 	EM(fscache_volume_get_cookie,		"GET cook ")		\
66*62ab6335SDavid Howells 	EM(fscache_volume_get_create_work,	"GET creat")		\
67*62ab6335SDavid Howells 	EM(fscache_volume_get_hash_collision,	"GET hcoll")		\
68*62ab6335SDavid Howells 	EM(fscache_volume_free,			"FREE     ")		\
69*62ab6335SDavid Howells 	EM(fscache_volume_new_acquire,		"NEW acq  ")		\
70*62ab6335SDavid Howells 	EM(fscache_volume_put_cookie,		"PUT cook ")		\
71*62ab6335SDavid Howells 	EM(fscache_volume_put_create_work,	"PUT creat")		\
72*62ab6335SDavid Howells 	EM(fscache_volume_put_hash_collision,	"PUT hcoll")		\
73*62ab6335SDavid Howells 	EM(fscache_volume_put_relinquish,	"PUT relnq")		\
74*62ab6335SDavid Howells 	EM(fscache_volume_see_create_work,	"SEE creat")		\
75*62ab6335SDavid Howells 	E_(fscache_volume_see_hash_wake,	"SEE hwake")
761e1236b8SDavid Howells 
771e1236b8SDavid Howells /*
781e1236b8SDavid Howells  * Export enum symbols via userspace.
791e1236b8SDavid Howells  */
801e1236b8SDavid Howells #undef EM
811e1236b8SDavid Howells #undef E_
821e1236b8SDavid Howells #define EM(a, b) TRACE_DEFINE_ENUM(a);
831e1236b8SDavid Howells #define E_(a, b) TRACE_DEFINE_ENUM(a);
841e1236b8SDavid Howells 
859549332dSDavid Howells fscache_cache_traces;
86*62ab6335SDavid Howells fscache_volume_traces;
879549332dSDavid Howells 
881e1236b8SDavid Howells /*
891e1236b8SDavid Howells  * Now redefine the EM() and E_() macros to map the enums to the strings that
901e1236b8SDavid Howells  * will be printed in the output.
911e1236b8SDavid Howells  */
921e1236b8SDavid Howells #undef EM
931e1236b8SDavid Howells #undef E_
941e1236b8SDavid Howells #define EM(a, b)	{ a, b },
951e1236b8SDavid Howells #define E_(a, b)	{ a, b }
961e1236b8SDavid Howells 
971e1236b8SDavid Howells 
989549332dSDavid Howells TRACE_EVENT(fscache_cache,
999549332dSDavid Howells 	    TP_PROTO(unsigned int cache_debug_id,
1009549332dSDavid Howells 		     int usage,
1019549332dSDavid Howells 		     enum fscache_cache_trace where),
1029549332dSDavid Howells 
1039549332dSDavid Howells 	    TP_ARGS(cache_debug_id, usage, where),
1049549332dSDavid Howells 
1059549332dSDavid Howells 	    TP_STRUCT__entry(
1069549332dSDavid Howells 		    __field(unsigned int,		cache		)
1079549332dSDavid Howells 		    __field(int,			usage		)
1089549332dSDavid Howells 		    __field(enum fscache_cache_trace,	where		)
1099549332dSDavid Howells 			     ),
1109549332dSDavid Howells 
1119549332dSDavid Howells 	    TP_fast_assign(
1129549332dSDavid Howells 		    __entry->cache	= cache_debug_id;
1139549332dSDavid Howells 		    __entry->usage	= usage;
1149549332dSDavid Howells 		    __entry->where	= where;
1159549332dSDavid Howells 			   ),
1169549332dSDavid Howells 
1179549332dSDavid Howells 	    TP_printk("C=%08x %s r=%d",
1189549332dSDavid Howells 		      __entry->cache,
1199549332dSDavid Howells 		      __print_symbolic(__entry->where, fscache_cache_traces),
1209549332dSDavid Howells 		      __entry->usage)
1219549332dSDavid Howells 	    );
1229549332dSDavid Howells 
123*62ab6335SDavid Howells TRACE_EVENT(fscache_volume,
124*62ab6335SDavid Howells 	    TP_PROTO(unsigned int volume_debug_id,
125*62ab6335SDavid Howells 		     int usage,
126*62ab6335SDavid Howells 		     enum fscache_volume_trace where),
127*62ab6335SDavid Howells 
128*62ab6335SDavid Howells 	    TP_ARGS(volume_debug_id, usage, where),
129*62ab6335SDavid Howells 
130*62ab6335SDavid Howells 	    TP_STRUCT__entry(
131*62ab6335SDavid Howells 		    __field(unsigned int,		volume		)
132*62ab6335SDavid Howells 		    __field(int,			usage		)
133*62ab6335SDavid Howells 		    __field(enum fscache_volume_trace,	where		)
134*62ab6335SDavid Howells 			     ),
135*62ab6335SDavid Howells 
136*62ab6335SDavid Howells 	    TP_fast_assign(
137*62ab6335SDavid Howells 		    __entry->volume	= volume_debug_id;
138*62ab6335SDavid Howells 		    __entry->usage	= usage;
139*62ab6335SDavid Howells 		    __entry->where	= where;
140*62ab6335SDavid Howells 			   ),
141*62ab6335SDavid Howells 
142*62ab6335SDavid Howells 	    TP_printk("V=%08x %s u=%d",
143*62ab6335SDavid Howells 		      __entry->volume,
144*62ab6335SDavid Howells 		      __print_symbolic(__entry->where, fscache_volume_traces),
145*62ab6335SDavid Howells 		      __entry->usage)
146*62ab6335SDavid Howells 	    );
147*62ab6335SDavid Howells 
1481e1236b8SDavid Howells #endif /* _TRACE_FSCACHE_H */
1491e1236b8SDavid Howells 
1501e1236b8SDavid Howells /* This part must be outside protection */
1511e1236b8SDavid Howells #include <trace/define_trace.h>
152