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, 46e6acd329SDavid 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 { 67*bfa22da3SDavid Howells fscache_access_acquire_volume, 68*bfa22da3SDavid Howells fscache_access_acquire_volume_end, 6923e12e28SDavid Howells fscache_access_cache_pin, 7023e12e28SDavid Howells fscache_access_cache_unpin, 71*bfa22da3SDavid Howells fscache_access_relinquish_volume, 72*bfa22da3SDavid Howells fscache_access_relinquish_volume_end, 7323e12e28SDavid Howells fscache_access_unlive, 7423e12e28SDavid Howells }; 7523e12e28SDavid Howells 761e1236b8SDavid Howells #endif 771e1236b8SDavid Howells 781e1236b8SDavid Howells /* 791e1236b8SDavid Howells * Declare tracing information enums and their string mappings for display. 801e1236b8SDavid Howells */ 819549332dSDavid Howells #define fscache_cache_traces \ 829549332dSDavid Howells EM(fscache_cache_collision, "*COLLIDE*") \ 839549332dSDavid Howells EM(fscache_cache_get_acquire, "GET acq ") \ 849549332dSDavid Howells EM(fscache_cache_new_acquire, "NEW acq ") \ 8562ab6335SDavid Howells EM(fscache_cache_put_alloc_volume, "PUT alvol") \ 869549332dSDavid Howells EM(fscache_cache_put_cache, "PUT cache") \ 879549332dSDavid Howells EM(fscache_cache_put_prep_failed, "PUT pfail") \ 8862ab6335SDavid Howells EM(fscache_cache_put_relinquish, "PUT relnq") \ 8962ab6335SDavid Howells E_(fscache_cache_put_volume, "PUT vol ") 9062ab6335SDavid Howells 9162ab6335SDavid Howells #define fscache_volume_traces \ 9262ab6335SDavid Howells EM(fscache_volume_collision, "*COLLIDE*") \ 9362ab6335SDavid Howells EM(fscache_volume_get_cookie, "GET cook ") \ 9462ab6335SDavid Howells EM(fscache_volume_get_create_work, "GET creat") \ 9562ab6335SDavid Howells EM(fscache_volume_get_hash_collision, "GET hcoll") \ 9662ab6335SDavid Howells EM(fscache_volume_free, "FREE ") \ 9762ab6335SDavid Howells EM(fscache_volume_new_acquire, "NEW acq ") \ 9862ab6335SDavid Howells EM(fscache_volume_put_cookie, "PUT cook ") \ 9962ab6335SDavid Howells EM(fscache_volume_put_create_work, "PUT creat") \ 10062ab6335SDavid Howells EM(fscache_volume_put_hash_collision, "PUT hcoll") \ 10162ab6335SDavid Howells EM(fscache_volume_put_relinquish, "PUT relnq") \ 10262ab6335SDavid Howells EM(fscache_volume_see_create_work, "SEE creat") \ 103*bfa22da3SDavid Howells EM(fscache_volume_see_hash_wake, "SEE hwake") \ 104*bfa22da3SDavid Howells E_(fscache_volume_wait_create_work, "WAIT crea") 1051e1236b8SDavid Howells 1067f3283abSDavid Howells #define fscache_cookie_traces \ 1077f3283abSDavid Howells EM(fscache_cookie_collision, "*COLLIDE*") \ 1087f3283abSDavid Howells EM(fscache_cookie_discard, "DISCARD ") \ 1097f3283abSDavid Howells EM(fscache_cookie_get_hash_collision, "GET hcoll") \ 1107f3283abSDavid Howells EM(fscache_cookie_get_end_access, "GQ endac") \ 1117f3283abSDavid Howells EM(fscache_cookie_new_acquire, "NEW acq ") \ 1127f3283abSDavid Howells EM(fscache_cookie_put_hash_collision, "PUT hcoll") \ 1137f3283abSDavid Howells EM(fscache_cookie_put_over_queued, "PQ overq") \ 1147f3283abSDavid Howells EM(fscache_cookie_put_relinquish, "PUT relnq") \ 1157f3283abSDavid Howells EM(fscache_cookie_put_withdrawn, "PUT wthdn") \ 1167f3283abSDavid Howells EM(fscache_cookie_put_work, "PQ work ") \ 1177f3283abSDavid Howells EM(fscache_cookie_see_active, "- activ") \ 1187f3283abSDavid Howells EM(fscache_cookie_see_relinquish, "- x-rlq") \ 1197f3283abSDavid Howells EM(fscache_cookie_see_withdraw, "- x-wth") \ 1207f3283abSDavid Howells E_(fscache_cookie_see_work, "- work ") 1217f3283abSDavid Howells 12223e12e28SDavid Howells #define fscache_access_traces \ 123*bfa22da3SDavid Howells EM(fscache_access_acquire_volume, "BEGIN acq_vol") \ 124*bfa22da3SDavid Howells EM(fscache_access_acquire_volume_end, "END acq_vol") \ 12523e12e28SDavid Howells EM(fscache_access_cache_pin, "PIN cache ") \ 12623e12e28SDavid Howells EM(fscache_access_cache_unpin, "UNPIN cache ") \ 127*bfa22da3SDavid Howells EM(fscache_access_relinquish_volume, "BEGIN rlq_vol") \ 128*bfa22da3SDavid Howells EM(fscache_access_relinquish_volume_end,"END rlq_vol") \ 12923e12e28SDavid Howells E_(fscache_access_unlive, "END unlive ") 13023e12e28SDavid Howells 1311e1236b8SDavid Howells /* 1321e1236b8SDavid Howells * Export enum symbols via userspace. 1331e1236b8SDavid Howells */ 1341e1236b8SDavid Howells #undef EM 1351e1236b8SDavid Howells #undef E_ 1361e1236b8SDavid Howells #define EM(a, b) TRACE_DEFINE_ENUM(a); 1371e1236b8SDavid Howells #define E_(a, b) TRACE_DEFINE_ENUM(a); 1381e1236b8SDavid Howells 1399549332dSDavid Howells fscache_cache_traces; 14062ab6335SDavid Howells fscache_volume_traces; 1417f3283abSDavid Howells fscache_cookie_traces; 14223e12e28SDavid Howells fscache_access_traces; 1439549332dSDavid Howells 1441e1236b8SDavid Howells /* 1451e1236b8SDavid Howells * Now redefine the EM() and E_() macros to map the enums to the strings that 1461e1236b8SDavid Howells * will be printed in the output. 1471e1236b8SDavid Howells */ 1481e1236b8SDavid Howells #undef EM 1491e1236b8SDavid Howells #undef E_ 1501e1236b8SDavid Howells #define EM(a, b) { a, b }, 1511e1236b8SDavid Howells #define E_(a, b) { a, b } 1521e1236b8SDavid Howells 1531e1236b8SDavid Howells 1549549332dSDavid Howells TRACE_EVENT(fscache_cache, 1559549332dSDavid Howells TP_PROTO(unsigned int cache_debug_id, 1569549332dSDavid Howells int usage, 1579549332dSDavid Howells enum fscache_cache_trace where), 1589549332dSDavid Howells 1599549332dSDavid Howells TP_ARGS(cache_debug_id, usage, where), 1609549332dSDavid Howells 1619549332dSDavid Howells TP_STRUCT__entry( 1629549332dSDavid Howells __field(unsigned int, cache ) 1639549332dSDavid Howells __field(int, usage ) 1649549332dSDavid Howells __field(enum fscache_cache_trace, where ) 1659549332dSDavid Howells ), 1669549332dSDavid Howells 1679549332dSDavid Howells TP_fast_assign( 1689549332dSDavid Howells __entry->cache = cache_debug_id; 1699549332dSDavid Howells __entry->usage = usage; 1709549332dSDavid Howells __entry->where = where; 1719549332dSDavid Howells ), 1729549332dSDavid Howells 1739549332dSDavid Howells TP_printk("C=%08x %s r=%d", 1749549332dSDavid Howells __entry->cache, 1759549332dSDavid Howells __print_symbolic(__entry->where, fscache_cache_traces), 1769549332dSDavid Howells __entry->usage) 1779549332dSDavid Howells ); 1789549332dSDavid Howells 17962ab6335SDavid Howells TRACE_EVENT(fscache_volume, 18062ab6335SDavid Howells TP_PROTO(unsigned int volume_debug_id, 18162ab6335SDavid Howells int usage, 18262ab6335SDavid Howells enum fscache_volume_trace where), 18362ab6335SDavid Howells 18462ab6335SDavid Howells TP_ARGS(volume_debug_id, usage, where), 18562ab6335SDavid Howells 18662ab6335SDavid Howells TP_STRUCT__entry( 18762ab6335SDavid Howells __field(unsigned int, volume ) 18862ab6335SDavid Howells __field(int, usage ) 18962ab6335SDavid Howells __field(enum fscache_volume_trace, where ) 19062ab6335SDavid Howells ), 19162ab6335SDavid Howells 19262ab6335SDavid Howells TP_fast_assign( 19362ab6335SDavid Howells __entry->volume = volume_debug_id; 19462ab6335SDavid Howells __entry->usage = usage; 19562ab6335SDavid Howells __entry->where = where; 19662ab6335SDavid Howells ), 19762ab6335SDavid Howells 19862ab6335SDavid Howells TP_printk("V=%08x %s u=%d", 19962ab6335SDavid Howells __entry->volume, 20062ab6335SDavid Howells __print_symbolic(__entry->where, fscache_volume_traces), 20162ab6335SDavid Howells __entry->usage) 20262ab6335SDavid Howells ); 20362ab6335SDavid Howells 2047f3283abSDavid Howells TRACE_EVENT(fscache_cookie, 2057f3283abSDavid Howells TP_PROTO(unsigned int cookie_debug_id, 2067f3283abSDavid Howells int ref, 2077f3283abSDavid Howells enum fscache_cookie_trace where), 2087f3283abSDavid Howells 2097f3283abSDavid Howells TP_ARGS(cookie_debug_id, ref, where), 2107f3283abSDavid Howells 2117f3283abSDavid Howells TP_STRUCT__entry( 2127f3283abSDavid Howells __field(unsigned int, cookie ) 2137f3283abSDavid Howells __field(int, ref ) 2147f3283abSDavid Howells __field(enum fscache_cookie_trace, where ) 2157f3283abSDavid Howells ), 2167f3283abSDavid Howells 2177f3283abSDavid Howells TP_fast_assign( 2187f3283abSDavid Howells __entry->cookie = cookie_debug_id; 2197f3283abSDavid Howells __entry->ref = ref; 2207f3283abSDavid Howells __entry->where = where; 2217f3283abSDavid Howells ), 2227f3283abSDavid Howells 2237f3283abSDavid Howells TP_printk("c=%08x %s r=%d", 2247f3283abSDavid Howells __entry->cookie, 2257f3283abSDavid Howells __print_symbolic(__entry->where, fscache_cookie_traces), 2267f3283abSDavid Howells __entry->ref) 2277f3283abSDavid Howells ); 2287f3283abSDavid Howells 22923e12e28SDavid Howells TRACE_EVENT(fscache_access_cache, 23023e12e28SDavid Howells TP_PROTO(unsigned int cache_debug_id, 23123e12e28SDavid Howells int ref, 23223e12e28SDavid Howells int n_accesses, 23323e12e28SDavid Howells enum fscache_access_trace why), 23423e12e28SDavid Howells 23523e12e28SDavid Howells TP_ARGS(cache_debug_id, ref, n_accesses, why), 23623e12e28SDavid Howells 23723e12e28SDavid Howells TP_STRUCT__entry( 23823e12e28SDavid Howells __field(unsigned int, cache ) 23923e12e28SDavid Howells __field(int, ref ) 24023e12e28SDavid Howells __field(int, n_accesses ) 24123e12e28SDavid Howells __field(enum fscache_access_trace, why ) 24223e12e28SDavid Howells ), 24323e12e28SDavid Howells 24423e12e28SDavid Howells TP_fast_assign( 24523e12e28SDavid Howells __entry->cache = cache_debug_id; 24623e12e28SDavid Howells __entry->ref = ref; 24723e12e28SDavid Howells __entry->n_accesses = n_accesses; 24823e12e28SDavid Howells __entry->why = why; 24923e12e28SDavid Howells ), 25023e12e28SDavid Howells 25123e12e28SDavid Howells TP_printk("C=%08x %s r=%d a=%d", 25223e12e28SDavid Howells __entry->cache, 25323e12e28SDavid Howells __print_symbolic(__entry->why, fscache_access_traces), 25423e12e28SDavid Howells __entry->ref, 25523e12e28SDavid Howells __entry->n_accesses) 25623e12e28SDavid Howells ); 25723e12e28SDavid Howells 258e6acd329SDavid Howells TRACE_EVENT(fscache_access_volume, 259e6acd329SDavid Howells TP_PROTO(unsigned int volume_debug_id, 260e6acd329SDavid Howells unsigned int cookie_debug_id, 261e6acd329SDavid Howells int ref, 262e6acd329SDavid Howells int n_accesses, 263e6acd329SDavid Howells enum fscache_access_trace why), 264e6acd329SDavid Howells 265e6acd329SDavid Howells TP_ARGS(volume_debug_id, cookie_debug_id, ref, n_accesses, why), 266e6acd329SDavid Howells 267e6acd329SDavid Howells TP_STRUCT__entry( 268e6acd329SDavid Howells __field(unsigned int, volume ) 269e6acd329SDavid Howells __field(unsigned int, cookie ) 270e6acd329SDavid Howells __field(int, ref ) 271e6acd329SDavid Howells __field(int, n_accesses ) 272e6acd329SDavid Howells __field(enum fscache_access_trace, why ) 273e6acd329SDavid Howells ), 274e6acd329SDavid Howells 275e6acd329SDavid Howells TP_fast_assign( 276e6acd329SDavid Howells __entry->volume = volume_debug_id; 277e6acd329SDavid Howells __entry->cookie = cookie_debug_id; 278e6acd329SDavid Howells __entry->ref = ref; 279e6acd329SDavid Howells __entry->n_accesses = n_accesses; 280e6acd329SDavid Howells __entry->why = why; 281e6acd329SDavid Howells ), 282e6acd329SDavid Howells 283e6acd329SDavid Howells TP_printk("V=%08x c=%08x %s r=%d a=%d", 284e6acd329SDavid Howells __entry->volume, 285e6acd329SDavid Howells __entry->cookie, 286e6acd329SDavid Howells __print_symbolic(__entry->why, fscache_access_traces), 287e6acd329SDavid Howells __entry->ref, 288e6acd329SDavid Howells __entry->n_accesses) 289e6acd329SDavid Howells ); 290e6acd329SDavid Howells 291a7733fb6SDavid Howells TRACE_EVENT(fscache_access, 292a7733fb6SDavid Howells TP_PROTO(unsigned int cookie_debug_id, 293a7733fb6SDavid Howells int ref, 294a7733fb6SDavid Howells int n_accesses, 295a7733fb6SDavid Howells enum fscache_access_trace why), 296a7733fb6SDavid Howells 297a7733fb6SDavid Howells TP_ARGS(cookie_debug_id, ref, n_accesses, why), 298a7733fb6SDavid Howells 299a7733fb6SDavid Howells TP_STRUCT__entry( 300a7733fb6SDavid Howells __field(unsigned int, cookie ) 301a7733fb6SDavid Howells __field(int, ref ) 302a7733fb6SDavid Howells __field(int, n_accesses ) 303a7733fb6SDavid Howells __field(enum fscache_access_trace, why ) 304a7733fb6SDavid Howells ), 305a7733fb6SDavid Howells 306a7733fb6SDavid Howells TP_fast_assign( 307a7733fb6SDavid Howells __entry->cookie = cookie_debug_id; 308a7733fb6SDavid Howells __entry->ref = ref; 309a7733fb6SDavid Howells __entry->n_accesses = n_accesses; 310a7733fb6SDavid Howells __entry->why = why; 311a7733fb6SDavid Howells ), 312a7733fb6SDavid Howells 313a7733fb6SDavid Howells TP_printk("c=%08x %s r=%d a=%d", 314a7733fb6SDavid Howells __entry->cookie, 315a7733fb6SDavid Howells __print_symbolic(__entry->why, fscache_access_traces), 316a7733fb6SDavid Howells __entry->ref, 317a7733fb6SDavid Howells __entry->n_accesses) 318a7733fb6SDavid Howells ); 319a7733fb6SDavid Howells 3207f3283abSDavid Howells TRACE_EVENT(fscache_acquire, 3217f3283abSDavid Howells TP_PROTO(struct fscache_cookie *cookie), 3227f3283abSDavid Howells 3237f3283abSDavid Howells TP_ARGS(cookie), 3247f3283abSDavid Howells 3257f3283abSDavid Howells TP_STRUCT__entry( 3267f3283abSDavid Howells __field(unsigned int, cookie ) 3277f3283abSDavid Howells __field(unsigned int, volume ) 3287f3283abSDavid Howells __field(int, v_ref ) 3297f3283abSDavid Howells __field(int, v_n_cookies ) 3307f3283abSDavid Howells ), 3317f3283abSDavid Howells 3327f3283abSDavid Howells TP_fast_assign( 3337f3283abSDavid Howells __entry->cookie = cookie->debug_id; 3347f3283abSDavid Howells __entry->volume = cookie->volume->debug_id; 3357f3283abSDavid Howells __entry->v_ref = refcount_read(&cookie->volume->ref); 3367f3283abSDavid Howells __entry->v_n_cookies = atomic_read(&cookie->volume->n_cookies); 3377f3283abSDavid Howells ), 3387f3283abSDavid Howells 3397f3283abSDavid Howells TP_printk("c=%08x V=%08x vr=%d vc=%d", 3407f3283abSDavid Howells __entry->cookie, 3417f3283abSDavid Howells __entry->volume, __entry->v_ref, __entry->v_n_cookies) 3427f3283abSDavid Howells ); 3437f3283abSDavid Howells 3447f3283abSDavid Howells TRACE_EVENT(fscache_relinquish, 3457f3283abSDavid Howells TP_PROTO(struct fscache_cookie *cookie, bool retire), 3467f3283abSDavid Howells 3477f3283abSDavid Howells TP_ARGS(cookie, retire), 3487f3283abSDavid Howells 3497f3283abSDavid Howells TP_STRUCT__entry( 3507f3283abSDavid Howells __field(unsigned int, cookie ) 3517f3283abSDavid Howells __field(unsigned int, volume ) 3527f3283abSDavid Howells __field(int, ref ) 3537f3283abSDavid Howells __field(int, n_active ) 3547f3283abSDavid Howells __field(u8, flags ) 3557f3283abSDavid Howells __field(bool, retire ) 3567f3283abSDavid Howells ), 3577f3283abSDavid Howells 3587f3283abSDavid Howells TP_fast_assign( 3597f3283abSDavid Howells __entry->cookie = cookie->debug_id; 3607f3283abSDavid Howells __entry->volume = cookie->volume->debug_id; 3617f3283abSDavid Howells __entry->ref = refcount_read(&cookie->ref); 3627f3283abSDavid Howells __entry->n_active = atomic_read(&cookie->n_active); 3637f3283abSDavid Howells __entry->flags = cookie->flags; 3647f3283abSDavid Howells __entry->retire = retire; 3657f3283abSDavid Howells ), 3667f3283abSDavid Howells 3677f3283abSDavid Howells TP_printk("c=%08x V=%08x r=%d U=%d f=%02x rt=%u", 3687f3283abSDavid Howells __entry->cookie, __entry->volume, __entry->ref, 3697f3283abSDavid Howells __entry->n_active, __entry->flags, __entry->retire) 3707f3283abSDavid Howells ); 3717f3283abSDavid Howells 3721e1236b8SDavid Howells #endif /* _TRACE_FSCACHE_H */ 3731e1236b8SDavid Howells 3741e1236b8SDavid Howells /* This part must be outside protection */ 3751e1236b8SDavid Howells #include <trace/define_trace.h> 376