1 /* SPDX-License-Identifier: GPL-2.0-or-later */ 2 /* Network filesystem support module 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 netfs 9 10 #if !defined(_TRACE_NETFS_H) || defined(TRACE_HEADER_MULTI_READ) 11 #define _TRACE_NETFS_H 12 13 #include <linux/tracepoint.h> 14 15 /* 16 * Define enums for tracing information. 17 */ 18 #ifndef __NETFS_DECLARE_TRACE_ENUMS_ONCE_ONLY 19 #define __NETFS_DECLARE_TRACE_ENUMS_ONCE_ONLY 20 21 enum netfs_read_trace { 22 netfs_read_trace_expanded, 23 netfs_read_trace_readahead, 24 netfs_read_trace_readpage, 25 netfs_read_trace_write_begin, 26 }; 27 28 enum netfs_rreq_trace { 29 netfs_rreq_trace_assess, 30 netfs_rreq_trace_done, 31 netfs_rreq_trace_free, 32 netfs_rreq_trace_resubmit, 33 netfs_rreq_trace_unlock, 34 netfs_rreq_trace_unmark, 35 netfs_rreq_trace_write, 36 }; 37 38 enum netfs_sreq_trace { 39 netfs_sreq_trace_download_instead, 40 netfs_sreq_trace_free, 41 netfs_sreq_trace_prepare, 42 netfs_sreq_trace_resubmit_short, 43 netfs_sreq_trace_submit, 44 netfs_sreq_trace_terminated, 45 netfs_sreq_trace_write, 46 netfs_sreq_trace_write_skip, 47 netfs_sreq_trace_write_term, 48 }; 49 50 enum netfs_failure { 51 netfs_fail_check_write_begin, 52 netfs_fail_copy_to_cache, 53 netfs_fail_read, 54 netfs_fail_short_readpage, 55 netfs_fail_short_write_begin, 56 netfs_fail_prepare_write, 57 }; 58 59 #endif 60 61 #define netfs_read_traces \ 62 EM(netfs_read_trace_expanded, "EXPANDED ") \ 63 EM(netfs_read_trace_readahead, "READAHEAD") \ 64 EM(netfs_read_trace_readpage, "READPAGE ") \ 65 E_(netfs_read_trace_write_begin, "WRITEBEGN") 66 67 #define netfs_rreq_traces \ 68 EM(netfs_rreq_trace_assess, "ASSESS") \ 69 EM(netfs_rreq_trace_done, "DONE ") \ 70 EM(netfs_rreq_trace_free, "FREE ") \ 71 EM(netfs_rreq_trace_resubmit, "RESUBM") \ 72 EM(netfs_rreq_trace_unlock, "UNLOCK") \ 73 EM(netfs_rreq_trace_unmark, "UNMARK") \ 74 E_(netfs_rreq_trace_write, "WRITE ") 75 76 #define netfs_sreq_sources \ 77 EM(NETFS_FILL_WITH_ZEROES, "ZERO") \ 78 EM(NETFS_DOWNLOAD_FROM_SERVER, "DOWN") \ 79 EM(NETFS_READ_FROM_CACHE, "READ") \ 80 E_(NETFS_INVALID_READ, "INVL") \ 81 82 #define netfs_sreq_traces \ 83 EM(netfs_sreq_trace_download_instead, "RDOWN") \ 84 EM(netfs_sreq_trace_free, "FREE ") \ 85 EM(netfs_sreq_trace_prepare, "PREP ") \ 86 EM(netfs_sreq_trace_resubmit_short, "SHORT") \ 87 EM(netfs_sreq_trace_submit, "SUBMT") \ 88 EM(netfs_sreq_trace_terminated, "TERM ") \ 89 EM(netfs_sreq_trace_write, "WRITE") \ 90 EM(netfs_sreq_trace_write_skip, "SKIP ") \ 91 E_(netfs_sreq_trace_write_term, "WTERM") 92 93 #define netfs_failures \ 94 EM(netfs_fail_check_write_begin, "check-write-begin") \ 95 EM(netfs_fail_copy_to_cache, "copy-to-cache") \ 96 EM(netfs_fail_read, "read") \ 97 EM(netfs_fail_short_readpage, "short-readpage") \ 98 EM(netfs_fail_short_write_begin, "short-write-begin") \ 99 E_(netfs_fail_prepare_write, "prep-write") 100 101 102 /* 103 * Export enum symbols via userspace. 104 */ 105 #undef EM 106 #undef E_ 107 #define EM(a, b) TRACE_DEFINE_ENUM(a); 108 #define E_(a, b) TRACE_DEFINE_ENUM(a); 109 110 netfs_read_traces; 111 netfs_rreq_traces; 112 netfs_sreq_sources; 113 netfs_sreq_traces; 114 netfs_failures; 115 116 /* 117 * Now redefine the EM() and E_() macros to map the enums to the strings that 118 * will be printed in the output. 119 */ 120 #undef EM 121 #undef E_ 122 #define EM(a, b) { a, b }, 123 #define E_(a, b) { a, b } 124 125 TRACE_EVENT(netfs_read, 126 TP_PROTO(struct netfs_read_request *rreq, 127 loff_t start, size_t len, 128 enum netfs_read_trace what), 129 130 TP_ARGS(rreq, start, len, what), 131 132 TP_STRUCT__entry( 133 __field(unsigned int, rreq ) 134 __field(unsigned int, cookie ) 135 __field(loff_t, start ) 136 __field(size_t, len ) 137 __field(enum netfs_read_trace, what ) 138 ), 139 140 TP_fast_assign( 141 __entry->rreq = rreq->debug_id; 142 __entry->cookie = rreq->cookie_debug_id; 143 __entry->start = start; 144 __entry->len = len; 145 __entry->what = what; 146 ), 147 148 TP_printk("R=%08x %s c=%08x s=%llx %zx", 149 __entry->rreq, 150 __print_symbolic(__entry->what, netfs_read_traces), 151 __entry->cookie, 152 __entry->start, __entry->len) 153 ); 154 155 TRACE_EVENT(netfs_rreq, 156 TP_PROTO(struct netfs_read_request *rreq, 157 enum netfs_rreq_trace what), 158 159 TP_ARGS(rreq, what), 160 161 TP_STRUCT__entry( 162 __field(unsigned int, rreq ) 163 __field(unsigned short, flags ) 164 __field(enum netfs_rreq_trace, what ) 165 ), 166 167 TP_fast_assign( 168 __entry->rreq = rreq->debug_id; 169 __entry->flags = rreq->flags; 170 __entry->what = what; 171 ), 172 173 TP_printk("R=%08x %s f=%02x", 174 __entry->rreq, 175 __print_symbolic(__entry->what, netfs_rreq_traces), 176 __entry->flags) 177 ); 178 179 TRACE_EVENT(netfs_sreq, 180 TP_PROTO(struct netfs_read_subrequest *sreq, 181 enum netfs_sreq_trace what), 182 183 TP_ARGS(sreq, what), 184 185 TP_STRUCT__entry( 186 __field(unsigned int, rreq ) 187 __field(unsigned short, index ) 188 __field(short, error ) 189 __field(unsigned short, flags ) 190 __field(enum netfs_read_source, source ) 191 __field(enum netfs_sreq_trace, what ) 192 __field(size_t, len ) 193 __field(size_t, transferred ) 194 __field(loff_t, start ) 195 ), 196 197 TP_fast_assign( 198 __entry->rreq = sreq->rreq->debug_id; 199 __entry->index = sreq->debug_index; 200 __entry->error = sreq->error; 201 __entry->flags = sreq->flags; 202 __entry->source = sreq->source; 203 __entry->what = what; 204 __entry->len = sreq->len; 205 __entry->transferred = sreq->transferred; 206 __entry->start = sreq->start; 207 ), 208 209 TP_printk("R=%08x[%u] %s %s f=%02x s=%llx %zx/%zx e=%d", 210 __entry->rreq, __entry->index, 211 __print_symbolic(__entry->what, netfs_sreq_traces), 212 __print_symbolic(__entry->source, netfs_sreq_sources), 213 __entry->flags, 214 __entry->start, __entry->transferred, __entry->len, 215 __entry->error) 216 ); 217 218 TRACE_EVENT(netfs_failure, 219 TP_PROTO(struct netfs_read_request *rreq, 220 struct netfs_read_subrequest *sreq, 221 int error, enum netfs_failure what), 222 223 TP_ARGS(rreq, sreq, error, what), 224 225 TP_STRUCT__entry( 226 __field(unsigned int, rreq ) 227 __field(unsigned short, index ) 228 __field(short, error ) 229 __field(unsigned short, flags ) 230 __field(enum netfs_read_source, source ) 231 __field(enum netfs_failure, what ) 232 __field(size_t, len ) 233 __field(size_t, transferred ) 234 __field(loff_t, start ) 235 ), 236 237 TP_fast_assign( 238 __entry->rreq = rreq->debug_id; 239 __entry->index = sreq ? sreq->debug_index : 0; 240 __entry->error = error; 241 __entry->flags = sreq ? sreq->flags : 0; 242 __entry->source = sreq ? sreq->source : NETFS_INVALID_READ; 243 __entry->what = what; 244 __entry->len = sreq ? sreq->len : 0; 245 __entry->transferred = sreq ? sreq->transferred : 0; 246 __entry->start = sreq ? sreq->start : 0; 247 ), 248 249 TP_printk("R=%08x[%u] %s f=%02x s=%llx %zx/%zx %s e=%d", 250 __entry->rreq, __entry->index, 251 __print_symbolic(__entry->source, netfs_sreq_sources), 252 __entry->flags, 253 __entry->start, __entry->transferred, __entry->len, 254 __print_symbolic(__entry->what, netfs_failures), 255 __entry->error) 256 ); 257 258 #endif /* _TRACE_NETFS_H */ 259 260 /* This part must be outside protection */ 261 #include <trace/define_trace.h> 262