]> git.proxmox.com Git - mirror_zfs.git/blob - include/sys/trace_arc.h
Illumos 5408 - managing ZFS cache devices requires lots of RAM
[mirror_zfs.git] / include / sys / trace_arc.h
1 /*
2 * CDDL HEADER START
3 *
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.
7 *
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.
12 *
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]
18 *
19 * CDDL HEADER END
20 */
21
22 #include <sys/list.h>
23
24 #if defined(_KERNEL) && defined(HAVE_DECLARE_EVENT_CLASS)
25
26 #undef TRACE_SYSTEM
27 #define TRACE_SYSTEM zfs
28
29 #if !defined(_TRACE_ARC_H) || defined(TRACE_HEADER_MULTI_READ)
30 #define _TRACE_ARC_H
31
32 #include <linux/tracepoint.h>
33 #include <sys/types.h>
34
35 /*
36 * Generic support for one argument tracepoints of the form:
37 *
38 * DTRACE_PROBE1(...,
39 * arc_buf_hdr_t *, ...);
40 */
41
42 DECLARE_EVENT_CLASS(zfs_arc_buf_hdr_class,
43 TP_PROTO(arc_buf_hdr_t *ab),
44 TP_ARGS(ab),
45 TP_STRUCT__entry(
46 __array(uint64_t, hdr_dva_word, 2)
47 __field(uint64_t, hdr_birth)
48 __field(uint32_t, hdr_flags)
49 __field(uint32_t, hdr_datacnt)
50 __field(arc_buf_contents_t, hdr_type)
51 __field(uint64_t, hdr_size)
52 __field(uint64_t, hdr_spa)
53 __field(arc_state_type_t, hdr_state_type)
54 __field(clock_t, hdr_access)
55 __field(uint32_t, hdr_mru_hits)
56 __field(uint32_t, hdr_mru_ghost_hits)
57 __field(uint32_t, hdr_mfu_hits)
58 __field(uint32_t, hdr_mfu_ghost_hits)
59 __field(uint32_t, hdr_l2_hits)
60 __field(int64_t, hdr_refcount)
61 ),
62 TP_fast_assign(
63 __entry->hdr_dva_word[0] = ab->b_dva.dva_word[0];
64 __entry->hdr_dva_word[1] = ab->b_dva.dva_word[1];
65 __entry->hdr_birth = ab->b_birth;
66 __entry->hdr_flags = ab->b_flags;
67 __entry->hdr_datacnt = ab->b_l1hdr.b_datacnt;
68 __entry->hdr_size = ab->b_size;
69 __entry->hdr_spa = ab->b_spa;
70 __entry->hdr_state_type = ab->b_l1hdr.b_state->arcs_state;
71 __entry->hdr_access = ab->b_l1hdr.b_arc_access;
72 __entry->hdr_mru_hits = ab->b_l1hdr.b_mru_hits;
73 __entry->hdr_mru_ghost_hits = ab->b_l1hdr.b_mru_ghost_hits;
74 __entry->hdr_mfu_hits = ab->b_l1hdr.b_mfu_hits;
75 __entry->hdr_mfu_ghost_hits = ab->b_l1hdr.b_mfu_ghost_hits;
76 __entry->hdr_l2_hits = ab->b_l1hdr.b_l2_hits;
77 __entry->hdr_refcount = ab->b_l1hdr.b_refcnt.rc_count;
78 ),
79 TP_printk("hdr { dva 0x%llx:0x%llx birth %llu "
80 "flags 0x%x datacnt %u type %u size %llu spa %llu "
81 "state_type %u access %lu mru_hits %u mru_ghost_hits %u "
82 "mfu_hits %u mfu_ghost_hits %u l2_hits %u refcount %lli }",
83 __entry->hdr_dva_word[0], __entry->hdr_dva_word[1],
84 __entry->hdr_birth, __entry->hdr_flags,
85 __entry->hdr_datacnt, __entry->hdr_type, __entry->hdr_size,
86 __entry->hdr_spa, __entry->hdr_state_type,
87 __entry->hdr_access, __entry->hdr_mru_hits,
88 __entry->hdr_mru_ghost_hits, __entry->hdr_mfu_hits,
89 __entry->hdr_mfu_ghost_hits, __entry->hdr_l2_hits,
90 __entry->hdr_refcount)
91 );
92
93 #define DEFINE_ARC_BUF_HDR_EVENT(name) \
94 DEFINE_EVENT(zfs_arc_buf_hdr_class, name, \
95 TP_PROTO(arc_buf_hdr_t *ab), \
96 TP_ARGS(ab))
97 DEFINE_ARC_BUF_HDR_EVENT(zfs_arc__hit);
98 DEFINE_ARC_BUF_HDR_EVENT(zfs_arc__evict);
99 DEFINE_ARC_BUF_HDR_EVENT(zfs_arc__delete);
100 DEFINE_ARC_BUF_HDR_EVENT(zfs_new_state__mru);
101 DEFINE_ARC_BUF_HDR_EVENT(zfs_new_state__mfu);
102 DEFINE_ARC_BUF_HDR_EVENT(zfs_l2arc__hit);
103 DEFINE_ARC_BUF_HDR_EVENT(zfs_l2arc__miss);
104
105 /*
106 * Generic support for two argument tracepoints of the form:
107 *
108 * DTRACE_PROBE2(...,
109 * vdev_t *, ...,
110 * zio_t *, ...);
111 */
112
113 #define ZIO_TP_STRUCT_ENTRY \
114 __field(zio_type_t, zio_type) \
115 __field(int, zio_cmd) \
116 __field(zio_priority_t, zio_priority) \
117 __field(uint64_t, zio_size) \
118 __field(uint64_t, zio_orig_size) \
119 __field(uint64_t, zio_offset) \
120 __field(hrtime_t, zio_timestamp) \
121 __field(hrtime_t, zio_delta) \
122 __field(uint64_t, zio_delay) \
123 __field(enum zio_flag, zio_flags) \
124 __field(enum zio_stage, zio_stage) \
125 __field(enum zio_stage, zio_pipeline) \
126 __field(enum zio_flag, zio_orig_flags) \
127 __field(enum zio_stage, zio_orig_stage) \
128 __field(enum zio_stage, zio_orig_pipeline) \
129 __field(uint8_t, zio_reexecute) \
130 __field(uint64_t, zio_txg) \
131 __field(int, zio_error) \
132 __field(uint64_t, zio_ena) \
133 \
134 __field(enum zio_checksum, zp_checksum) \
135 __field(enum zio_compress, zp_compress) \
136 __field(dmu_object_type_t, zp_type) \
137 __field(uint8_t, zp_level) \
138 __field(uint8_t, zp_copies) \
139 __field(boolean_t, zp_dedup) \
140 __field(boolean_t, zp_dedup_verify) \
141 __field(boolean_t, zp_nopwrite)
142
143 #define ZIO_TP_FAST_ASSIGN \
144 __entry->zio_type = zio->io_type; \
145 __entry->zio_cmd = zio->io_cmd; \
146 __entry->zio_priority = zio->io_priority; \
147 __entry->zio_size = zio->io_size; \
148 __entry->zio_orig_size = zio->io_orig_size; \
149 __entry->zio_offset = zio->io_offset; \
150 __entry->zio_timestamp = zio->io_timestamp; \
151 __entry->zio_delta = zio->io_delta; \
152 __entry->zio_delay = zio->io_delay; \
153 __entry->zio_flags = zio->io_flags; \
154 __entry->zio_stage = zio->io_stage; \
155 __entry->zio_pipeline = zio->io_pipeline; \
156 __entry->zio_orig_flags = zio->io_orig_flags; \
157 __entry->zio_orig_stage = zio->io_orig_stage; \
158 __entry->zio_orig_pipeline = zio->io_orig_pipeline; \
159 __entry->zio_reexecute = zio->io_reexecute; \
160 __entry->zio_txg = zio->io_txg; \
161 __entry->zio_error = zio->io_error; \
162 __entry->zio_ena = zio->io_ena; \
163 \
164 __entry->zp_checksum = zio->io_prop.zp_checksum; \
165 __entry->zp_compress = zio->io_prop.zp_compress; \
166 __entry->zp_type = zio->io_prop.zp_type; \
167 __entry->zp_level = zio->io_prop.zp_level; \
168 __entry->zp_copies = zio->io_prop.zp_copies; \
169 __entry->zp_dedup = zio->io_prop.zp_dedup; \
170 __entry->zp_nopwrite = zio->io_prop.zp_nopwrite; \
171 __entry->zp_dedup_verify = zio->io_prop.zp_dedup_verify;
172
173 #define ZIO_TP_PRINTK_FMT \
174 "zio { type %u cmd %i prio %u size %llu orig_size %llu " \
175 "offset %llu timestamp %llu delta %llu delay %llu " \
176 "flags 0x%x stage 0x%x pipeline 0x%x orig_flags 0x%x " \
177 "orig_stage 0x%x orig_pipeline 0x%x reexecute %u " \
178 "txg %llu error %d ena %llu prop { checksum %u compress %u " \
179 "type %u level %u copies %u dedup %u dedup_verify %u nopwrite %u } }"
180
181 #define ZIO_TP_PRINTK_ARGS \
182 __entry->zio_type, __entry->zio_cmd, __entry->zio_priority, \
183 __entry->zio_size, __entry->zio_orig_size, __entry->zio_offset, \
184 __entry->zio_timestamp, __entry->zio_delta, __entry->zio_delay, \
185 __entry->zio_flags, __entry->zio_stage, __entry->zio_pipeline, \
186 __entry->zio_orig_flags, __entry->zio_orig_stage, \
187 __entry->zio_orig_pipeline, __entry->zio_reexecute, \
188 __entry->zio_txg, __entry->zio_error, __entry->zio_ena, \
189 __entry->zp_checksum, __entry->zp_compress, __entry->zp_type, \
190 __entry->zp_level, __entry->zp_copies, __entry->zp_dedup, \
191 __entry->zp_dedup_verify, __entry->zp_nopwrite
192
193 DECLARE_EVENT_CLASS(zfs_l2arc_rw_class,
194 TP_PROTO(vdev_t *vd, zio_t *zio),
195 TP_ARGS(vd, zio),
196 TP_STRUCT__entry(
197 __field(uint64_t, vdev_id)
198 __field(uint64_t, vdev_guid)
199 __field(uint64_t, vdev_state)
200 ZIO_TP_STRUCT_ENTRY
201 ),
202 TP_fast_assign(
203 __entry->vdev_id = vd->vdev_id;
204 __entry->vdev_guid = vd->vdev_guid;
205 __entry->vdev_state = vd->vdev_state;
206 ZIO_TP_FAST_ASSIGN
207 ),
208 TP_printk("vdev { id %llu guid %llu state %llu } "
209 ZIO_TP_PRINTK_FMT, __entry->vdev_id, __entry->vdev_guid,
210 __entry->vdev_state, ZIO_TP_PRINTK_ARGS)
211 );
212
213 #define DEFINE_L2ARC_RW_EVENT(name) \
214 DEFINE_EVENT(zfs_l2arc_rw_class, name, \
215 TP_PROTO(vdev_t *vd, zio_t *zio), \
216 TP_ARGS(vd, zio))
217 DEFINE_L2ARC_RW_EVENT(zfs_l2arc__read);
218 DEFINE_L2ARC_RW_EVENT(zfs_l2arc__write);
219
220
221 /*
222 * Generic support for two argument tracepoints of the form:
223 *
224 * DTRACE_PROBE2(...,
225 * zio_t *, ...,
226 * l2arc_write_callback_t *, ...);
227 */
228
229 DECLARE_EVENT_CLASS(zfs_l2arc_iodone_class,
230 TP_PROTO(zio_t *zio, l2arc_write_callback_t *cb),
231 TP_ARGS(zio, cb),
232 TP_STRUCT__entry(ZIO_TP_STRUCT_ENTRY),
233 TP_fast_assign(ZIO_TP_FAST_ASSIGN),
234 TP_printk(ZIO_TP_PRINTK_FMT, ZIO_TP_PRINTK_ARGS)
235 );
236
237 #define DEFINE_L2ARC_IODONE_EVENT(name) \
238 DEFINE_EVENT(zfs_l2arc_iodone_class, name, \
239 TP_PROTO(zio_t *zio, l2arc_write_callback_t *cb), \
240 TP_ARGS(zio, cb))
241 DEFINE_L2ARC_IODONE_EVENT(zfs_l2arc__iodone);
242
243
244 /*
245 * Generic support for four argument tracepoints of the form:
246 *
247 * DTRACE_PROBE4(...,
248 * arc_buf_hdr_t *, ...,
249 * const blkptr_t *,
250 * uint64_t,
251 * const zbookmark_phys_t *);
252 */
253
254 DECLARE_EVENT_CLASS(zfs_arc_miss_class,
255 TP_PROTO(arc_buf_hdr_t *hdr,
256 const blkptr_t *bp, uint64_t size, const zbookmark_phys_t *zb),
257 TP_ARGS(hdr, bp, size, zb),
258 TP_STRUCT__entry(
259 __array(uint64_t, hdr_dva_word, 2)
260 __field(uint64_t, hdr_birth)
261 __field(uint32_t, hdr_flags)
262 __field(uint32_t, hdr_datacnt)
263 __field(arc_buf_contents_t, hdr_type)
264 __field(uint64_t, hdr_size)
265 __field(uint64_t, hdr_spa)
266 __field(arc_state_type_t, hdr_state_type)
267 __field(clock_t, hdr_access)
268 __field(uint32_t, hdr_mru_hits)
269 __field(uint32_t, hdr_mru_ghost_hits)
270 __field(uint32_t, hdr_mfu_hits)
271 __field(uint32_t, hdr_mfu_ghost_hits)
272 __field(uint32_t, hdr_l2_hits)
273 __field(int64_t, hdr_refcount)
274
275 __array(uint64_t, bp_dva0, 2)
276 __array(uint64_t, bp_dva1, 2)
277 __array(uint64_t, bp_dva2, 2)
278 __array(uint64_t, bp_cksum, 4)
279
280 __field(uint64_t, bp_lsize)
281
282 __field(uint64_t, zb_objset)
283 __field(uint64_t, zb_object)
284 __field(int64_t, zb_level)
285 __field(uint64_t, zb_blkid)
286 ),
287 TP_fast_assign(
288 __entry->hdr_dva_word[0] = hdr->b_dva.dva_word[0];
289 __entry->hdr_dva_word[1] = hdr->b_dva.dva_word[1];
290 __entry->hdr_birth = hdr->b_birth;
291 __entry->hdr_flags = hdr->b_flags;
292 __entry->hdr_datacnt = hdr->b_l1hdr.b_datacnt;
293 __entry->hdr_size = hdr->b_size;
294 __entry->hdr_spa = hdr->b_spa;
295 __entry->hdr_state_type = hdr->b_l1hdr.b_state->arcs_state;
296 __entry->hdr_access = hdr->b_l1hdr.b_arc_access;
297 __entry->hdr_mru_hits = hdr->b_l1hdr.b_mru_hits;
298 __entry->hdr_mru_ghost_hits = hdr->b_l1hdr.b_mru_ghost_hits;
299 __entry->hdr_mfu_hits = hdr->b_l1hdr.b_mfu_hits;
300 __entry->hdr_mfu_ghost_hits = hdr->b_l1hdr.b_mfu_ghost_hits;
301 __entry->hdr_l2_hits = hdr->b_l1hdr.b_l2_hits;
302 __entry->hdr_refcount = hdr->b_l1hdr.b_refcnt.rc_count;
303
304 __entry->bp_dva0[0] = bp->blk_dva[0].dva_word[0];
305 __entry->bp_dva0[1] = bp->blk_dva[0].dva_word[1];
306 __entry->bp_dva1[0] = bp->blk_dva[1].dva_word[0];
307 __entry->bp_dva1[1] = bp->blk_dva[1].dva_word[1];
308 __entry->bp_dva2[0] = bp->blk_dva[2].dva_word[0];
309 __entry->bp_dva2[1] = bp->blk_dva[2].dva_word[1];
310 __entry->bp_cksum[0] = bp->blk_cksum.zc_word[0];
311 __entry->bp_cksum[1] = bp->blk_cksum.zc_word[1];
312 __entry->bp_cksum[2] = bp->blk_cksum.zc_word[2];
313 __entry->bp_cksum[3] = bp->blk_cksum.zc_word[3];
314
315 __entry->bp_lsize = size;
316
317 __entry->zb_objset = zb->zb_objset;
318 __entry->zb_object = zb->zb_object;
319 __entry->zb_level = zb->zb_level;
320 __entry->zb_blkid = zb->zb_blkid;
321 ),
322 TP_printk("hdr { dva 0x%llx:0x%llx birth %llu "
323 "flags 0x%x datacnt %u size %llu spa %llu state_type %u "
324 "access %lu mru_hits %u mru_ghost_hits %u mfu_hits %u "
325 "mfu_ghost_hits %u l2_hits %u refcount %lli } "
326 "bp { dva0 0x%llx:0x%llx dva1 0x%llx:0x%llx dva2 "
327 "0x%llx:0x%llx cksum 0x%llx:0x%llx:0x%llx:0x%llx "
328 "lsize %llu } zb { objset %llu object %llu level %lli "
329 "blkid %llu }",
330 __entry->hdr_dva_word[0], __entry->hdr_dva_word[1],
331 __entry->hdr_birth, __entry->hdr_flags,
332 __entry->hdr_datacnt, __entry->hdr_size,
333 __entry->hdr_spa, __entry->hdr_state_type, __entry->hdr_access,
334 __entry->hdr_mru_hits, __entry->hdr_mru_ghost_hits,
335 __entry->hdr_mfu_hits, __entry->hdr_mfu_ghost_hits,
336 __entry->hdr_l2_hits, __entry->hdr_refcount,
337 __entry->bp_dva0[0], __entry->bp_dva0[1],
338 __entry->bp_dva1[0], __entry->bp_dva1[1],
339 __entry->bp_dva2[0], __entry->bp_dva2[1],
340 __entry->bp_cksum[0], __entry->bp_cksum[1],
341 __entry->bp_cksum[2], __entry->bp_cksum[3],
342 __entry->bp_lsize, __entry->zb_objset, __entry->zb_object,
343 __entry->zb_level, __entry->zb_blkid)
344 );
345
346 #define DEFINE_ARC_MISS_EVENT(name) \
347 DEFINE_EVENT(zfs_arc_miss_class, name, \
348 TP_PROTO(arc_buf_hdr_t *hdr, \
349 const blkptr_t *bp, uint64_t size, const zbookmark_phys_t *zb), \
350 TP_ARGS(hdr, bp, size, zb))
351 DEFINE_ARC_MISS_EVENT(zfs_arc__miss);
352
353 /*
354 * Generic support for four argument tracepoints of the form:
355 *
356 * DTRACE_PROBE4(...,
357 * l2arc_dev_t *, ...,
358 * list_t *, ...,
359 * uint64_t, ...,
360 * boolean_t, ...);
361 */
362
363 DECLARE_EVENT_CLASS(zfs_l2arc_evict_class,
364 TP_PROTO(l2arc_dev_t *dev,
365 list_t *buflist, uint64_t taddr, boolean_t all),
366 TP_ARGS(dev, buflist, taddr, all),
367 TP_STRUCT__entry(
368 __field(uint64_t, vdev_id)
369 __field(uint64_t, vdev_guid)
370 __field(uint64_t, vdev_state)
371
372 __field(uint64_t, l2ad_hand)
373 __field(uint64_t, l2ad_start)
374 __field(uint64_t, l2ad_end)
375 __field(uint64_t, l2ad_evict)
376 __field(boolean_t, l2ad_first)
377 __field(boolean_t, l2ad_writing)
378
379 __field(uint64_t, taddr)
380 __field(boolean_t, all)
381 ),
382 TP_fast_assign(
383 __entry->vdev_id = dev->l2ad_vdev->vdev_id;
384 __entry->vdev_guid = dev->l2ad_vdev->vdev_guid;
385 __entry->vdev_state = dev->l2ad_vdev->vdev_state;
386
387 __entry->l2ad_hand = dev->l2ad_hand;
388 __entry->l2ad_start = dev->l2ad_start;
389 __entry->l2ad_end = dev->l2ad_end;
390 __entry->l2ad_evict = dev->l2ad_evict;
391 __entry->l2ad_first = dev->l2ad_first;
392 __entry->l2ad_writing = dev->l2ad_writing;
393
394 __entry->taddr = taddr;
395 __entry->all = all;
396 ),
397 TP_printk("l2ad { vdev { id %llu guid %llu state %llu } "
398 "hand %llu start %llu end %llu evict %llu "
399 "first %d writing %d } taddr %llu all %d",
400 __entry->vdev_id, __entry->vdev_guid, __entry->vdev_state,
401 __entry->l2ad_hand, __entry->l2ad_start,
402 __entry->l2ad_end, __entry->l2ad_evict,
403 __entry->l2ad_first, __entry->l2ad_writing,
404 __entry->taddr, __entry->all)
405 );
406
407 #define DEFINE_L2ARC_EVICT_EVENT(name) \
408 DEFINE_EVENT(zfs_l2arc_evict_class, name, \
409 TP_PROTO(l2arc_dev_t *dev, \
410 list_t *buflist, uint64_t taddr, boolean_t all), \
411 TP_ARGS(dev, buflist, taddr, all))
412 DEFINE_L2ARC_EVICT_EVENT(zfs_l2arc__evict);
413
414 #endif /* _TRACE_ARC_H */
415
416 #undef TRACE_INCLUDE_PATH
417 #undef TRACE_INCLUDE_FILE
418 #define TRACE_INCLUDE_PATH sys
419 #define TRACE_INCLUDE_FILE trace_arc
420 #include <trace/define_trace.h>
421
422 #endif /* _KERNEL && HAVE_DECLARE_EVENT_CLASS */