1 /* SPDX-License-Identifier: GPL-2.0-or-later */ 2 /* FS-Cache tracepoints 3 * 4 * Copyright (C) 2021 Red Hat, Inc. All Rights Reserved. 5 * Written by David Howells (dhowells@redhat.com) 6 */ 7 #undef TRACE_SYSTEM 8 #define TRACE_SYSTEM fscache 9 10 #if !defined(_TRACE_FSCACHE_H) || defined(TRACE_HEADER_MULTI_READ) 11 #define _TRACE_FSCACHE_H 12 13 #include <linux/fscache.h> 14 #include <linux/tracepoint.h> 15 16 /* 17 * Define enums for tracing information. 18 */ 19 #ifndef __FSCACHE_DECLARE_TRACE_ENUMS_ONCE_ONLY 20 #define __FSCACHE_DECLARE_TRACE_ENUMS_ONCE_ONLY 21 22 enum fscache_cache_trace { 23 fscache_cache_collision, 24 fscache_cache_get_acquire, 25 fscache_cache_new_acquire, 26 fscache_cache_put_alloc_volume, 27 fscache_cache_put_cache, 28 fscache_cache_put_prep_failed, 29 fscache_cache_put_relinquish, 30 fscache_cache_put_volume, 31 }; 32 33 enum fscache_volume_trace { 34 fscache_volume_collision, 35 fscache_volume_get_cookie, 36 fscache_volume_get_create_work, 37 fscache_volume_get_hash_collision, 38 fscache_volume_free, 39 fscache_volume_new_acquire, 40 fscache_volume_put_cookie, 41 fscache_volume_put_create_work, 42 fscache_volume_put_hash_collision, 43 fscache_volume_put_relinquish, 44 fscache_volume_see_create_work, 45 fscache_volume_see_hash_wake, 46 fscache_volume_wait_create_work, 47 }; 48 49 enum fscache_cookie_trace { 50 fscache_cookie_collision, 51 fscache_cookie_discard, 52 fscache_cookie_failed, 53 fscache_cookie_get_attach_object, 54 fscache_cookie_get_end_access, 55 fscache_cookie_get_hash_collision, 56 fscache_cookie_get_inval_work, 57 fscache_cookie_get_lru, 58 fscache_cookie_get_use_work, 59 fscache_cookie_new_acquire, 60 fscache_cookie_put_hash_collision, 61 fscache_cookie_put_lru, 62 fscache_cookie_put_object, 63 fscache_cookie_put_over_queued, 64 fscache_cookie_put_relinquish, 65 fscache_cookie_put_withdrawn, 66 fscache_cookie_put_work, 67 fscache_cookie_see_active, 68 fscache_cookie_see_lru_discard, 69 fscache_cookie_see_lru_do_one, 70 fscache_cookie_see_relinquish, 71 fscache_cookie_see_withdraw, 72 fscache_cookie_see_work, 73 }; 74 75 enum fscache_active_trace { 76 fscache_active_use, 77 fscache_active_use_modify, 78 fscache_active_unuse, 79 }; 80 81 enum fscache_access_trace { 82 fscache_access_acquire_volume, 83 fscache_access_acquire_volume_end, 84 fscache_access_cache_pin, 85 fscache_access_cache_unpin, 86 fscache_access_invalidate_cookie, 87 fscache_access_invalidate_cookie_end, 88 fscache_access_io_end, 89 fscache_access_io_not_live, 90 fscache_access_io_read, 91 fscache_access_io_resize, 92 fscache_access_io_wait, 93 fscache_access_io_write, 94 fscache_access_lookup_cookie, 95 fscache_access_lookup_cookie_end, 96 fscache_access_lookup_cookie_end_failed, 97 fscache_access_relinquish_volume, 98 fscache_access_relinquish_volume_end, 99 fscache_access_unlive, 100 }; 101 102 #endif 103 104 /* 105 * Declare tracing information enums and their string mappings for display. 106 */ 107 #define fscache_cache_traces \ 108 EM(fscache_cache_collision, "*COLLIDE*") \ 109 EM(fscache_cache_get_acquire, "GET acq ") \ 110 EM(fscache_cache_new_acquire, "NEW acq ") \ 111 EM(fscache_cache_put_alloc_volume, "PUT alvol") \ 112 EM(fscache_cache_put_cache, "PUT cache") \ 113 EM(fscache_cache_put_prep_failed, "PUT pfail") \ 114 EM(fscache_cache_put_relinquish, "PUT relnq") \ 115 E_(fscache_cache_put_volume, "PUT vol ") 116 117 #define fscache_volume_traces \ 118 EM(fscache_volume_collision, "*COLLIDE*") \ 119 EM(fscache_volume_get_cookie, "GET cook ") \ 120 EM(fscache_volume_get_create_work, "GET creat") \ 121 EM(fscache_volume_get_hash_collision, "GET hcoll") \ 122 EM(fscache_volume_free, "FREE ") \ 123 EM(fscache_volume_new_acquire, "NEW acq ") \ 124 EM(fscache_volume_put_cookie, "PUT cook ") \ 125 EM(fscache_volume_put_create_work, "PUT creat") \ 126 EM(fscache_volume_put_hash_collision, "PUT hcoll") \ 127 EM(fscache_volume_put_relinquish, "PUT relnq") \ 128 EM(fscache_volume_see_create_work, "SEE creat") \ 129 EM(fscache_volume_see_hash_wake, "SEE hwake") \ 130 E_(fscache_volume_wait_create_work, "WAIT crea") 131 132 #define fscache_cookie_traces \ 133 EM(fscache_cookie_collision, "*COLLIDE*") \ 134 EM(fscache_cookie_discard, "DISCARD ") \ 135 EM(fscache_cookie_failed, "FAILED ") \ 136 EM(fscache_cookie_get_attach_object, "GET attch") \ 137 EM(fscache_cookie_get_hash_collision, "GET hcoll") \ 138 EM(fscache_cookie_get_end_access, "GQ endac") \ 139 EM(fscache_cookie_get_inval_work, "GQ inval") \ 140 EM(fscache_cookie_get_lru, "GET lru ") \ 141 EM(fscache_cookie_get_use_work, "GQ use ") \ 142 EM(fscache_cookie_new_acquire, "NEW acq ") \ 143 EM(fscache_cookie_put_hash_collision, "PUT hcoll") \ 144 EM(fscache_cookie_put_lru, "PUT lru ") \ 145 EM(fscache_cookie_put_object, "PUT obj ") \ 146 EM(fscache_cookie_put_over_queued, "PQ overq") \ 147 EM(fscache_cookie_put_relinquish, "PUT relnq") \ 148 EM(fscache_cookie_put_withdrawn, "PUT wthdn") \ 149 EM(fscache_cookie_put_work, "PQ work ") \ 150 EM(fscache_cookie_see_active, "- activ") \ 151 EM(fscache_cookie_see_lru_discard, "- x-lru") \ 152 EM(fscache_cookie_see_lru_do_one, "- lrudo") \ 153 EM(fscache_cookie_see_relinquish, "- x-rlq") \ 154 EM(fscache_cookie_see_withdraw, "- x-wth") \ 155 E_(fscache_cookie_see_work, "- work ") 156 157 #define fscache_active_traces \ 158 EM(fscache_active_use, "USE ") \ 159 EM(fscache_active_use_modify, "USE-m ") \ 160 E_(fscache_active_unuse, "UNUSE ") 161 162 #define fscache_access_traces \ 163 EM(fscache_access_acquire_volume, "BEGIN acq_vol") \ 164 EM(fscache_access_acquire_volume_end, "END acq_vol") \ 165 EM(fscache_access_cache_pin, "PIN cache ") \ 166 EM(fscache_access_cache_unpin, "UNPIN cache ") \ 167 EM(fscache_access_invalidate_cookie, "BEGIN inval ") \ 168 EM(fscache_access_invalidate_cookie_end,"END inval ") \ 169 EM(fscache_access_io_end, "END io ") \ 170 EM(fscache_access_io_not_live, "END io_notl") \ 171 EM(fscache_access_io_read, "BEGIN io_read") \ 172 EM(fscache_access_io_resize, "BEGIN io_resz") \ 173 EM(fscache_access_io_wait, "WAIT io ") \ 174 EM(fscache_access_io_write, "BEGIN io_writ") \ 175 EM(fscache_access_lookup_cookie, "BEGIN lookup ") \ 176 EM(fscache_access_lookup_cookie_end, "END lookup ") \ 177 EM(fscache_access_lookup_cookie_end_failed,"END lookupf") \ 178 EM(fscache_access_relinquish_volume, "BEGIN rlq_vol") \ 179 EM(fscache_access_relinquish_volume_end,"END rlq_vol") \ 180 E_(fscache_access_unlive, "END unlive ") 181 182 /* 183 * Export enum symbols via userspace. 184 */ 185 #undef EM 186 #undef E_ 187 #define EM(a, b) TRACE_DEFINE_ENUM(a); 188 #define E_(a, b) TRACE_DEFINE_ENUM(a); 189 190 fscache_cache_traces; 191 fscache_volume_traces; 192 fscache_cookie_traces; 193 fscache_access_traces; 194 195 /* 196 * Now redefine the EM() and E_() macros to map the enums to the strings that 197 * will be printed in the output. 198 */ 199 #undef EM 200 #undef E_ 201 #define EM(a, b) { a, b }, 202 #define E_(a, b) { a, b } 203 204 205 TRACE_EVENT(fscache_cache, 206 TP_PROTO(unsigned int cache_debug_id, 207 int usage, 208 enum fscache_cache_trace where), 209 210 TP_ARGS(cache_debug_id, usage, where), 211 212 TP_STRUCT__entry( 213 __field(unsigned int, cache ) 214 __field(int, usage ) 215 __field(enum fscache_cache_trace, where ) 216 ), 217 218 TP_fast_assign( 219 __entry->cache = cache_debug_id; 220 __entry->usage = usage; 221 __entry->where = where; 222 ), 223 224 TP_printk("C=%08x %s r=%d", 225 __entry->cache, 226 __print_symbolic(__entry->where, fscache_cache_traces), 227 __entry->usage) 228 ); 229 230 TRACE_EVENT(fscache_volume, 231 TP_PROTO(unsigned int volume_debug_id, 232 int usage, 233 enum fscache_volume_trace where), 234 235 TP_ARGS(volume_debug_id, usage, where), 236 237 TP_STRUCT__entry( 238 __field(unsigned int, volume ) 239 __field(int, usage ) 240 __field(enum fscache_volume_trace, where ) 241 ), 242 243 TP_fast_assign( 244 __entry->volume = volume_debug_id; 245 __entry->usage = usage; 246 __entry->where = where; 247 ), 248 249 TP_printk("V=%08x %s u=%d", 250 __entry->volume, 251 __print_symbolic(__entry->where, fscache_volume_traces), 252 __entry->usage) 253 ); 254 255 TRACE_EVENT(fscache_cookie, 256 TP_PROTO(unsigned int cookie_debug_id, 257 int ref, 258 enum fscache_cookie_trace where), 259 260 TP_ARGS(cookie_debug_id, ref, where), 261 262 TP_STRUCT__entry( 263 __field(unsigned int, cookie ) 264 __field(int, ref ) 265 __field(enum fscache_cookie_trace, where ) 266 ), 267 268 TP_fast_assign( 269 __entry->cookie = cookie_debug_id; 270 __entry->ref = ref; 271 __entry->where = where; 272 ), 273 274 TP_printk("c=%08x %s r=%d", 275 __entry->cookie, 276 __print_symbolic(__entry->where, fscache_cookie_traces), 277 __entry->ref) 278 ); 279 280 TRACE_EVENT(fscache_active, 281 TP_PROTO(unsigned int cookie_debug_id, 282 int ref, 283 int n_active, 284 int n_accesses, 285 enum fscache_active_trace why), 286 287 TP_ARGS(cookie_debug_id, ref, n_active, n_accesses, why), 288 289 TP_STRUCT__entry( 290 __field(unsigned int, cookie ) 291 __field(int, ref ) 292 __field(int, n_active ) 293 __field(int, n_accesses ) 294 __field(enum fscache_active_trace, why ) 295 ), 296 297 TP_fast_assign( 298 __entry->cookie = cookie_debug_id; 299 __entry->ref = ref; 300 __entry->n_active = n_active; 301 __entry->n_accesses = n_accesses; 302 __entry->why = why; 303 ), 304 305 TP_printk("c=%08x %s r=%d a=%d c=%d", 306 __entry->cookie, 307 __print_symbolic(__entry->why, fscache_active_traces), 308 __entry->ref, 309 __entry->n_accesses, 310 __entry->n_active) 311 ); 312 313 TRACE_EVENT(fscache_access_cache, 314 TP_PROTO(unsigned int cache_debug_id, 315 int ref, 316 int n_accesses, 317 enum fscache_access_trace why), 318 319 TP_ARGS(cache_debug_id, ref, n_accesses, why), 320 321 TP_STRUCT__entry( 322 __field(unsigned int, cache ) 323 __field(int, ref ) 324 __field(int, n_accesses ) 325 __field(enum fscache_access_trace, why ) 326 ), 327 328 TP_fast_assign( 329 __entry->cache = cache_debug_id; 330 __entry->ref = ref; 331 __entry->n_accesses = n_accesses; 332 __entry->why = why; 333 ), 334 335 TP_printk("C=%08x %s r=%d a=%d", 336 __entry->cache, 337 __print_symbolic(__entry->why, fscache_access_traces), 338 __entry->ref, 339 __entry->n_accesses) 340 ); 341 342 TRACE_EVENT(fscache_access_volume, 343 TP_PROTO(unsigned int volume_debug_id, 344 unsigned int cookie_debug_id, 345 int ref, 346 int n_accesses, 347 enum fscache_access_trace why), 348 349 TP_ARGS(volume_debug_id, cookie_debug_id, ref, n_accesses, why), 350 351 TP_STRUCT__entry( 352 __field(unsigned int, volume ) 353 __field(unsigned int, cookie ) 354 __field(int, ref ) 355 __field(int, n_accesses ) 356 __field(enum fscache_access_trace, why ) 357 ), 358 359 TP_fast_assign( 360 __entry->volume = volume_debug_id; 361 __entry->cookie = cookie_debug_id; 362 __entry->ref = ref; 363 __entry->n_accesses = n_accesses; 364 __entry->why = why; 365 ), 366 367 TP_printk("V=%08x c=%08x %s r=%d a=%d", 368 __entry->volume, 369 __entry->cookie, 370 __print_symbolic(__entry->why, fscache_access_traces), 371 __entry->ref, 372 __entry->n_accesses) 373 ); 374 375 TRACE_EVENT(fscache_access, 376 TP_PROTO(unsigned int cookie_debug_id, 377 int ref, 378 int n_accesses, 379 enum fscache_access_trace why), 380 381 TP_ARGS(cookie_debug_id, ref, n_accesses, why), 382 383 TP_STRUCT__entry( 384 __field(unsigned int, cookie ) 385 __field(int, ref ) 386 __field(int, n_accesses ) 387 __field(enum fscache_access_trace, why ) 388 ), 389 390 TP_fast_assign( 391 __entry->cookie = cookie_debug_id; 392 __entry->ref = ref; 393 __entry->n_accesses = n_accesses; 394 __entry->why = why; 395 ), 396 397 TP_printk("c=%08x %s r=%d a=%d", 398 __entry->cookie, 399 __print_symbolic(__entry->why, fscache_access_traces), 400 __entry->ref, 401 __entry->n_accesses) 402 ); 403 404 TRACE_EVENT(fscache_acquire, 405 TP_PROTO(struct fscache_cookie *cookie), 406 407 TP_ARGS(cookie), 408 409 TP_STRUCT__entry( 410 __field(unsigned int, cookie ) 411 __field(unsigned int, volume ) 412 __field(int, v_ref ) 413 __field(int, v_n_cookies ) 414 ), 415 416 TP_fast_assign( 417 __entry->cookie = cookie->debug_id; 418 __entry->volume = cookie->volume->debug_id; 419 __entry->v_ref = refcount_read(&cookie->volume->ref); 420 __entry->v_n_cookies = atomic_read(&cookie->volume->n_cookies); 421 ), 422 423 TP_printk("c=%08x V=%08x vr=%d vc=%d", 424 __entry->cookie, 425 __entry->volume, __entry->v_ref, __entry->v_n_cookies) 426 ); 427 428 TRACE_EVENT(fscache_relinquish, 429 TP_PROTO(struct fscache_cookie *cookie, bool retire), 430 431 TP_ARGS(cookie, retire), 432 433 TP_STRUCT__entry( 434 __field(unsigned int, cookie ) 435 __field(unsigned int, volume ) 436 __field(int, ref ) 437 __field(int, n_active ) 438 __field(u8, flags ) 439 __field(bool, retire ) 440 ), 441 442 TP_fast_assign( 443 __entry->cookie = cookie->debug_id; 444 __entry->volume = cookie->volume->debug_id; 445 __entry->ref = refcount_read(&cookie->ref); 446 __entry->n_active = atomic_read(&cookie->n_active); 447 __entry->flags = cookie->flags; 448 __entry->retire = retire; 449 ), 450 451 TP_printk("c=%08x V=%08x r=%d U=%d f=%02x rt=%u", 452 __entry->cookie, __entry->volume, __entry->ref, 453 __entry->n_active, __entry->flags, __entry->retire) 454 ); 455 456 TRACE_EVENT(fscache_invalidate, 457 TP_PROTO(struct fscache_cookie *cookie, loff_t new_size), 458 459 TP_ARGS(cookie, new_size), 460 461 TP_STRUCT__entry( 462 __field(unsigned int, cookie ) 463 __field(loff_t, new_size ) 464 ), 465 466 TP_fast_assign( 467 __entry->cookie = cookie->debug_id; 468 __entry->new_size = new_size; 469 ), 470 471 TP_printk("c=%08x sz=%llx", 472 __entry->cookie, __entry->new_size) 473 ); 474 475 TRACE_EVENT(fscache_resize, 476 TP_PROTO(struct fscache_cookie *cookie, loff_t new_size), 477 478 TP_ARGS(cookie, new_size), 479 480 TP_STRUCT__entry( 481 __field(unsigned int, cookie ) 482 __field(loff_t, old_size ) 483 __field(loff_t, new_size ) 484 ), 485 486 TP_fast_assign( 487 __entry->cookie = cookie->debug_id; 488 __entry->old_size = cookie->object_size; 489 __entry->new_size = new_size; 490 ), 491 492 TP_printk("c=%08x os=%08llx sz=%08llx", 493 __entry->cookie, 494 __entry->old_size, 495 __entry->new_size) 496 ); 497 498 #endif /* _TRACE_FSCACHE_H */ 499 500 /* This part must be outside protection */ 501 #include <trace/define_trace.h> 502