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]
25 #if defined(HAVE_DECLARE_EVENT_CLASS)
28 #define TRACE_SYSTEM zfs
30 #undef TRACE_SYSTEM_VAR
31 #define TRACE_SYSTEM_VAR zfs_arc
33 #if !defined(_TRACE_ARC_H) || defined(TRACE_HEADER_MULTI_READ)
36 #include <linux/tracepoint.h>
37 #include <sys/types.h>
38 #include <sys/trace_common.h> /* For ZIO macros */
41 * Generic support for one argument tracepoints of the form:
44 * arc_buf_hdr_t *, ...);
47 DECLARE_EVENT_CLASS(zfs_arc_buf_hdr_class
,
48 TP_PROTO(arc_buf_hdr_t
*ab
),
51 __array(uint64_t, hdr_dva_word
, 2)
52 __field(uint64_t, hdr_birth
)
53 __field(uint32_t, hdr_flags
)
54 __field(uint32_t, hdr_bufcnt
)
55 __field(arc_buf_contents_t
, hdr_type
)
56 __field(uint16_t, hdr_psize
)
57 __field(uint16_t, hdr_lsize
)
58 __field(uint64_t, hdr_spa
)
59 __field(arc_state_type_t
, hdr_state_type
)
60 __field(clock_t, hdr_access
)
61 __field(uint32_t, hdr_mru_hits
)
62 __field(uint32_t, hdr_mru_ghost_hits
)
63 __field(uint32_t, hdr_mfu_hits
)
64 __field(uint32_t, hdr_mfu_ghost_hits
)
65 __field(uint32_t, hdr_l2_hits
)
66 __field(int64_t, hdr_refcount
)
69 __entry
->hdr_dva_word
[0] = ab
->b_dva
.dva_word
[0];
70 __entry
->hdr_dva_word
[1] = ab
->b_dva
.dva_word
[1];
71 __entry
->hdr_birth
= ab
->b_birth
;
72 __entry
->hdr_flags
= ab
->b_flags
;
73 __entry
->hdr_bufcnt
= ab
->b_l1hdr
.b_bufcnt
;
74 __entry
->hdr_psize
= ab
->b_psize
;
75 __entry
->hdr_lsize
= ab
->b_lsize
;
76 __entry
->hdr_spa
= ab
->b_spa
;
77 __entry
->hdr_state_type
= ab
->b_l1hdr
.b_state
->arcs_state
;
78 __entry
->hdr_access
= ab
->b_l1hdr
.b_arc_access
;
79 __entry
->hdr_mru_hits
= ab
->b_l1hdr
.b_mru_hits
;
80 __entry
->hdr_mru_ghost_hits
= ab
->b_l1hdr
.b_mru_ghost_hits
;
81 __entry
->hdr_mfu_hits
= ab
->b_l1hdr
.b_mfu_hits
;
82 __entry
->hdr_mfu_ghost_hits
= ab
->b_l1hdr
.b_mfu_ghost_hits
;
83 __entry
->hdr_l2_hits
= ab
->b_l1hdr
.b_l2_hits
;
84 __entry
->hdr_refcount
= ab
->b_l1hdr
.b_refcnt
.rc_count
;
86 TP_printk("hdr { dva 0x%llx:0x%llx birth %llu "
87 "flags 0x%x bufcnt %u type %u psize %u lsize %u spa %llu "
88 "state_type %u access %lu mru_hits %u mru_ghost_hits %u "
89 "mfu_hits %u mfu_ghost_hits %u l2_hits %u refcount %lli }",
90 __entry
->hdr_dva_word
[0], __entry
->hdr_dva_word
[1],
91 __entry
->hdr_birth
, __entry
->hdr_flags
,
92 __entry
->hdr_bufcnt
, __entry
->hdr_type
, __entry
->hdr_psize
,
93 __entry
->hdr_lsize
, __entry
->hdr_spa
, __entry
->hdr_state_type
,
94 __entry
->hdr_access
, __entry
->hdr_mru_hits
,
95 __entry
->hdr_mru_ghost_hits
, __entry
->hdr_mfu_hits
,
96 __entry
->hdr_mfu_ghost_hits
, __entry
->hdr_l2_hits
,
97 __entry
->hdr_refcount
)
102 #define DEFINE_ARC_BUF_HDR_EVENT(name) \
103 DEFINE_EVENT(zfs_arc_buf_hdr_class, name, \
104 TP_PROTO(arc_buf_hdr_t *ab), \
107 DEFINE_ARC_BUF_HDR_EVENT(zfs_arc__hit
);
108 DEFINE_ARC_BUF_HDR_EVENT(zfs_arc__evict
);
109 DEFINE_ARC_BUF_HDR_EVENT(zfs_arc__delete
);
110 DEFINE_ARC_BUF_HDR_EVENT(zfs_new_state__mru
);
111 DEFINE_ARC_BUF_HDR_EVENT(zfs_new_state__mfu
);
112 DEFINE_ARC_BUF_HDR_EVENT(zfs_arc__async__upgrade__sync
);
113 DEFINE_ARC_BUF_HDR_EVENT(zfs_arc__demand__hit__predictive__prefetch
);
114 DEFINE_ARC_BUF_HDR_EVENT(zfs_l2arc__hit
);
115 DEFINE_ARC_BUF_HDR_EVENT(zfs_l2arc__miss
);
118 * Generic support for two argument tracepoints of the form:
125 DECLARE_EVENT_CLASS(zfs_l2arc_rw_class
,
126 TP_PROTO(vdev_t
*vd
, zio_t
*zio
),
129 __field(uint64_t, vdev_id
)
130 __field(uint64_t, vdev_guid
)
131 __field(uint64_t, vdev_state
)
135 __entry
->vdev_id
= vd
->vdev_id
;
136 __entry
->vdev_guid
= vd
->vdev_guid
;
137 __entry
->vdev_state
= vd
->vdev_state
;
140 TP_printk("vdev { id %llu guid %llu state %llu } "
141 ZIO_TP_PRINTK_FMT
, __entry
->vdev_id
, __entry
->vdev_guid
,
142 __entry
->vdev_state
, ZIO_TP_PRINTK_ARGS
)
147 #define DEFINE_L2ARC_RW_EVENT(name) \
148 DEFINE_EVENT(zfs_l2arc_rw_class, name, \
149 TP_PROTO(vdev_t *vd, zio_t *zio), \
152 DEFINE_L2ARC_RW_EVENT(zfs_l2arc__read
);
153 DEFINE_L2ARC_RW_EVENT(zfs_l2arc__write
);
157 * Generic support for two argument tracepoints of the form:
161 * l2arc_write_callback_t *, ...);
164 DECLARE_EVENT_CLASS(zfs_l2arc_iodone_class
,
165 TP_PROTO(zio_t
*zio
, l2arc_write_callback_t
*cb
),
167 TP_STRUCT__entry(ZIO_TP_STRUCT_ENTRY
),
168 TP_fast_assign(ZIO_TP_FAST_ASSIGN
),
169 TP_printk(ZIO_TP_PRINTK_FMT
, ZIO_TP_PRINTK_ARGS
)
174 #define DEFINE_L2ARC_IODONE_EVENT(name) \
175 DEFINE_EVENT(zfs_l2arc_iodone_class, name, \
176 TP_PROTO(zio_t *zio, l2arc_write_callback_t *cb), \
179 DEFINE_L2ARC_IODONE_EVENT(zfs_l2arc__iodone
);
183 * Generic support for four argument tracepoints of the form:
186 * arc_buf_hdr_t *, ...,
189 * const zbookmark_phys_t *);
192 DECLARE_EVENT_CLASS(zfs_arc_miss_class
,
193 TP_PROTO(arc_buf_hdr_t
*hdr
,
194 const blkptr_t
*bp
, uint64_t size
, const zbookmark_phys_t
*zb
),
195 TP_ARGS(hdr
, bp
, size
, zb
),
197 __array(uint64_t, hdr_dva_word
, 2)
198 __field(uint64_t, hdr_birth
)
199 __field(uint32_t, hdr_flags
)
200 __field(uint32_t, hdr_bufcnt
)
201 __field(arc_buf_contents_t
, hdr_type
)
202 __field(uint16_t, hdr_psize
)
203 __field(uint16_t, hdr_lsize
)
204 __field(uint64_t, hdr_spa
)
205 __field(arc_state_type_t
, hdr_state_type
)
206 __field(clock_t, hdr_access
)
207 __field(uint32_t, hdr_mru_hits
)
208 __field(uint32_t, hdr_mru_ghost_hits
)
209 __field(uint32_t, hdr_mfu_hits
)
210 __field(uint32_t, hdr_mfu_ghost_hits
)
211 __field(uint32_t, hdr_l2_hits
)
212 __field(int64_t, hdr_refcount
)
214 __array(uint64_t, bp_dva0
, 2)
215 __array(uint64_t, bp_dva1
, 2)
216 __array(uint64_t, bp_dva2
, 2)
217 __array(uint64_t, bp_cksum
, 4)
219 __field(uint64_t, bp_lsize
)
221 __field(uint64_t, zb_objset
)
222 __field(uint64_t, zb_object
)
223 __field(int64_t, zb_level
)
224 __field(uint64_t, zb_blkid
)
227 __entry
->hdr_dva_word
[0] = hdr
->b_dva
.dva_word
[0];
228 __entry
->hdr_dva_word
[1] = hdr
->b_dva
.dva_word
[1];
229 __entry
->hdr_birth
= hdr
->b_birth
;
230 __entry
->hdr_flags
= hdr
->b_flags
;
231 __entry
->hdr_bufcnt
= hdr
->b_l1hdr
.b_bufcnt
;
232 __entry
->hdr_psize
= hdr
->b_psize
;
233 __entry
->hdr_lsize
= hdr
->b_lsize
;
234 __entry
->hdr_spa
= hdr
->b_spa
;
235 __entry
->hdr_state_type
= hdr
->b_l1hdr
.b_state
->arcs_state
;
236 __entry
->hdr_access
= hdr
->b_l1hdr
.b_arc_access
;
237 __entry
->hdr_mru_hits
= hdr
->b_l1hdr
.b_mru_hits
;
238 __entry
->hdr_mru_ghost_hits
= hdr
->b_l1hdr
.b_mru_ghost_hits
;
239 __entry
->hdr_mfu_hits
= hdr
->b_l1hdr
.b_mfu_hits
;
240 __entry
->hdr_mfu_ghost_hits
= hdr
->b_l1hdr
.b_mfu_ghost_hits
;
241 __entry
->hdr_l2_hits
= hdr
->b_l1hdr
.b_l2_hits
;
242 __entry
->hdr_refcount
= hdr
->b_l1hdr
.b_refcnt
.rc_count
;
244 __entry
->bp_dva0
[0] = bp
->blk_dva
[0].dva_word
[0];
245 __entry
->bp_dva0
[1] = bp
->blk_dva
[0].dva_word
[1];
246 __entry
->bp_dva1
[0] = bp
->blk_dva
[1].dva_word
[0];
247 __entry
->bp_dva1
[1] = bp
->blk_dva
[1].dva_word
[1];
248 __entry
->bp_dva2
[0] = bp
->blk_dva
[2].dva_word
[0];
249 __entry
->bp_dva2
[1] = bp
->blk_dva
[2].dva_word
[1];
250 __entry
->bp_cksum
[0] = bp
->blk_cksum
.zc_word
[0];
251 __entry
->bp_cksum
[1] = bp
->blk_cksum
.zc_word
[1];
252 __entry
->bp_cksum
[2] = bp
->blk_cksum
.zc_word
[2];
253 __entry
->bp_cksum
[3] = bp
->blk_cksum
.zc_word
[3];
255 __entry
->bp_lsize
= size
;
257 __entry
->zb_objset
= zb
->zb_objset
;
258 __entry
->zb_object
= zb
->zb_object
;
259 __entry
->zb_level
= zb
->zb_level
;
260 __entry
->zb_blkid
= zb
->zb_blkid
;
262 TP_printk("hdr { dva 0x%llx:0x%llx birth %llu "
263 "flags 0x%x bufcnt %u psize %u lsize %u spa %llu state_type %u "
264 "access %lu mru_hits %u mru_ghost_hits %u mfu_hits %u "
265 "mfu_ghost_hits %u l2_hits %u refcount %lli } "
266 "bp { dva0 0x%llx:0x%llx dva1 0x%llx:0x%llx dva2 "
267 "0x%llx:0x%llx cksum 0x%llx:0x%llx:0x%llx:0x%llx "
268 "lsize %llu } zb { objset %llu object %llu level %lli "
270 __entry
->hdr_dva_word
[0], __entry
->hdr_dva_word
[1],
271 __entry
->hdr_birth
, __entry
->hdr_flags
,
272 __entry
->hdr_bufcnt
, __entry
->hdr_psize
, __entry
->hdr_lsize
,
273 __entry
->hdr_spa
, __entry
->hdr_state_type
, __entry
->hdr_access
,
274 __entry
->hdr_mru_hits
, __entry
->hdr_mru_ghost_hits
,
275 __entry
->hdr_mfu_hits
, __entry
->hdr_mfu_ghost_hits
,
276 __entry
->hdr_l2_hits
, __entry
->hdr_refcount
,
277 __entry
->bp_dva0
[0], __entry
->bp_dva0
[1],
278 __entry
->bp_dva1
[0], __entry
->bp_dva1
[1],
279 __entry
->bp_dva2
[0], __entry
->bp_dva2
[1],
280 __entry
->bp_cksum
[0], __entry
->bp_cksum
[1],
281 __entry
->bp_cksum
[2], __entry
->bp_cksum
[3],
282 __entry
->bp_lsize
, __entry
->zb_objset
, __entry
->zb_object
,
283 __entry
->zb_level
, __entry
->zb_blkid
)
288 #define DEFINE_ARC_MISS_EVENT(name) \
289 DEFINE_EVENT(zfs_arc_miss_class, name, \
290 TP_PROTO(arc_buf_hdr_t *hdr, \
291 const blkptr_t *bp, uint64_t size, const zbookmark_phys_t *zb), \
292 TP_ARGS(hdr, bp, size, zb))
294 DEFINE_ARC_MISS_EVENT(zfs_arc__miss
);
297 * Generic support for four argument tracepoints of the form:
300 * l2arc_dev_t *, ...,
306 DECLARE_EVENT_CLASS(zfs_l2arc_evict_class
,
307 TP_PROTO(l2arc_dev_t
*dev
,
308 list_t
*buflist
, uint64_t taddr
, boolean_t all
),
309 TP_ARGS(dev
, buflist
, taddr
, all
),
311 __field(uint64_t, vdev_id
)
312 __field(uint64_t, vdev_guid
)
313 __field(uint64_t, vdev_state
)
315 __field(uint64_t, l2ad_hand
)
316 __field(uint64_t, l2ad_start
)
317 __field(uint64_t, l2ad_end
)
318 __field(boolean_t
, l2ad_first
)
319 __field(boolean_t
, l2ad_writing
)
321 __field(uint64_t, taddr
)
322 __field(boolean_t
, all
)
325 __entry
->vdev_id
= dev
->l2ad_vdev
->vdev_id
;
326 __entry
->vdev_guid
= dev
->l2ad_vdev
->vdev_guid
;
327 __entry
->vdev_state
= dev
->l2ad_vdev
->vdev_state
;
329 __entry
->l2ad_hand
= dev
->l2ad_hand
;
330 __entry
->l2ad_start
= dev
->l2ad_start
;
331 __entry
->l2ad_end
= dev
->l2ad_end
;
332 __entry
->l2ad_first
= dev
->l2ad_first
;
333 __entry
->l2ad_writing
= dev
->l2ad_writing
;
335 __entry
->taddr
= taddr
;
338 TP_printk("l2ad { vdev { id %llu guid %llu state %llu } "
339 "hand %llu start %llu end %llu "
340 "first %d writing %d } taddr %llu all %d",
341 __entry
->vdev_id
, __entry
->vdev_guid
, __entry
->vdev_state
,
342 __entry
->l2ad_hand
, __entry
->l2ad_start
,
343 __entry
->l2ad_end
, __entry
->l2ad_first
, __entry
->l2ad_writing
,
344 __entry
->taddr
, __entry
->all
)
349 #define DEFINE_L2ARC_EVICT_EVENT(name) \
350 DEFINE_EVENT(zfs_l2arc_evict_class, name, \
351 TP_PROTO(l2arc_dev_t *dev, \
352 list_t *buflist, uint64_t taddr, boolean_t all), \
353 TP_ARGS(dev, buflist, taddr, all))
355 DEFINE_L2ARC_EVICT_EVENT(zfs_l2arc__evict
);
358 * Generic support for three argument tracepoints of the form:
366 DECLARE_EVENT_CLASS(zfs_arc_wait_for_eviction_class
,
367 TP_PROTO(uint64_t amount
, uint64_t arc_evict_count
, uint64_t aew_count
),
368 TP_ARGS(amount
, arc_evict_count
, aew_count
),
370 __field(uint64_t, amount
)
371 __field(uint64_t, arc_evict_count
)
372 __field(uint64_t, aew_count
)
375 __entry
->amount
= amount
;
376 __entry
->arc_evict_count
= arc_evict_count
;
377 __entry
->aew_count
= aew_count
;
379 TP_printk("amount %llu arc_evict_count %llu aew_count %llu",
380 __entry
->amount
, __entry
->arc_evict_count
, __entry
->aew_count
)
385 #define DEFINE_ARC_WAIT_FOR_EVICTION_EVENT(name) \
386 DEFINE_EVENT(zfs_arc_wait_for_eviction_class, name, \
387 TP_PROTO(uint64_t amount, uint64_t arc_evict_count, uint64_t aew_count), \
388 TP_ARGS(amount, arc_evict_count, aew_count))
390 DEFINE_ARC_WAIT_FOR_EVICTION_EVENT(zfs_arc__wait__for__eviction
);
392 #endif /* _TRACE_ARC_H */
394 #undef TRACE_INCLUDE_PATH
395 #undef TRACE_INCLUDE_FILE
396 #define TRACE_INCLUDE_PATH sys
397 #define TRACE_INCLUDE_FILE trace_arc
398 #include <trace/define_trace.h>
402 DEFINE_DTRACE_PROBE1(arc__hit
);
403 DEFINE_DTRACE_PROBE1(arc__evict
);
404 DEFINE_DTRACE_PROBE1(arc__delete
);
405 DEFINE_DTRACE_PROBE1(new_state__mru
);
406 DEFINE_DTRACE_PROBE1(new_state__mfu
);
407 DEFINE_DTRACE_PROBE1(arc__async__upgrade__sync
);
408 DEFINE_DTRACE_PROBE1(arc__demand__hit__predictive__prefetch
);
409 DEFINE_DTRACE_PROBE1(l2arc__hit
);
410 DEFINE_DTRACE_PROBE1(l2arc__miss
);
411 DEFINE_DTRACE_PROBE2(l2arc__read
);
412 DEFINE_DTRACE_PROBE2(l2arc__write
);
413 DEFINE_DTRACE_PROBE2(l2arc__iodone
);
414 DEFINE_DTRACE_PROBE3(arc__wait__for__eviction
);
415 DEFINE_DTRACE_PROBE4(arc__miss
);
416 DEFINE_DTRACE_PROBE4(l2arc__evict
);
418 #endif /* HAVE_DECLARE_EVENT_CLASS */