1 /* FS-Cache tracepoints
3 * Copyright (C) 2016 Red Hat, Inc. All Rights Reserved.
4 * Written by David Howells (dhowells@redhat.com)
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.
12 #define TRACE_SYSTEM fscache
14 #if !defined(_TRACE_FSCACHE_H) || defined(TRACE_HEADER_MULTI_READ)
15 #define _TRACE_FSCACHE_H
17 #include <linux/fscache.h>
18 #include <linux/tracepoint.h>
21 * Define enums for tracing information.
23 #ifndef __FSCACHE_DECLARE_TRACE_ENUMS_ONCE_ONLY
24 #define __FSCACHE_DECLARE_TRACE_ENUMS_ONCE_ONLY
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,
39 * Declare tracing information enums and their string mappings for display.
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")
51 * Export enum symbols via userspace.
55 #define EM(a, b) TRACE_DEFINE_ENUM(a);
56 #define E_(a, b) TRACE_DEFINE_ENUM(a);
58 fscache_cookie_traces;
61 * Now redefine the EM() and E_() macros to map the enums to the strings that
62 * will be printed in the output.
66 #define EM(a, b) { a, b },
67 #define E_(a, b) { a, b }
70 TRACE_EVENT(fscache_cookie,
71 TP_PROTO(struct fscache_cookie *cookie,
72 enum fscache_cookie_trace where,
75 TP_ARGS(cookie, where, usage),
78 __field(struct fscache_cookie *, cookie )
79 __field(struct fscache_cookie *, parent )
80 __field(enum fscache_cookie_trace, where )
82 __field(int, n_children )
83 __field(int, n_active )
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;
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,
104 TRACE_EVENT(fscache_netfs,
105 TP_PROTO(struct fscache_netfs *netfs),
110 __field(struct fscache_cookie *, cookie )
111 __array(char, name, 8 )
115 __entry->cookie = netfs->primary_index;
116 strncpy(__entry->name, netfs->name, 8);
117 __entry->name[7] = 0;
120 TP_printk("c=%p n=%s",
121 __entry->cookie, __entry->name)
124 TRACE_EVENT(fscache_acquire,
125 TP_PROTO(struct fscache_cookie *cookie),
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 )
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;
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)
153 TRACE_EVENT(fscache_relinquish,
154 TP_PROTO(struct fscache_cookie *cookie, bool retire),
156 TP_ARGS(cookie, retire),
159 __field(struct fscache_cookie *, cookie )
160 __field(struct fscache_cookie *, parent )
162 __field(int, n_children )
163 __field(int, n_active )
165 __field(bool, retire )
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;
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)
184 TRACE_EVENT(fscache_enable,
185 TP_PROTO(struct fscache_cookie *cookie),
190 __field(struct fscache_cookie *, cookie )
192 __field(int, n_children )
193 __field(int, n_active )
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;
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)
210 TRACE_EVENT(fscache_disable,
211 TP_PROTO(struct fscache_cookie *cookie),
216 __field(struct fscache_cookie *, cookie )
218 __field(int, n_children )
219 __field(int, n_active )
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;
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)
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),
241 TP_ARGS(object, state, wait, oob, event_num),
244 __field(struct fscache_cookie *, cookie )
245 __field(struct fscache_object *, object )
246 __array(char, state, 8 )
249 __field(s8, event_num )
253 __entry->cookie = object->cookie;
254 __entry->object = object;
255 __entry->wait = wait;
257 __entry->event_num = event_num;
258 memcpy(__entry->state, state->short_name, 8);
261 TP_printk("c=%p o=%p %s %s%sev=%d",
265 __print_symbolic(__entry->wait,
268 __print_symbolic(__entry->oob,
274 #endif /* _TRACE_FSCACHE_H */
276 /* This part must be outside protection */
277 #include <trace/define_trace.h>