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