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 48*7f3283abSDavid Howells enum fscache_cookie_trace { 49*7f3283abSDavid Howells fscache_cookie_collision, 50*7f3283abSDavid Howells fscache_cookie_discard, 51*7f3283abSDavid Howells fscache_cookie_get_end_access, 52*7f3283abSDavid Howells fscache_cookie_get_hash_collision, 53*7f3283abSDavid Howells fscache_cookie_new_acquire, 54*7f3283abSDavid Howells fscache_cookie_put_hash_collision, 55*7f3283abSDavid Howells fscache_cookie_put_over_queued, 56*7f3283abSDavid Howells fscache_cookie_put_relinquish, 57*7f3283abSDavid Howells fscache_cookie_put_withdrawn, 58*7f3283abSDavid Howells fscache_cookie_put_work, 59*7f3283abSDavid Howells fscache_cookie_see_active, 60*7f3283abSDavid Howells fscache_cookie_see_relinquish, 61*7f3283abSDavid Howells fscache_cookie_see_withdraw, 62*7f3283abSDavid Howells fscache_cookie_see_work, 63*7f3283abSDavid Howells }; 64*7f3283abSDavid Howells 651e1236b8SDavid Howells #endif 661e1236b8SDavid Howells 671e1236b8SDavid Howells /* 681e1236b8SDavid Howells * Declare tracing information enums and their string mappings for display. 691e1236b8SDavid Howells */ 709549332dSDavid Howells #define fscache_cache_traces \ 719549332dSDavid Howells EM(fscache_cache_collision, "*COLLIDE*") \ 729549332dSDavid Howells EM(fscache_cache_get_acquire, "GET acq ") \ 739549332dSDavid Howells EM(fscache_cache_new_acquire, "NEW acq ") \ 7462ab6335SDavid Howells EM(fscache_cache_put_alloc_volume, "PUT alvol") \ 759549332dSDavid Howells EM(fscache_cache_put_cache, "PUT cache") \ 769549332dSDavid Howells EM(fscache_cache_put_prep_failed, "PUT pfail") \ 7762ab6335SDavid Howells EM(fscache_cache_put_relinquish, "PUT relnq") \ 7862ab6335SDavid Howells E_(fscache_cache_put_volume, "PUT vol ") 7962ab6335SDavid Howells 8062ab6335SDavid Howells #define fscache_volume_traces \ 8162ab6335SDavid Howells EM(fscache_volume_collision, "*COLLIDE*") \ 8262ab6335SDavid Howells EM(fscache_volume_get_cookie, "GET cook ") \ 8362ab6335SDavid Howells EM(fscache_volume_get_create_work, "GET creat") \ 8462ab6335SDavid Howells EM(fscache_volume_get_hash_collision, "GET hcoll") \ 8562ab6335SDavid Howells EM(fscache_volume_free, "FREE ") \ 8662ab6335SDavid Howells EM(fscache_volume_new_acquire, "NEW acq ") \ 8762ab6335SDavid Howells EM(fscache_volume_put_cookie, "PUT cook ") \ 8862ab6335SDavid Howells EM(fscache_volume_put_create_work, "PUT creat") \ 8962ab6335SDavid Howells EM(fscache_volume_put_hash_collision, "PUT hcoll") \ 9062ab6335SDavid Howells EM(fscache_volume_put_relinquish, "PUT relnq") \ 9162ab6335SDavid Howells EM(fscache_volume_see_create_work, "SEE creat") \ 9262ab6335SDavid Howells E_(fscache_volume_see_hash_wake, "SEE hwake") 931e1236b8SDavid Howells 94*7f3283abSDavid Howells #define fscache_cookie_traces \ 95*7f3283abSDavid Howells EM(fscache_cookie_collision, "*COLLIDE*") \ 96*7f3283abSDavid Howells EM(fscache_cookie_discard, "DISCARD ") \ 97*7f3283abSDavid Howells EM(fscache_cookie_get_hash_collision, "GET hcoll") \ 98*7f3283abSDavid Howells EM(fscache_cookie_get_end_access, "GQ endac") \ 99*7f3283abSDavid Howells EM(fscache_cookie_new_acquire, "NEW acq ") \ 100*7f3283abSDavid Howells EM(fscache_cookie_put_hash_collision, "PUT hcoll") \ 101*7f3283abSDavid Howells EM(fscache_cookie_put_over_queued, "PQ overq") \ 102*7f3283abSDavid Howells EM(fscache_cookie_put_relinquish, "PUT relnq") \ 103*7f3283abSDavid Howells EM(fscache_cookie_put_withdrawn, "PUT wthdn") \ 104*7f3283abSDavid Howells EM(fscache_cookie_put_work, "PQ work ") \ 105*7f3283abSDavid Howells EM(fscache_cookie_see_active, "- activ") \ 106*7f3283abSDavid Howells EM(fscache_cookie_see_relinquish, "- x-rlq") \ 107*7f3283abSDavid Howells EM(fscache_cookie_see_withdraw, "- x-wth") \ 108*7f3283abSDavid Howells E_(fscache_cookie_see_work, "- work ") 109*7f3283abSDavid Howells 1101e1236b8SDavid Howells /* 1111e1236b8SDavid Howells * Export enum symbols via userspace. 1121e1236b8SDavid Howells */ 1131e1236b8SDavid Howells #undef EM 1141e1236b8SDavid Howells #undef E_ 1151e1236b8SDavid Howells #define EM(a, b) TRACE_DEFINE_ENUM(a); 1161e1236b8SDavid Howells #define E_(a, b) TRACE_DEFINE_ENUM(a); 1171e1236b8SDavid Howells 1189549332dSDavid Howells fscache_cache_traces; 11962ab6335SDavid Howells fscache_volume_traces; 120*7f3283abSDavid Howells fscache_cookie_traces; 1219549332dSDavid Howells 1221e1236b8SDavid Howells /* 1231e1236b8SDavid Howells * Now redefine the EM() and E_() macros to map the enums to the strings that 1241e1236b8SDavid Howells * will be printed in the output. 1251e1236b8SDavid Howells */ 1261e1236b8SDavid Howells #undef EM 1271e1236b8SDavid Howells #undef E_ 1281e1236b8SDavid Howells #define EM(a, b) { a, b }, 1291e1236b8SDavid Howells #define E_(a, b) { a, b } 1301e1236b8SDavid Howells 1311e1236b8SDavid Howells 1329549332dSDavid Howells TRACE_EVENT(fscache_cache, 1339549332dSDavid Howells TP_PROTO(unsigned int cache_debug_id, 1349549332dSDavid Howells int usage, 1359549332dSDavid Howells enum fscache_cache_trace where), 1369549332dSDavid Howells 1379549332dSDavid Howells TP_ARGS(cache_debug_id, usage, where), 1389549332dSDavid Howells 1399549332dSDavid Howells TP_STRUCT__entry( 1409549332dSDavid Howells __field(unsigned int, cache ) 1419549332dSDavid Howells __field(int, usage ) 1429549332dSDavid Howells __field(enum fscache_cache_trace, where ) 1439549332dSDavid Howells ), 1449549332dSDavid Howells 1459549332dSDavid Howells TP_fast_assign( 1469549332dSDavid Howells __entry->cache = cache_debug_id; 1479549332dSDavid Howells __entry->usage = usage; 1489549332dSDavid Howells __entry->where = where; 1499549332dSDavid Howells ), 1509549332dSDavid Howells 1519549332dSDavid Howells TP_printk("C=%08x %s r=%d", 1529549332dSDavid Howells __entry->cache, 1539549332dSDavid Howells __print_symbolic(__entry->where, fscache_cache_traces), 1549549332dSDavid Howells __entry->usage) 1559549332dSDavid Howells ); 1569549332dSDavid Howells 15762ab6335SDavid Howells TRACE_EVENT(fscache_volume, 15862ab6335SDavid Howells TP_PROTO(unsigned int volume_debug_id, 15962ab6335SDavid Howells int usage, 16062ab6335SDavid Howells enum fscache_volume_trace where), 16162ab6335SDavid Howells 16262ab6335SDavid Howells TP_ARGS(volume_debug_id, usage, where), 16362ab6335SDavid Howells 16462ab6335SDavid Howells TP_STRUCT__entry( 16562ab6335SDavid Howells __field(unsigned int, volume ) 16662ab6335SDavid Howells __field(int, usage ) 16762ab6335SDavid Howells __field(enum fscache_volume_trace, where ) 16862ab6335SDavid Howells ), 16962ab6335SDavid Howells 17062ab6335SDavid Howells TP_fast_assign( 17162ab6335SDavid Howells __entry->volume = volume_debug_id; 17262ab6335SDavid Howells __entry->usage = usage; 17362ab6335SDavid Howells __entry->where = where; 17462ab6335SDavid Howells ), 17562ab6335SDavid Howells 17662ab6335SDavid Howells TP_printk("V=%08x %s u=%d", 17762ab6335SDavid Howells __entry->volume, 17862ab6335SDavid Howells __print_symbolic(__entry->where, fscache_volume_traces), 17962ab6335SDavid Howells __entry->usage) 18062ab6335SDavid Howells ); 18162ab6335SDavid Howells 182*7f3283abSDavid Howells TRACE_EVENT(fscache_cookie, 183*7f3283abSDavid Howells TP_PROTO(unsigned int cookie_debug_id, 184*7f3283abSDavid Howells int ref, 185*7f3283abSDavid Howells enum fscache_cookie_trace where), 186*7f3283abSDavid Howells 187*7f3283abSDavid Howells TP_ARGS(cookie_debug_id, ref, where), 188*7f3283abSDavid Howells 189*7f3283abSDavid Howells TP_STRUCT__entry( 190*7f3283abSDavid Howells __field(unsigned int, cookie ) 191*7f3283abSDavid Howells __field(int, ref ) 192*7f3283abSDavid Howells __field(enum fscache_cookie_trace, where ) 193*7f3283abSDavid Howells ), 194*7f3283abSDavid Howells 195*7f3283abSDavid Howells TP_fast_assign( 196*7f3283abSDavid Howells __entry->cookie = cookie_debug_id; 197*7f3283abSDavid Howells __entry->ref = ref; 198*7f3283abSDavid Howells __entry->where = where; 199*7f3283abSDavid Howells ), 200*7f3283abSDavid Howells 201*7f3283abSDavid Howells TP_printk("c=%08x %s r=%d", 202*7f3283abSDavid Howells __entry->cookie, 203*7f3283abSDavid Howells __print_symbolic(__entry->where, fscache_cookie_traces), 204*7f3283abSDavid Howells __entry->ref) 205*7f3283abSDavid Howells ); 206*7f3283abSDavid Howells 207*7f3283abSDavid Howells TRACE_EVENT(fscache_acquire, 208*7f3283abSDavid Howells TP_PROTO(struct fscache_cookie *cookie), 209*7f3283abSDavid Howells 210*7f3283abSDavid Howells TP_ARGS(cookie), 211*7f3283abSDavid Howells 212*7f3283abSDavid Howells TP_STRUCT__entry( 213*7f3283abSDavid Howells __field(unsigned int, cookie ) 214*7f3283abSDavid Howells __field(unsigned int, volume ) 215*7f3283abSDavid Howells __field(int, v_ref ) 216*7f3283abSDavid Howells __field(int, v_n_cookies ) 217*7f3283abSDavid Howells ), 218*7f3283abSDavid Howells 219*7f3283abSDavid Howells TP_fast_assign( 220*7f3283abSDavid Howells __entry->cookie = cookie->debug_id; 221*7f3283abSDavid Howells __entry->volume = cookie->volume->debug_id; 222*7f3283abSDavid Howells __entry->v_ref = refcount_read(&cookie->volume->ref); 223*7f3283abSDavid Howells __entry->v_n_cookies = atomic_read(&cookie->volume->n_cookies); 224*7f3283abSDavid Howells ), 225*7f3283abSDavid Howells 226*7f3283abSDavid Howells TP_printk("c=%08x V=%08x vr=%d vc=%d", 227*7f3283abSDavid Howells __entry->cookie, 228*7f3283abSDavid Howells __entry->volume, __entry->v_ref, __entry->v_n_cookies) 229*7f3283abSDavid Howells ); 230*7f3283abSDavid Howells 231*7f3283abSDavid Howells TRACE_EVENT(fscache_relinquish, 232*7f3283abSDavid Howells TP_PROTO(struct fscache_cookie *cookie, bool retire), 233*7f3283abSDavid Howells 234*7f3283abSDavid Howells TP_ARGS(cookie, retire), 235*7f3283abSDavid Howells 236*7f3283abSDavid Howells TP_STRUCT__entry( 237*7f3283abSDavid Howells __field(unsigned int, cookie ) 238*7f3283abSDavid Howells __field(unsigned int, volume ) 239*7f3283abSDavid Howells __field(int, ref ) 240*7f3283abSDavid Howells __field(int, n_active ) 241*7f3283abSDavid Howells __field(u8, flags ) 242*7f3283abSDavid Howells __field(bool, retire ) 243*7f3283abSDavid Howells ), 244*7f3283abSDavid Howells 245*7f3283abSDavid Howells TP_fast_assign( 246*7f3283abSDavid Howells __entry->cookie = cookie->debug_id; 247*7f3283abSDavid Howells __entry->volume = cookie->volume->debug_id; 248*7f3283abSDavid Howells __entry->ref = refcount_read(&cookie->ref); 249*7f3283abSDavid Howells __entry->n_active = atomic_read(&cookie->n_active); 250*7f3283abSDavid Howells __entry->flags = cookie->flags; 251*7f3283abSDavid Howells __entry->retire = retire; 252*7f3283abSDavid Howells ), 253*7f3283abSDavid Howells 254*7f3283abSDavid Howells TP_printk("c=%08x V=%08x r=%d U=%d f=%02x rt=%u", 255*7f3283abSDavid Howells __entry->cookie, __entry->volume, __entry->ref, 256*7f3283abSDavid Howells __entry->n_active, __entry->flags, __entry->retire) 257*7f3283abSDavid Howells ); 258*7f3283abSDavid Howells 2591e1236b8SDavid Howells #endif /* _TRACE_FSCACHE_H */ 2601e1236b8SDavid Howells 2611e1236b8SDavid Howells /* This part must be outside protection */ 2621e1236b8SDavid Howells #include <trace/define_trace.h> 263