David Howells | a18feb5 | 2018-04-04 13:41:27 +0100 | [diff] [blame^] | 1 | /* FS-Cache tracepoints |
| 2 | * |
| 3 | * Copyright (C) 2016 Red Hat, Inc. All Rights Reserved. |
| 4 | * Written by David Howells (dhowells@redhat.com) |
| 5 | * |
| 6 | * This program is free software; you can redistribute it and/or |
| 7 | * modify it under the terms of the GNU General Public Licence |
| 8 | * as published by the Free Software Foundation; either version |
| 9 | * 2 of the Licence, or (at your option) any later version. |
| 10 | */ |
| 11 | #undef TRACE_SYSTEM |
| 12 | #define TRACE_SYSTEM fscache |
| 13 | |
| 14 | #if !defined(_TRACE_FSCACHE_H) || defined(TRACE_HEADER_MULTI_READ) |
| 15 | #define _TRACE_FSCACHE_H |
| 16 | |
| 17 | #include <linux/fscache.h> |
| 18 | #include <linux/tracepoint.h> |
| 19 | |
| 20 | /* |
| 21 | * Define enums for tracing information. |
| 22 | */ |
| 23 | #ifndef __FSCACHE_DECLARE_TRACE_ENUMS_ONCE_ONLY |
| 24 | #define __FSCACHE_DECLARE_TRACE_ENUMS_ONCE_ONLY |
| 25 | |
| 26 | enum fscache_cookie_trace { |
| 27 | fscache_cookie_get_acquire_parent, |
| 28 | fscache_cookie_get_attach_object, |
| 29 | fscache_cookie_get_register_netfs, |
| 30 | fscache_cookie_put_acquire_nobufs, |
| 31 | fscache_cookie_put_relinquish, |
| 32 | fscache_cookie_put_object, |
| 33 | fscache_cookie_put_parent, |
| 34 | }; |
| 35 | |
| 36 | #endif |
| 37 | |
| 38 | /* |
| 39 | * Declare tracing information enums and their string mappings for display. |
| 40 | */ |
| 41 | #define fscache_cookie_traces \ |
| 42 | EM(fscache_cookie_get_acquire_parent, "GET prn") \ |
| 43 | EM(fscache_cookie_get_attach_object, "GET obj") \ |
| 44 | EM(fscache_cookie_get_register_netfs, "GET net") \ |
| 45 | EM(fscache_cookie_put_acquire_nobufs, "PUT nbf") \ |
| 46 | EM(fscache_cookie_put_relinquish, "PUT rlq") \ |
| 47 | EM(fscache_cookie_put_object, "PUT obj") \ |
| 48 | E_(fscache_cookie_put_parent, "PUT prn") |
| 49 | |
| 50 | /* |
| 51 | * Export enum symbols via userspace. |
| 52 | */ |
| 53 | #undef EM |
| 54 | #undef E_ |
| 55 | #define EM(a, b) TRACE_DEFINE_ENUM(a); |
| 56 | #define E_(a, b) TRACE_DEFINE_ENUM(a); |
| 57 | |
| 58 | fscache_cookie_traces; |
| 59 | |
| 60 | /* |
| 61 | * Now redefine the EM() and E_() macros to map the enums to the strings that |
| 62 | * will be printed in the output. |
| 63 | */ |
| 64 | #undef EM |
| 65 | #undef E_ |
| 66 | #define EM(a, b) { a, b }, |
| 67 | #define E_(a, b) { a, b } |
| 68 | |
| 69 | |
| 70 | TRACE_EVENT(fscache_cookie, |
| 71 | TP_PROTO(struct fscache_cookie *cookie, |
| 72 | enum fscache_cookie_trace where, |
| 73 | int usage), |
| 74 | |
| 75 | TP_ARGS(cookie, where, usage), |
| 76 | |
| 77 | TP_STRUCT__entry( |
| 78 | __field(struct fscache_cookie *, cookie ) |
| 79 | __field(struct fscache_cookie *, parent ) |
| 80 | __field(enum fscache_cookie_trace, where ) |
| 81 | __field(int, usage ) |
| 82 | __field(int, n_children ) |
| 83 | __field(int, n_active ) |
| 84 | __field(u8, flags ) |
| 85 | ), |
| 86 | |
| 87 | TP_fast_assign( |
| 88 | __entry->cookie = cookie; |
| 89 | __entry->parent = cookie->parent; |
| 90 | __entry->where = where; |
| 91 | __entry->usage = usage; |
| 92 | __entry->n_children = atomic_read(&cookie->n_children); |
| 93 | __entry->n_active = atomic_read(&cookie->n_active); |
| 94 | __entry->flags = cookie->flags; |
| 95 | ), |
| 96 | |
| 97 | TP_printk("%s c=%p u=%d p=%p Nc=%d Na=%d f=%02x", |
| 98 | __print_symbolic(__entry->where, fscache_cookie_traces), |
| 99 | __entry->cookie, __entry->usage, |
| 100 | __entry->parent, __entry->n_children, __entry->n_active, |
| 101 | __entry->flags) |
| 102 | ); |
| 103 | |
| 104 | TRACE_EVENT(fscache_netfs, |
| 105 | TP_PROTO(struct fscache_netfs *netfs), |
| 106 | |
| 107 | TP_ARGS(netfs), |
| 108 | |
| 109 | TP_STRUCT__entry( |
| 110 | __field(struct fscache_cookie *, cookie ) |
| 111 | __array(char, name, 8 ) |
| 112 | ), |
| 113 | |
| 114 | TP_fast_assign( |
| 115 | __entry->cookie = netfs->primary_index; |
| 116 | strncpy(__entry->name, netfs->name, 8); |
| 117 | __entry->name[7] = 0; |
| 118 | ), |
| 119 | |
| 120 | TP_printk("c=%p n=%s", |
| 121 | __entry->cookie, __entry->name) |
| 122 | ); |
| 123 | |
| 124 | TRACE_EVENT(fscache_acquire, |
| 125 | TP_PROTO(struct fscache_cookie *cookie), |
| 126 | |
| 127 | TP_ARGS(cookie), |
| 128 | |
| 129 | TP_STRUCT__entry( |
| 130 | __field(struct fscache_cookie *, cookie ) |
| 131 | __field(struct fscache_cookie *, parent ) |
| 132 | __array(char, name, 8 ) |
| 133 | __field(int, p_usage ) |
| 134 | __field(int, p_n_children ) |
| 135 | __field(u8, p_flags ) |
| 136 | ), |
| 137 | |
| 138 | TP_fast_assign( |
| 139 | __entry->cookie = cookie; |
| 140 | __entry->parent = cookie->parent; |
| 141 | __entry->p_usage = atomic_read(&cookie->parent->usage); |
| 142 | __entry->p_n_children = atomic_read(&cookie->parent->n_children); |
| 143 | __entry->p_flags = cookie->parent->flags; |
| 144 | memcpy(__entry->name, cookie->def->name, 8); |
| 145 | __entry->name[7] = 0; |
| 146 | ), |
| 147 | |
| 148 | TP_printk("c=%p p=%p pu=%d pc=%d pf=%02x n=%s", |
| 149 | __entry->cookie, __entry->parent, __entry->p_usage, |
| 150 | __entry->p_n_children, __entry->p_flags, __entry->name) |
| 151 | ); |
| 152 | |
| 153 | TRACE_EVENT(fscache_relinquish, |
| 154 | TP_PROTO(struct fscache_cookie *cookie, bool retire), |
| 155 | |
| 156 | TP_ARGS(cookie, retire), |
| 157 | |
| 158 | TP_STRUCT__entry( |
| 159 | __field(struct fscache_cookie *, cookie ) |
| 160 | __field(struct fscache_cookie *, parent ) |
| 161 | __field(int, usage ) |
| 162 | __field(int, n_children ) |
| 163 | __field(int, n_active ) |
| 164 | __field(u8, flags ) |
| 165 | __field(bool, retire ) |
| 166 | ), |
| 167 | |
| 168 | TP_fast_assign( |
| 169 | __entry->cookie = cookie; |
| 170 | __entry->parent = cookie->parent; |
| 171 | __entry->usage = atomic_read(&cookie->usage); |
| 172 | __entry->n_children = atomic_read(&cookie->n_children); |
| 173 | __entry->n_active = atomic_read(&cookie->n_active); |
| 174 | __entry->flags = cookie->flags; |
| 175 | __entry->retire = retire; |
| 176 | ), |
| 177 | |
| 178 | TP_printk("c=%p u=%d p=%p Nc=%d Na=%d f=%02x r=%u", |
| 179 | __entry->cookie, __entry->usage, |
| 180 | __entry->parent, __entry->n_children, __entry->n_active, |
| 181 | __entry->flags, __entry->retire) |
| 182 | ); |
| 183 | |
| 184 | TRACE_EVENT(fscache_enable, |
| 185 | TP_PROTO(struct fscache_cookie *cookie), |
| 186 | |
| 187 | TP_ARGS(cookie), |
| 188 | |
| 189 | TP_STRUCT__entry( |
| 190 | __field(struct fscache_cookie *, cookie ) |
| 191 | __field(int, usage ) |
| 192 | __field(int, n_children ) |
| 193 | __field(int, n_active ) |
| 194 | __field(u8, flags ) |
| 195 | ), |
| 196 | |
| 197 | TP_fast_assign( |
| 198 | __entry->cookie = cookie; |
| 199 | __entry->usage = atomic_read(&cookie->usage); |
| 200 | __entry->n_children = atomic_read(&cookie->n_children); |
| 201 | __entry->n_active = atomic_read(&cookie->n_active); |
| 202 | __entry->flags = cookie->flags; |
| 203 | ), |
| 204 | |
| 205 | TP_printk("c=%p u=%d Nc=%d Na=%d f=%02x", |
| 206 | __entry->cookie, __entry->usage, |
| 207 | __entry->n_children, __entry->n_active, __entry->flags) |
| 208 | ); |
| 209 | |
| 210 | TRACE_EVENT(fscache_disable, |
| 211 | TP_PROTO(struct fscache_cookie *cookie), |
| 212 | |
| 213 | TP_ARGS(cookie), |
| 214 | |
| 215 | TP_STRUCT__entry( |
| 216 | __field(struct fscache_cookie *, cookie ) |
| 217 | __field(int, usage ) |
| 218 | __field(int, n_children ) |
| 219 | __field(int, n_active ) |
| 220 | __field(u8, flags ) |
| 221 | ), |
| 222 | |
| 223 | TP_fast_assign( |
| 224 | __entry->cookie = cookie; |
| 225 | __entry->usage = atomic_read(&cookie->usage); |
| 226 | __entry->n_children = atomic_read(&cookie->n_children); |
| 227 | __entry->n_active = atomic_read(&cookie->n_active); |
| 228 | __entry->flags = cookie->flags; |
| 229 | ), |
| 230 | |
| 231 | TP_printk("c=%p u=%d Nc=%d Na=%d f=%02x", |
| 232 | __entry->cookie, __entry->usage, |
| 233 | __entry->n_children, __entry->n_active, __entry->flags) |
| 234 | ); |
| 235 | |
| 236 | TRACE_EVENT(fscache_osm, |
| 237 | TP_PROTO(struct fscache_object *object, |
| 238 | const struct fscache_state *state, |
| 239 | bool wait, bool oob, s8 event_num), |
| 240 | |
| 241 | TP_ARGS(object, state, wait, oob, event_num), |
| 242 | |
| 243 | TP_STRUCT__entry( |
| 244 | __field(struct fscache_cookie *, cookie ) |
| 245 | __field(struct fscache_object *, object ) |
| 246 | __array(char, state, 8 ) |
| 247 | __field(bool, wait ) |
| 248 | __field(bool, oob ) |
| 249 | __field(s8, event_num ) |
| 250 | ), |
| 251 | |
| 252 | TP_fast_assign( |
| 253 | __entry->cookie = object->cookie; |
| 254 | __entry->object = object; |
| 255 | __entry->wait = wait; |
| 256 | __entry->oob = oob; |
| 257 | __entry->event_num = event_num; |
| 258 | memcpy(__entry->state, state->short_name, 8); |
| 259 | ), |
| 260 | |
| 261 | TP_printk("c=%p o=%p %s %s%sev=%d", |
| 262 | __entry->cookie, |
| 263 | __entry->object, |
| 264 | __entry->state, |
| 265 | __print_symbolic(__entry->wait, |
| 266 | { true, "WAIT" }, |
| 267 | { false, "WORK" }), |
| 268 | __print_symbolic(__entry->oob, |
| 269 | { true, " OOB " }, |
| 270 | { false, " " }), |
| 271 | __entry->event_num) |
| 272 | ); |
| 273 | |
| 274 | #endif /* _TRACE_FSCACHE_H */ |
| 275 | |
| 276 | /* This part must be outside protection */ |
| 277 | #include <trace/define_trace.h> |