Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

cachefiles: Add tracepoints for calls to the VFS

Add tracepoints in cachefiles to monitor when it does various VFS
operations, such as mkdir.

Signed-off-by: David Howells <dhowells@redhat.com>
Reviewed-by: Jeff Layton <jlayton@kernel.org>
cc: linux-cachefs@redhat.com
Link: https://lore.kernel.org/r/163819638517.215744.12773133137536579766.stgit@warthog.procyon.org.uk/ # v1
Link: https://lore.kernel.org/r/163906938316.143852.17227990869551737803.stgit@warthog.procyon.org.uk/ # v2
Link: https://lore.kernel.org/r/163967147139.1823006.4909879317496543392.stgit@warthog.procyon.org.uk/ # v3
Link: https://lore.kernel.org/r/164021546287.640689.3501604495002415631.stgit@warthog.procyon.org.uk/ # v4

+176
+176
include/trace/events/cachefiles.h
··· 18 18 #ifndef __CACHEFILES_DECLARE_TRACE_ENUMS_ONCE_ONLY 19 19 #define __CACHEFILES_DECLARE_TRACE_ENUMS_ONCE_ONLY 20 20 21 + enum fscache_why_object_killed { 22 + FSCACHE_OBJECT_IS_STALE, 23 + FSCACHE_OBJECT_IS_WEIRD, 24 + FSCACHE_OBJECT_INVALIDATED, 25 + FSCACHE_OBJECT_NO_SPACE, 26 + FSCACHE_OBJECT_WAS_RETIRED, 27 + FSCACHE_OBJECT_WAS_CULLED, 28 + }; 29 + 30 + enum cachefiles_trunc_trace { 31 + cachefiles_trunc_dio_adjust, 32 + cachefiles_trunc_expand_tmpfile, 33 + cachefiles_trunc_shrink, 34 + }; 35 + 21 36 enum cachefiles_error_trace { 22 37 cachefiles_trace_fallocate_error, 23 38 cachefiles_trace_getxattr_error, ··· 58 43 /* 59 44 * Define enum -> string mappings for display. 60 45 */ 46 + #define cachefiles_obj_kill_traces \ 47 + EM(FSCACHE_OBJECT_IS_STALE, "stale") \ 48 + EM(FSCACHE_OBJECT_IS_WEIRD, "weird") \ 49 + EM(FSCACHE_OBJECT_INVALIDATED, "inval") \ 50 + EM(FSCACHE_OBJECT_NO_SPACE, "no_space") \ 51 + EM(FSCACHE_OBJECT_WAS_RETIRED, "was_retired") \ 52 + E_(FSCACHE_OBJECT_WAS_CULLED, "was_culled") 53 + 54 + #define cachefiles_trunc_traces \ 55 + EM(cachefiles_trunc_dio_adjust, "DIOADJ") \ 56 + EM(cachefiles_trunc_expand_tmpfile, "EXPTMP") \ 57 + E_(cachefiles_trunc_shrink, "SHRINK") 58 + 61 59 #define cachefiles_error_traces \ 62 60 EM(cachefiles_trace_fallocate_error, "fallocate") \ 63 61 EM(cachefiles_trace_getxattr_error, "getxattr") \ ··· 99 71 #define EM(a, b) TRACE_DEFINE_ENUM(a); 100 72 #define E_(a, b) TRACE_DEFINE_ENUM(a); 101 73 74 + cachefiles_obj_kill_traces; 75 + cachefiles_trunc_traces; 102 76 cachefiles_error_traces; 103 77 104 78 /* ··· 112 82 #define EM(a, b) { a, b }, 113 83 #define E_(a, b) { a, b } 114 84 85 + 86 + TRACE_EVENT(cachefiles_lookup, 87 + TP_PROTO(struct cachefiles_object *obj, 88 + struct dentry *de), 89 + 90 + TP_ARGS(obj, de), 91 + 92 + TP_STRUCT__entry( 93 + __field(unsigned int, obj ) 94 + __field(short, error ) 95 + __field(unsigned long, ino ) 96 + ), 97 + 98 + TP_fast_assign( 99 + __entry->obj = obj->debug_id; 100 + __entry->ino = (!IS_ERR(de) && d_backing_inode(de) ? 101 + d_backing_inode(de)->i_ino : 0); 102 + __entry->error = IS_ERR(de) ? PTR_ERR(de) : 0; 103 + ), 104 + 105 + TP_printk("o=%08x i=%lx e=%d", 106 + __entry->obj, __entry->ino, __entry->error) 107 + ); 108 + 109 + TRACE_EVENT(cachefiles_tmpfile, 110 + TP_PROTO(struct cachefiles_object *obj, struct inode *backer), 111 + 112 + TP_ARGS(obj, backer), 113 + 114 + TP_STRUCT__entry( 115 + __field(unsigned int, obj ) 116 + __field(unsigned int, backer ) 117 + ), 118 + 119 + TP_fast_assign( 120 + __entry->obj = obj->debug_id; 121 + __entry->backer = backer->i_ino; 122 + ), 123 + 124 + TP_printk("o=%08x b=%08x", 125 + __entry->obj, 126 + __entry->backer) 127 + ); 128 + 129 + TRACE_EVENT(cachefiles_link, 130 + TP_PROTO(struct cachefiles_object *obj, struct inode *backer), 131 + 132 + TP_ARGS(obj, backer), 133 + 134 + TP_STRUCT__entry( 135 + __field(unsigned int, obj ) 136 + __field(unsigned int, backer ) 137 + ), 138 + 139 + TP_fast_assign( 140 + __entry->obj = obj->debug_id; 141 + __entry->backer = backer->i_ino; 142 + ), 143 + 144 + TP_printk("o=%08x b=%08x", 145 + __entry->obj, 146 + __entry->backer) 147 + ); 148 + 149 + TRACE_EVENT(cachefiles_unlink, 150 + TP_PROTO(struct cachefiles_object *obj, 151 + struct dentry *de, 152 + enum fscache_why_object_killed why), 153 + 154 + TP_ARGS(obj, de, why), 155 + 156 + /* Note that obj may be NULL */ 157 + TP_STRUCT__entry( 158 + __field(unsigned int, obj ) 159 + __field(struct dentry *, de ) 160 + __field(enum fscache_why_object_killed, why ) 161 + ), 162 + 163 + TP_fast_assign( 164 + __entry->obj = obj ? obj->debug_id : UINT_MAX; 165 + __entry->de = de; 166 + __entry->why = why; 167 + ), 168 + 169 + TP_printk("o=%08x d=%p w=%s", 170 + __entry->obj, __entry->de, 171 + __print_symbolic(__entry->why, cachefiles_obj_kill_traces)) 172 + ); 173 + 174 + TRACE_EVENT(cachefiles_rename, 175 + TP_PROTO(struct cachefiles_object *obj, 176 + struct dentry *de, 177 + struct dentry *to, 178 + enum fscache_why_object_killed why), 179 + 180 + TP_ARGS(obj, de, to, why), 181 + 182 + /* Note that obj may be NULL */ 183 + TP_STRUCT__entry( 184 + __field(unsigned int, obj ) 185 + __field(struct dentry *, de ) 186 + __field(struct dentry *, to ) 187 + __field(enum fscache_why_object_killed, why ) 188 + ), 189 + 190 + TP_fast_assign( 191 + __entry->obj = obj ? obj->debug_id : UINT_MAX; 192 + __entry->de = de; 193 + __entry->to = to; 194 + __entry->why = why; 195 + ), 196 + 197 + TP_printk("o=%08x d=%p t=%p w=%s", 198 + __entry->obj, __entry->de, __entry->to, 199 + __print_symbolic(__entry->why, cachefiles_obj_kill_traces)) 200 + ); 201 + 202 + TRACE_EVENT(cachefiles_trunc, 203 + TP_PROTO(struct cachefiles_object *obj, struct inode *backer, 204 + loff_t from, loff_t to, enum cachefiles_trunc_trace why), 205 + 206 + TP_ARGS(obj, backer, from, to, why), 207 + 208 + TP_STRUCT__entry( 209 + __field(unsigned int, obj ) 210 + __field(unsigned int, backer ) 211 + __field(enum cachefiles_trunc_trace, why ) 212 + __field(loff_t, from ) 213 + __field(loff_t, to ) 214 + ), 215 + 216 + TP_fast_assign( 217 + __entry->obj = obj->debug_id; 218 + __entry->backer = backer->i_ino; 219 + __entry->from = from; 220 + __entry->to = to; 221 + __entry->why = why; 222 + ), 223 + 224 + TP_printk("o=%08x b=%08x %s l=%llx->%llx", 225 + __entry->obj, 226 + __entry->backer, 227 + __print_symbolic(__entry->why, cachefiles_trunc_traces), 228 + __entry->from, 229 + __entry->to) 230 + ); 115 231 116 232 TRACE_EVENT(cachefiles_mark_active, 117 233 TP_PROTO(struct cachefiles_object *obj,