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, 46*e6acd329SDavid Howells fscache_volume_wait_create_work, 479549332dSDavid Howells }; 489549332dSDavid Howells 497f3283abSDavid Howells enum fscache_cookie_trace { 507f3283abSDavid Howells fscache_cookie_collision, 517f3283abSDavid Howells fscache_cookie_discard, 527f3283abSDavid Howells fscache_cookie_get_end_access, 537f3283abSDavid Howells fscache_cookie_get_hash_collision, 547f3283abSDavid Howells fscache_cookie_new_acquire, 557f3283abSDavid Howells fscache_cookie_put_hash_collision, 567f3283abSDavid Howells fscache_cookie_put_over_queued, 577f3283abSDavid Howells fscache_cookie_put_relinquish, 587f3283abSDavid Howells fscache_cookie_put_withdrawn, 597f3283abSDavid Howells fscache_cookie_put_work, 607f3283abSDavid Howells fscache_cookie_see_active, 617f3283abSDavid Howells fscache_cookie_see_relinquish, 627f3283abSDavid Howells fscache_cookie_see_withdraw, 637f3283abSDavid Howells fscache_cookie_see_work, 647f3283abSDavid Howells }; 657f3283abSDavid Howells 6623e12e28SDavid Howells enum fscache_access_trace { 6723e12e28SDavid Howells fscache_access_cache_pin, 6823e12e28SDavid Howells fscache_access_cache_unpin, 6923e12e28SDavid Howells fscache_access_unlive, 7023e12e28SDavid Howells }; 7123e12e28SDavid Howells 721e1236b8SDavid Howells #endif 731e1236b8SDavid Howells 741e1236b8SDavid Howells /* 751e1236b8SDavid Howells * Declare tracing information enums and their string mappings for display. 761e1236b8SDavid Howells */ 779549332dSDavid Howells #define fscache_cache_traces \ 789549332dSDavid Howells EM(fscache_cache_collision, "*COLLIDE*") \ 799549332dSDavid Howells EM(fscache_cache_get_acquire, "GET acq ") \ 809549332dSDavid Howells EM(fscache_cache_new_acquire, "NEW acq ") \ 8162ab6335SDavid Howells EM(fscache_cache_put_alloc_volume, "PUT alvol") \ 829549332dSDavid Howells EM(fscache_cache_put_cache, "PUT cache") \ 839549332dSDavid Howells EM(fscache_cache_put_prep_failed, "PUT pfail") \ 8462ab6335SDavid Howells EM(fscache_cache_put_relinquish, "PUT relnq") \ 8562ab6335SDavid Howells E_(fscache_cache_put_volume, "PUT vol ") 8662ab6335SDavid Howells 8762ab6335SDavid Howells #define fscache_volume_traces \ 8862ab6335SDavid Howells EM(fscache_volume_collision, "*COLLIDE*") \ 8962ab6335SDavid Howells EM(fscache_volume_get_cookie, "GET cook ") \ 9062ab6335SDavid Howells EM(fscache_volume_get_create_work, "GET creat") \ 9162ab6335SDavid Howells EM(fscache_volume_get_hash_collision, "GET hcoll") \ 9262ab6335SDavid Howells EM(fscache_volume_free, "FREE ") \ 9362ab6335SDavid Howells EM(fscache_volume_new_acquire, "NEW acq ") \ 9462ab6335SDavid Howells EM(fscache_volume_put_cookie, "PUT cook ") \ 9562ab6335SDavid Howells EM(fscache_volume_put_create_work, "PUT creat") \ 9662ab6335SDavid Howells EM(fscache_volume_put_hash_collision, "PUT hcoll") \ 9762ab6335SDavid Howells EM(fscache_volume_put_relinquish, "PUT relnq") \ 9862ab6335SDavid Howells EM(fscache_volume_see_create_work, "SEE creat") \ 9962ab6335SDavid Howells E_(fscache_volume_see_hash_wake, "SEE hwake") 1001e1236b8SDavid Howells 1017f3283abSDavid Howells #define fscache_cookie_traces \ 1027f3283abSDavid Howells EM(fscache_cookie_collision, "*COLLIDE*") \ 1037f3283abSDavid Howells EM(fscache_cookie_discard, "DISCARD ") \ 1047f3283abSDavid Howells EM(fscache_cookie_get_hash_collision, "GET hcoll") \ 1057f3283abSDavid Howells EM(fscache_cookie_get_end_access, "GQ endac") \ 1067f3283abSDavid Howells EM(fscache_cookie_new_acquire, "NEW acq ") \ 1077f3283abSDavid Howells EM(fscache_cookie_put_hash_collision, "PUT hcoll") \ 1087f3283abSDavid Howells EM(fscache_cookie_put_over_queued, "PQ overq") \ 1097f3283abSDavid Howells EM(fscache_cookie_put_relinquish, "PUT relnq") \ 1107f3283abSDavid Howells EM(fscache_cookie_put_withdrawn, "PUT wthdn") \ 1117f3283abSDavid Howells EM(fscache_cookie_put_work, "PQ work ") \ 1127f3283abSDavid Howells EM(fscache_cookie_see_active, "- activ") \ 1137f3283abSDavid Howells EM(fscache_cookie_see_relinquish, "- x-rlq") \ 1147f3283abSDavid Howells EM(fscache_cookie_see_withdraw, "- x-wth") \ 1157f3283abSDavid Howells E_(fscache_cookie_see_work, "- work ") 1167f3283abSDavid Howells 11723e12e28SDavid Howells #define fscache_access_traces \ 11823e12e28SDavid Howells EM(fscache_access_cache_pin, "PIN cache ") \ 11923e12e28SDavid Howells EM(fscache_access_cache_unpin, "UNPIN cache ") \ 12023e12e28SDavid Howells E_(fscache_access_unlive, "END unlive ") 12123e12e28SDavid Howells 1221e1236b8SDavid Howells /* 1231e1236b8SDavid Howells * Export enum symbols via userspace. 1241e1236b8SDavid Howells */ 1251e1236b8SDavid Howells #undef EM 1261e1236b8SDavid Howells #undef E_ 1271e1236b8SDavid Howells #define EM(a, b) TRACE_DEFINE_ENUM(a); 1281e1236b8SDavid Howells #define E_(a, b) TRACE_DEFINE_ENUM(a); 1291e1236b8SDavid Howells 1309549332dSDavid Howells fscache_cache_traces; 13162ab6335SDavid Howells fscache_volume_traces; 1327f3283abSDavid Howells fscache_cookie_traces; 13323e12e28SDavid Howells fscache_access_traces; 1349549332dSDavid Howells 1351e1236b8SDavid Howells /* 1361e1236b8SDavid Howells * Now redefine the EM() and E_() macros to map the enums to the strings that 1371e1236b8SDavid Howells * will be printed in the output. 1381e1236b8SDavid Howells */ 1391e1236b8SDavid Howells #undef EM 1401e1236b8SDavid Howells #undef E_ 1411e1236b8SDavid Howells #define EM(a, b) { a, b }, 1421e1236b8SDavid Howells #define E_(a, b) { a, b } 1431e1236b8SDavid Howells 1441e1236b8SDavid Howells 1459549332dSDavid Howells TRACE_EVENT(fscache_cache, 1469549332dSDavid Howells TP_PROTO(unsigned int cache_debug_id, 1479549332dSDavid Howells int usage, 1489549332dSDavid Howells enum fscache_cache_trace where), 1499549332dSDavid Howells 1509549332dSDavid Howells TP_ARGS(cache_debug_id, usage, where), 1519549332dSDavid Howells 1529549332dSDavid Howells TP_STRUCT__entry( 1539549332dSDavid Howells __field(unsigned int, cache ) 1549549332dSDavid Howells __field(int, usage ) 1559549332dSDavid Howells __field(enum fscache_cache_trace, where ) 1569549332dSDavid Howells ), 1579549332dSDavid Howells 1589549332dSDavid Howells TP_fast_assign( 1599549332dSDavid Howells __entry->cache = cache_debug_id; 1609549332dSDavid Howells __entry->usage = usage; 1619549332dSDavid Howells __entry->where = where; 1629549332dSDavid Howells ), 1639549332dSDavid Howells 1649549332dSDavid Howells TP_printk("C=%08x %s r=%d", 1659549332dSDavid Howells __entry->cache, 1669549332dSDavid Howells __print_symbolic(__entry->where, fscache_cache_traces), 1679549332dSDavid Howells __entry->usage) 1689549332dSDavid Howells ); 1699549332dSDavid Howells 17062ab6335SDavid Howells TRACE_EVENT(fscache_volume, 17162ab6335SDavid Howells TP_PROTO(unsigned int volume_debug_id, 17262ab6335SDavid Howells int usage, 17362ab6335SDavid Howells enum fscache_volume_trace where), 17462ab6335SDavid Howells 17562ab6335SDavid Howells TP_ARGS(volume_debug_id, usage, where), 17662ab6335SDavid Howells 17762ab6335SDavid Howells TP_STRUCT__entry( 17862ab6335SDavid Howells __field(unsigned int, volume ) 17962ab6335SDavid Howells __field(int, usage ) 18062ab6335SDavid Howells __field(enum fscache_volume_trace, where ) 18162ab6335SDavid Howells ), 18262ab6335SDavid Howells 18362ab6335SDavid Howells TP_fast_assign( 18462ab6335SDavid Howells __entry->volume = volume_debug_id; 18562ab6335SDavid Howells __entry->usage = usage; 18662ab6335SDavid Howells __entry->where = where; 18762ab6335SDavid Howells ), 18862ab6335SDavid Howells 18962ab6335SDavid Howells TP_printk("V=%08x %s u=%d", 19062ab6335SDavid Howells __entry->volume, 19162ab6335SDavid Howells __print_symbolic(__entry->where, fscache_volume_traces), 19262ab6335SDavid Howells __entry->usage) 19362ab6335SDavid Howells ); 19462ab6335SDavid Howells 1957f3283abSDavid Howells TRACE_EVENT(fscache_cookie, 1967f3283abSDavid Howells TP_PROTO(unsigned int cookie_debug_id, 1977f3283abSDavid Howells int ref, 1987f3283abSDavid Howells enum fscache_cookie_trace where), 1997f3283abSDavid Howells 2007f3283abSDavid Howells TP_ARGS(cookie_debug_id, ref, where), 2017f3283abSDavid Howells 2027f3283abSDavid Howells TP_STRUCT__entry( 2037f3283abSDavid Howells __field(unsigned int, cookie ) 2047f3283abSDavid Howells __field(int, ref ) 2057f3283abSDavid Howells __field(enum fscache_cookie_trace, where ) 2067f3283abSDavid Howells ), 2077f3283abSDavid Howells 2087f3283abSDavid Howells TP_fast_assign( 2097f3283abSDavid Howells __entry->cookie = cookie_debug_id; 2107f3283abSDavid Howells __entry->ref = ref; 2117f3283abSDavid Howells __entry->where = where; 2127f3283abSDavid Howells ), 2137f3283abSDavid Howells 2147f3283abSDavid Howells TP_printk("c=%08x %s r=%d", 2157f3283abSDavid Howells __entry->cookie, 2167f3283abSDavid Howells __print_symbolic(__entry->where, fscache_cookie_traces), 2177f3283abSDavid Howells __entry->ref) 2187f3283abSDavid Howells ); 2197f3283abSDavid Howells 22023e12e28SDavid Howells TRACE_EVENT(fscache_access_cache, 22123e12e28SDavid Howells TP_PROTO(unsigned int cache_debug_id, 22223e12e28SDavid Howells int ref, 22323e12e28SDavid Howells int n_accesses, 22423e12e28SDavid Howells enum fscache_access_trace why), 22523e12e28SDavid Howells 22623e12e28SDavid Howells TP_ARGS(cache_debug_id, ref, n_accesses, why), 22723e12e28SDavid Howells 22823e12e28SDavid Howells TP_STRUCT__entry( 22923e12e28SDavid Howells __field(unsigned int, cache ) 23023e12e28SDavid Howells __field(int, ref ) 23123e12e28SDavid Howells __field(int, n_accesses ) 23223e12e28SDavid Howells __field(enum fscache_access_trace, why ) 23323e12e28SDavid Howells ), 23423e12e28SDavid Howells 23523e12e28SDavid Howells TP_fast_assign( 23623e12e28SDavid Howells __entry->cache = cache_debug_id; 23723e12e28SDavid Howells __entry->ref = ref; 23823e12e28SDavid Howells __entry->n_accesses = n_accesses; 23923e12e28SDavid Howells __entry->why = why; 24023e12e28SDavid Howells ), 24123e12e28SDavid Howells 24223e12e28SDavid Howells TP_printk("C=%08x %s r=%d a=%d", 24323e12e28SDavid Howells __entry->cache, 24423e12e28SDavid Howells __print_symbolic(__entry->why, fscache_access_traces), 24523e12e28SDavid Howells __entry->ref, 24623e12e28SDavid Howells __entry->n_accesses) 24723e12e28SDavid Howells ); 24823e12e28SDavid Howells 249*e6acd329SDavid Howells TRACE_EVENT(fscache_access_volume, 250*e6acd329SDavid Howells TP_PROTO(unsigned int volume_debug_id, 251*e6acd329SDavid Howells unsigned int cookie_debug_id, 252*e6acd329SDavid Howells int ref, 253*e6acd329SDavid Howells int n_accesses, 254*e6acd329SDavid Howells enum fscache_access_trace why), 255*e6acd329SDavid Howells 256*e6acd329SDavid Howells TP_ARGS(volume_debug_id, cookie_debug_id, ref, n_accesses, why), 257*e6acd329SDavid Howells 258*e6acd329SDavid Howells TP_STRUCT__entry( 259*e6acd329SDavid Howells __field(unsigned int, volume ) 260*e6acd329SDavid Howells __field(unsigned int, cookie ) 261*e6acd329SDavid Howells __field(int, ref ) 262*e6acd329SDavid Howells __field(int, n_accesses ) 263*e6acd329SDavid Howells __field(enum fscache_access_trace, why ) 264*e6acd329SDavid Howells ), 265*e6acd329SDavid Howells 266*e6acd329SDavid Howells TP_fast_assign( 267*e6acd329SDavid Howells __entry->volume = volume_debug_id; 268*e6acd329SDavid Howells __entry->cookie = cookie_debug_id; 269*e6acd329SDavid Howells __entry->ref = ref; 270*e6acd329SDavid Howells __entry->n_accesses = n_accesses; 271*e6acd329SDavid Howells __entry->why = why; 272*e6acd329SDavid Howells ), 273*e6acd329SDavid Howells 274*e6acd329SDavid Howells TP_printk("V=%08x c=%08x %s r=%d a=%d", 275*e6acd329SDavid Howells __entry->volume, 276*e6acd329SDavid Howells __entry->cookie, 277*e6acd329SDavid Howells __print_symbolic(__entry->why, fscache_access_traces), 278*e6acd329SDavid Howells __entry->ref, 279*e6acd329SDavid Howells __entry->n_accesses) 280*e6acd329SDavid Howells ); 281*e6acd329SDavid Howells 2827f3283abSDavid Howells TRACE_EVENT(fscache_acquire, 2837f3283abSDavid Howells TP_PROTO(struct fscache_cookie *cookie), 2847f3283abSDavid Howells 2857f3283abSDavid Howells TP_ARGS(cookie), 2867f3283abSDavid Howells 2877f3283abSDavid Howells TP_STRUCT__entry( 2887f3283abSDavid Howells __field(unsigned int, cookie ) 2897f3283abSDavid Howells __field(unsigned int, volume ) 2907f3283abSDavid Howells __field(int, v_ref ) 2917f3283abSDavid Howells __field(int, v_n_cookies ) 2927f3283abSDavid Howells ), 2937f3283abSDavid Howells 2947f3283abSDavid Howells TP_fast_assign( 2957f3283abSDavid Howells __entry->cookie = cookie->debug_id; 2967f3283abSDavid Howells __entry->volume = cookie->volume->debug_id; 2977f3283abSDavid Howells __entry->v_ref = refcount_read(&cookie->volume->ref); 2987f3283abSDavid Howells __entry->v_n_cookies = atomic_read(&cookie->volume->n_cookies); 2997f3283abSDavid Howells ), 3007f3283abSDavid Howells 3017f3283abSDavid Howells TP_printk("c=%08x V=%08x vr=%d vc=%d", 3027f3283abSDavid Howells __entry->cookie, 3037f3283abSDavid Howells __entry->volume, __entry->v_ref, __entry->v_n_cookies) 3047f3283abSDavid Howells ); 3057f3283abSDavid Howells 3067f3283abSDavid Howells TRACE_EVENT(fscache_relinquish, 3077f3283abSDavid Howells TP_PROTO(struct fscache_cookie *cookie, bool retire), 3087f3283abSDavid Howells 3097f3283abSDavid Howells TP_ARGS(cookie, retire), 3107f3283abSDavid Howells 3117f3283abSDavid Howells TP_STRUCT__entry( 3127f3283abSDavid Howells __field(unsigned int, cookie ) 3137f3283abSDavid Howells __field(unsigned int, volume ) 3147f3283abSDavid Howells __field(int, ref ) 3157f3283abSDavid Howells __field(int, n_active ) 3167f3283abSDavid Howells __field(u8, flags ) 3177f3283abSDavid Howells __field(bool, retire ) 3187f3283abSDavid Howells ), 3197f3283abSDavid Howells 3207f3283abSDavid Howells TP_fast_assign( 3217f3283abSDavid Howells __entry->cookie = cookie->debug_id; 3227f3283abSDavid Howells __entry->volume = cookie->volume->debug_id; 3237f3283abSDavid Howells __entry->ref = refcount_read(&cookie->ref); 3247f3283abSDavid Howells __entry->n_active = atomic_read(&cookie->n_active); 3257f3283abSDavid Howells __entry->flags = cookie->flags; 3267f3283abSDavid Howells __entry->retire = retire; 3277f3283abSDavid Howells ), 3287f3283abSDavid Howells 3297f3283abSDavid Howells TP_printk("c=%08x V=%08x r=%d U=%d f=%02x rt=%u", 3307f3283abSDavid Howells __entry->cookie, __entry->volume, __entry->ref, 3317f3283abSDavid Howells __entry->n_active, __entry->flags, __entry->retire) 3327f3283abSDavid Howells ); 3337f3283abSDavid Howells 3341e1236b8SDavid Howells #endif /* _TRACE_FSCACHE_H */ 3351e1236b8SDavid Howells 3361e1236b8SDavid Howells /* This part must be outside protection */ 3371e1236b8SDavid Howells #include <trace/define_trace.h> 338