4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License (the "License").
6 * You may not use this file except in compliance with the License.
8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 * or http://www.opensolaris.org/os/licensing.
10 * See the License for the specific language governing permissions
11 * and limitations under the License.
13 * When distributing Covered Code, include this CDDL HEADER in each
14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 * If applicable, add the following below this CDDL HEADER, with the
16 * fields enclosed by brackets "[]" replaced with your own identifying
17 * information: Portions Copyright [yyyy] [name of copyright owner]
24 #if defined(_KERNEL) && defined(HAVE_DECLARE_EVENT_CLASS)
27 #define TRACE_SYSTEM zfs
29 #undef TRACE_SYSTEM_VAR
30 #define TRACE_SYSTEM_VAR zfs_arc
32 #if !defined(_TRACE_ARC_H) || defined(TRACE_HEADER_MULTI_READ)
35 #include <linux/tracepoint.h>
36 #include <sys/types.h>
37 #include <sys/trace_common.h> /* For ZIO macros */
40 * Generic support for one argument tracepoints of the form:
43 * arc_buf_hdr_t *, ...);
46 DECLARE_EVENT_CLASS(zfs_arc_buf_hdr_class
,
47 TP_PROTO(arc_buf_hdr_t
*ab
),
50 __array(uint64_t, hdr_dva_word
, 2)
51 __field(uint64_t, hdr_birth
)
52 __field(uint32_t, hdr_flags
)
53 __field(uint32_t, hdr_bufcnt
)
54 __field(arc_buf_contents_t
, hdr_type
)
55 __field(uint16_t, hdr_psize
)
56 __field(uint16_t, hdr_lsize
)
57 __field(uint64_t, hdr_spa
)
58 __field(arc_state_type_t
, hdr_state_type
)
59 __field(clock_t, hdr_access
)
60 __field(uint32_t, hdr_mru_hits
)
61 __field(uint32_t, hdr_mru_ghost_hits
)
62 __field(uint32_t, hdr_mfu_hits
)
63 __field(uint32_t, hdr_mfu_ghost_hits
)
64 __field(uint32_t, hdr_l2_hits
)
65 __field(int64_t, hdr_refcount
)
68 __entry
->hdr_dva_word
[0] = ab
->b_dva
.dva_word
[0];
69 __entry
->hdr_dva_word
[1] = ab
->b_dva
.dva_word
[1];
70 __entry
->hdr_birth
= ab
->b_birth
;
71 __entry
->hdr_flags
= ab
->b_flags
;
72 __entry
->hdr_bufcnt
= ab
->b_l1hdr
.b_bufcnt
;
73 __entry
->hdr_psize
= ab
->b_psize
;
74 __entry
->hdr_lsize
= ab
->b_lsize
;
75 __entry
->hdr_spa
= ab
->b_spa
;
76 __entry
->hdr_state_type
= ab
->b_l1hdr
.b_state
->arcs_state
;
77 __entry
->hdr_access
= ab
->b_l1hdr
.b_arc_access
;
78 __entry
->hdr_mru_hits
= ab
->b_l1hdr
.b_mru_hits
;
79 __entry
->hdr_mru_ghost_hits
= ab
->b_l1hdr
.b_mru_ghost_hits
;
80 __entry
->hdr_mfu_hits
= ab
->b_l1hdr
.b_mfu_hits
;
81 __entry
->hdr_mfu_ghost_hits
= ab
->b_l1hdr
.b_mfu_ghost_hits
;
82 __entry
->hdr_l2_hits
= ab
->b_l1hdr
.b_l2_hits
;
83 __entry
->hdr_refcount
= ab
->b_l1hdr
.b_refcnt
.rc_count
;
85 TP_printk("hdr { dva 0x%llx:0x%llx birth %llu "
86 "flags 0x%x bufcnt %u type %u psize %u lsize %u spa %llu "
87 "state_type %u access %lu mru_hits %u mru_ghost_hits %u "
88 "mfu_hits %u mfu_ghost_hits %u l2_hits %u refcount %lli }",
89 __entry
->hdr_dva_word
[0], __entry
->hdr_dva_word
[1],
90 __entry
->hdr_birth
, __entry
->hdr_flags
,
91 __entry
->hdr_bufcnt
, __entry
->hdr_type
, __entry
->hdr_psize
,
92 __entry
->hdr_lsize
, __entry
->hdr_spa
, __entry
->hdr_state_type
,
93 __entry
->hdr_access
, __entry
->hdr_mru_hits
,
94 __entry
->hdr_mru_ghost_hits
, __entry
->hdr_mfu_hits
,
95 __entry
->hdr_mfu_ghost_hits
, __entry
->hdr_l2_hits
,
96 __entry
->hdr_refcount
)
99 #define DEFINE_ARC_BUF_HDR_EVENT(name) \
100 DEFINE_EVENT(zfs_arc_buf_hdr_class, name, \
101 TP_PROTO(arc_buf_hdr_t *ab), \
103 DEFINE_ARC_BUF_HDR_EVENT(zfs_arc__hit
);
104 DEFINE_ARC_BUF_HDR_EVENT(zfs_arc__evict
);
105 DEFINE_ARC_BUF_HDR_EVENT(zfs_arc__delete
);
106 DEFINE_ARC_BUF_HDR_EVENT(zfs_new_state__mru
);
107 DEFINE_ARC_BUF_HDR_EVENT(zfs_new_state__mfu
);
108 DEFINE_ARC_BUF_HDR_EVENT(zfs_arc__sync__wait__for__async
);
109 DEFINE_ARC_BUF_HDR_EVENT(zfs_arc__demand__hit__predictive__prefetch
);
110 DEFINE_ARC_BUF_HDR_EVENT(zfs_l2arc__hit
);
111 DEFINE_ARC_BUF_HDR_EVENT(zfs_l2arc__miss
);
114 * Generic support for two argument tracepoints of the form:
121 DECLARE_EVENT_CLASS(zfs_l2arc_rw_class
,
122 TP_PROTO(vdev_t
*vd
, zio_t
*zio
),
125 __field(uint64_t, vdev_id
)
126 __field(uint64_t, vdev_guid
)
127 __field(uint64_t, vdev_state
)
131 __entry
->vdev_id
= vd
->vdev_id
;
132 __entry
->vdev_guid
= vd
->vdev_guid
;
133 __entry
->vdev_state
= vd
->vdev_state
;
136 TP_printk("vdev { id %llu guid %llu state %llu } "
137 ZIO_TP_PRINTK_FMT
, __entry
->vdev_id
, __entry
->vdev_guid
,
138 __entry
->vdev_state
, ZIO_TP_PRINTK_ARGS
)
141 #define DEFINE_L2ARC_RW_EVENT(name) \
142 DEFINE_EVENT(zfs_l2arc_rw_class, name, \
143 TP_PROTO(vdev_t *vd, zio_t *zio), \
145 DEFINE_L2ARC_RW_EVENT(zfs_l2arc__read
);
146 DEFINE_L2ARC_RW_EVENT(zfs_l2arc__write
);
150 * Generic support for two argument tracepoints of the form:
154 * l2arc_write_callback_t *, ...);
157 DECLARE_EVENT_CLASS(zfs_l2arc_iodone_class
,
158 TP_PROTO(zio_t
*zio
, l2arc_write_callback_t
*cb
),
160 TP_STRUCT__entry(ZIO_TP_STRUCT_ENTRY
),
161 TP_fast_assign(ZIO_TP_FAST_ASSIGN
),
162 TP_printk(ZIO_TP_PRINTK_FMT
, ZIO_TP_PRINTK_ARGS
)
165 #define DEFINE_L2ARC_IODONE_EVENT(name) \
166 DEFINE_EVENT(zfs_l2arc_iodone_class, name, \
167 TP_PROTO(zio_t *zio, l2arc_write_callback_t *cb), \
169 DEFINE_L2ARC_IODONE_EVENT(zfs_l2arc__iodone
);
173 * Generic support for four argument tracepoints of the form:
176 * arc_buf_hdr_t *, ...,
179 * const zbookmark_phys_t *);
182 DECLARE_EVENT_CLASS(zfs_arc_miss_class
,
183 TP_PROTO(arc_buf_hdr_t
*hdr
,
184 const blkptr_t
*bp
, uint64_t size
, const zbookmark_phys_t
*zb
),
185 TP_ARGS(hdr
, bp
, size
, zb
),
187 __array(uint64_t, hdr_dva_word
, 2)
188 __field(uint64_t, hdr_birth
)
189 __field(uint32_t, hdr_flags
)
190 __field(uint32_t, hdr_bufcnt
)
191 __field(arc_buf_contents_t
, hdr_type
)
192 __field(uint16_t, hdr_psize
)
193 __field(uint16_t, hdr_lsize
)
194 __field(uint64_t, hdr_spa
)
195 __field(arc_state_type_t
, hdr_state_type
)
196 __field(clock_t, hdr_access
)
197 __field(uint32_t, hdr_mru_hits
)
198 __field(uint32_t, hdr_mru_ghost_hits
)
199 __field(uint32_t, hdr_mfu_hits
)
200 __field(uint32_t, hdr_mfu_ghost_hits
)
201 __field(uint32_t, hdr_l2_hits
)
202 __field(int64_t, hdr_refcount
)
204 __array(uint64_t, bp_dva0
, 2)
205 __array(uint64_t, bp_dva1
, 2)
206 __array(uint64_t, bp_dva2
, 2)
207 __array(uint64_t, bp_cksum
, 4)
209 __field(uint64_t, bp_lsize
)
211 __field(uint64_t, zb_objset
)
212 __field(uint64_t, zb_object
)
213 __field(int64_t, zb_level
)
214 __field(uint64_t, zb_blkid
)
217 __entry
->hdr_dva_word
[0] = hdr
->b_dva
.dva_word
[0];
218 __entry
->hdr_dva_word
[1] = hdr
->b_dva
.dva_word
[1];
219 __entry
->hdr_birth
= hdr
->b_birth
;
220 __entry
->hdr_flags
= hdr
->b_flags
;
221 __entry
->hdr_bufcnt
= hdr
->b_l1hdr
.b_bufcnt
;
222 __entry
->hdr_psize
= hdr
->b_psize
;
223 __entry
->hdr_lsize
= hdr
->b_lsize
;
224 __entry
->hdr_spa
= hdr
->b_spa
;
225 __entry
->hdr_state_type
= hdr
->b_l1hdr
.b_state
->arcs_state
;
226 __entry
->hdr_access
= hdr
->b_l1hdr
.b_arc_access
;
227 __entry
->hdr_mru_hits
= hdr
->b_l1hdr
.b_mru_hits
;
228 __entry
->hdr_mru_ghost_hits
= hdr
->b_l1hdr
.b_mru_ghost_hits
;
229 __entry
->hdr_mfu_hits
= hdr
->b_l1hdr
.b_mfu_hits
;
230 __entry
->hdr_mfu_ghost_hits
= hdr
->b_l1hdr
.b_mfu_ghost_hits
;
231 __entry
->hdr_l2_hits
= hdr
->b_l1hdr
.b_l2_hits
;
232 __entry
->hdr_refcount
= hdr
->b_l1hdr
.b_refcnt
.rc_count
;
234 __entry
->bp_dva0
[0] = bp
->blk_dva
[0].dva_word
[0];
235 __entry
->bp_dva0
[1] = bp
->blk_dva
[0].dva_word
[1];
236 __entry
->bp_dva1
[0] = bp
->blk_dva
[1].dva_word
[0];
237 __entry
->bp_dva1
[1] = bp
->blk_dva
[1].dva_word
[1];
238 __entry
->bp_dva2
[0] = bp
->blk_dva
[2].dva_word
[0];
239 __entry
->bp_dva2
[1] = bp
->blk_dva
[2].dva_word
[1];
240 __entry
->bp_cksum
[0] = bp
->blk_cksum
.zc_word
[0];
241 __entry
->bp_cksum
[1] = bp
->blk_cksum
.zc_word
[1];
242 __entry
->bp_cksum
[2] = bp
->blk_cksum
.zc_word
[2];
243 __entry
->bp_cksum
[3] = bp
->blk_cksum
.zc_word
[3];
245 __entry
->bp_lsize
= size
;
247 __entry
->zb_objset
= zb
->zb_objset
;
248 __entry
->zb_object
= zb
->zb_object
;
249 __entry
->zb_level
= zb
->zb_level
;
250 __entry
->zb_blkid
= zb
->zb_blkid
;
252 TP_printk("hdr { dva 0x%llx:0x%llx birth %llu "
253 "flags 0x%x bufcnt %u psize %u lsize %u spa %llu state_type %u "
254 "access %lu mru_hits %u mru_ghost_hits %u mfu_hits %u "
255 "mfu_ghost_hits %u l2_hits %u refcount %lli } "
256 "bp { dva0 0x%llx:0x%llx dva1 0x%llx:0x%llx dva2 "
257 "0x%llx:0x%llx cksum 0x%llx:0x%llx:0x%llx:0x%llx "
258 "lsize %llu } zb { objset %llu object %llu level %lli "
260 __entry
->hdr_dva_word
[0], __entry
->hdr_dva_word
[1],
261 __entry
->hdr_birth
, __entry
->hdr_flags
,
262 __entry
->hdr_bufcnt
, __entry
->hdr_psize
, __entry
->hdr_lsize
,
263 __entry
->hdr_spa
, __entry
->hdr_state_type
, __entry
->hdr_access
,
264 __entry
->hdr_mru_hits
, __entry
->hdr_mru_ghost_hits
,
265 __entry
->hdr_mfu_hits
, __entry
->hdr_mfu_ghost_hits
,
266 __entry
->hdr_l2_hits
, __entry
->hdr_refcount
,
267 __entry
->bp_dva0
[0], __entry
->bp_dva0
[1],
268 __entry
->bp_dva1
[0], __entry
->bp_dva1
[1],
269 __entry
->bp_dva2
[0], __entry
->bp_dva2
[1],
270 __entry
->bp_cksum
[0], __entry
->bp_cksum
[1],
271 __entry
->bp_cksum
[2], __entry
->bp_cksum
[3],
272 __entry
->bp_lsize
, __entry
->zb_objset
, __entry
->zb_object
,
273 __entry
->zb_level
, __entry
->zb_blkid
)
276 #define DEFINE_ARC_MISS_EVENT(name) \
277 DEFINE_EVENT(zfs_arc_miss_class, name, \
278 TP_PROTO(arc_buf_hdr_t *hdr, \
279 const blkptr_t *bp, uint64_t size, const zbookmark_phys_t *zb), \
280 TP_ARGS(hdr, bp, size, zb))
281 DEFINE_ARC_MISS_EVENT(zfs_arc__miss
);
284 * Generic support for four argument tracepoints of the form:
287 * l2arc_dev_t *, ...,
293 DECLARE_EVENT_CLASS(zfs_l2arc_evict_class
,
294 TP_PROTO(l2arc_dev_t
*dev
,
295 list_t
*buflist
, uint64_t taddr
, boolean_t all
),
296 TP_ARGS(dev
, buflist
, taddr
, all
),
298 __field(uint64_t, vdev_id
)
299 __field(uint64_t, vdev_guid
)
300 __field(uint64_t, vdev_state
)
302 __field(uint64_t, l2ad_hand
)
303 __field(uint64_t, l2ad_start
)
304 __field(uint64_t, l2ad_end
)
305 __field(boolean_t
, l2ad_first
)
306 __field(boolean_t
, l2ad_writing
)
308 __field(uint64_t, taddr
)
309 __field(boolean_t
, all
)
312 __entry
->vdev_id
= dev
->l2ad_vdev
->vdev_id
;
313 __entry
->vdev_guid
= dev
->l2ad_vdev
->vdev_guid
;
314 __entry
->vdev_state
= dev
->l2ad_vdev
->vdev_state
;
316 __entry
->l2ad_hand
= dev
->l2ad_hand
;
317 __entry
->l2ad_start
= dev
->l2ad_start
;
318 __entry
->l2ad_end
= dev
->l2ad_end
;
319 __entry
->l2ad_first
= dev
->l2ad_first
;
320 __entry
->l2ad_writing
= dev
->l2ad_writing
;
322 __entry
->taddr
= taddr
;
325 TP_printk("l2ad { vdev { id %llu guid %llu state %llu } "
326 "hand %llu start %llu end %llu "
327 "first %d writing %d } taddr %llu all %d",
328 __entry
->vdev_id
, __entry
->vdev_guid
, __entry
->vdev_state
,
329 __entry
->l2ad_hand
, __entry
->l2ad_start
,
330 __entry
->l2ad_end
, __entry
->l2ad_first
, __entry
->l2ad_writing
,
331 __entry
->taddr
, __entry
->all
)
334 #define DEFINE_L2ARC_EVICT_EVENT(name) \
335 DEFINE_EVENT(zfs_l2arc_evict_class, name, \
336 TP_PROTO(l2arc_dev_t *dev, \
337 list_t *buflist, uint64_t taddr, boolean_t all), \
338 TP_ARGS(dev, buflist, taddr, all))
339 DEFINE_L2ARC_EVICT_EVENT(zfs_l2arc__evict
);
341 #endif /* _TRACE_ARC_H */
343 #undef TRACE_INCLUDE_PATH
344 #undef TRACE_INCLUDE_FILE
345 #define TRACE_INCLUDE_PATH sys
346 #define TRACE_INCLUDE_FILE trace_arc
347 #include <trace/define_trace.h>
349 #endif /* _KERNEL && HAVE_DECLARE_EVENT_CLASS */