]> git.proxmox.com Git - mirror_zfs.git/blame - include/sys/trace_arc.h
OpenZFS 6531 - Provide mechanism to artificially limit disk performance
[mirror_zfs.git] / include / sys / trace_arc.h
CommitLineData
49ee64e5
NB
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
c1718e95
FV
29#undef TRACE_SYSTEM_VAR
30#define TRACE_SYSTEM_VAR zfs_arc
31
49ee64e5
NB
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>
26ef0cc7 37#include <sys/trace_common.h> /* For ZIO macros */
49ee64e5
NB
38
39/*
40 * Generic support for one argument tracepoints of the form:
41 *
42 * DTRACE_PROBE1(...,
43 * arc_buf_hdr_t *, ...);
44 */
45
46DECLARE_EVENT_CLASS(zfs_arc_buf_hdr_class,
47 TP_PROTO(arc_buf_hdr_t *ab),
48 TP_ARGS(ab),
49 TP_STRUCT__entry(
50 __array(uint64_t, hdr_dva_word, 2)
51 __field(uint64_t, hdr_birth)
49ee64e5
NB
52 __field(uint32_t, hdr_flags)
53 __field(uint32_t, hdr_datacnt)
54 __field(arc_buf_contents_t, hdr_type)
55 __field(uint64_t, hdr_size)
56 __field(uint64_t, hdr_spa)
57 __field(arc_state_type_t, hdr_state_type)
58 __field(clock_t, hdr_access)
59 __field(uint32_t, hdr_mru_hits)
60 __field(uint32_t, hdr_mru_ghost_hits)
61 __field(uint32_t, hdr_mfu_hits)
62 __field(uint32_t, hdr_mfu_ghost_hits)
63 __field(uint32_t, hdr_l2_hits)
64 __field(int64_t, hdr_refcount)
65 ),
66 TP_fast_assign(
67 __entry->hdr_dva_word[0] = ab->b_dva.dva_word[0];
68 __entry->hdr_dva_word[1] = ab->b_dva.dva_word[1];
69 __entry->hdr_birth = ab->b_birth;
49ee64e5 70 __entry->hdr_flags = ab->b_flags;
b9541d6b 71 __entry->hdr_datacnt = ab->b_l1hdr.b_datacnt;
49ee64e5
NB
72 __entry->hdr_size = ab->b_size;
73 __entry->hdr_spa = ab->b_spa;
b9541d6b
CW
74 __entry->hdr_state_type = ab->b_l1hdr.b_state->arcs_state;
75 __entry->hdr_access = ab->b_l1hdr.b_arc_access;
76 __entry->hdr_mru_hits = ab->b_l1hdr.b_mru_hits;
77 __entry->hdr_mru_ghost_hits = ab->b_l1hdr.b_mru_ghost_hits;
78 __entry->hdr_mfu_hits = ab->b_l1hdr.b_mfu_hits;
79 __entry->hdr_mfu_ghost_hits = ab->b_l1hdr.b_mfu_ghost_hits;
80 __entry->hdr_l2_hits = ab->b_l1hdr.b_l2_hits;
81 __entry->hdr_refcount = ab->b_l1hdr.b_refcnt.rc_count;
49ee64e5 82 ),
b9541d6b 83 TP_printk("hdr { dva 0x%llx:0x%llx birth %llu "
49ee64e5
NB
84 "flags 0x%x datacnt %u type %u size %llu spa %llu "
85 "state_type %u access %lu mru_hits %u mru_ghost_hits %u "
86 "mfu_hits %u mfu_ghost_hits %u l2_hits %u refcount %lli }",
87 __entry->hdr_dva_word[0], __entry->hdr_dva_word[1],
b9541d6b 88 __entry->hdr_birth, __entry->hdr_flags,
49ee64e5
NB
89 __entry->hdr_datacnt, __entry->hdr_type, __entry->hdr_size,
90 __entry->hdr_spa, __entry->hdr_state_type,
91 __entry->hdr_access, __entry->hdr_mru_hits,
92 __entry->hdr_mru_ghost_hits, __entry->hdr_mfu_hits,
93 __entry->hdr_mfu_ghost_hits, __entry->hdr_l2_hits,
94 __entry->hdr_refcount)
95);
96
97#define DEFINE_ARC_BUF_HDR_EVENT(name) \
98DEFINE_EVENT(zfs_arc_buf_hdr_class, name, \
99 TP_PROTO(arc_buf_hdr_t *ab), \
100 TP_ARGS(ab))
101DEFINE_ARC_BUF_HDR_EVENT(zfs_arc__hit);
102DEFINE_ARC_BUF_HDR_EVENT(zfs_arc__evict);
103DEFINE_ARC_BUF_HDR_EVENT(zfs_arc__delete);
104DEFINE_ARC_BUF_HDR_EVENT(zfs_new_state__mru);
105DEFINE_ARC_BUF_HDR_EVENT(zfs_new_state__mfu);
7f60329a
MA
106DEFINE_ARC_BUF_HDR_EVENT(zfs_arc__sync__wait__for__async);
107DEFINE_ARC_BUF_HDR_EVENT(zfs_arc__demand__hit__predictive__prefetch);
49ee64e5
NB
108DEFINE_ARC_BUF_HDR_EVENT(zfs_l2arc__hit);
109DEFINE_ARC_BUF_HDR_EVENT(zfs_l2arc__miss);
110
111/*
112 * Generic support for two argument tracepoints of the form:
113 *
114 * DTRACE_PROBE2(...,
115 * vdev_t *, ...,
116 * zio_t *, ...);
117 */
118
49ee64e5
NB
119DECLARE_EVENT_CLASS(zfs_l2arc_rw_class,
120 TP_PROTO(vdev_t *vd, zio_t *zio),
121 TP_ARGS(vd, zio),
122 TP_STRUCT__entry(
123 __field(uint64_t, vdev_id)
124 __field(uint64_t, vdev_guid)
125 __field(uint64_t, vdev_state)
126 ZIO_TP_STRUCT_ENTRY
127 ),
128 TP_fast_assign(
129 __entry->vdev_id = vd->vdev_id;
130 __entry->vdev_guid = vd->vdev_guid;
131 __entry->vdev_state = vd->vdev_state;
132 ZIO_TP_FAST_ASSIGN
133 ),
134 TP_printk("vdev { id %llu guid %llu state %llu } "
135 ZIO_TP_PRINTK_FMT, __entry->vdev_id, __entry->vdev_guid,
136 __entry->vdev_state, ZIO_TP_PRINTK_ARGS)
137);
138
139#define DEFINE_L2ARC_RW_EVENT(name) \
140DEFINE_EVENT(zfs_l2arc_rw_class, name, \
141 TP_PROTO(vdev_t *vd, zio_t *zio), \
142 TP_ARGS(vd, zio))
143DEFINE_L2ARC_RW_EVENT(zfs_l2arc__read);
144DEFINE_L2ARC_RW_EVENT(zfs_l2arc__write);
145
146
147/*
148 * Generic support for two argument tracepoints of the form:
149 *
150 * DTRACE_PROBE2(...,
151 * zio_t *, ...,
152 * l2arc_write_callback_t *, ...);
153 */
154
155DECLARE_EVENT_CLASS(zfs_l2arc_iodone_class,
156 TP_PROTO(zio_t *zio, l2arc_write_callback_t *cb),
157 TP_ARGS(zio, cb),
158 TP_STRUCT__entry(ZIO_TP_STRUCT_ENTRY),
159 TP_fast_assign(ZIO_TP_FAST_ASSIGN),
160 TP_printk(ZIO_TP_PRINTK_FMT, ZIO_TP_PRINTK_ARGS)
161);
162
163#define DEFINE_L2ARC_IODONE_EVENT(name) \
164DEFINE_EVENT(zfs_l2arc_iodone_class, name, \
165 TP_PROTO(zio_t *zio, l2arc_write_callback_t *cb), \
166 TP_ARGS(zio, cb))
167DEFINE_L2ARC_IODONE_EVENT(zfs_l2arc__iodone);
168
169
170/*
171 * Generic support for four argument tracepoints of the form:
172 *
173 * DTRACE_PROBE4(...,
174 * arc_buf_hdr_t *, ...,
175 * const blkptr_t *,
176 * uint64_t,
177 * const zbookmark_phys_t *);
178 */
179
180DECLARE_EVENT_CLASS(zfs_arc_miss_class,
181 TP_PROTO(arc_buf_hdr_t *hdr,
182 const blkptr_t *bp, uint64_t size, const zbookmark_phys_t *zb),
183 TP_ARGS(hdr, bp, size, zb),
184 TP_STRUCT__entry(
185 __array(uint64_t, hdr_dva_word, 2)
186 __field(uint64_t, hdr_birth)
49ee64e5
NB
187 __field(uint32_t, hdr_flags)
188 __field(uint32_t, hdr_datacnt)
189 __field(arc_buf_contents_t, hdr_type)
190 __field(uint64_t, hdr_size)
191 __field(uint64_t, hdr_spa)
192 __field(arc_state_type_t, hdr_state_type)
193 __field(clock_t, hdr_access)
194 __field(uint32_t, hdr_mru_hits)
195 __field(uint32_t, hdr_mru_ghost_hits)
196 __field(uint32_t, hdr_mfu_hits)
197 __field(uint32_t, hdr_mfu_ghost_hits)
198 __field(uint32_t, hdr_l2_hits)
199 __field(int64_t, hdr_refcount)
200
201 __array(uint64_t, bp_dva0, 2)
202 __array(uint64_t, bp_dva1, 2)
203 __array(uint64_t, bp_dva2, 2)
204 __array(uint64_t, bp_cksum, 4)
205
206 __field(uint64_t, bp_lsize)
207
208 __field(uint64_t, zb_objset)
209 __field(uint64_t, zb_object)
210 __field(int64_t, zb_level)
211 __field(uint64_t, zb_blkid)
212 ),
213 TP_fast_assign(
214 __entry->hdr_dva_word[0] = hdr->b_dva.dva_word[0];
215 __entry->hdr_dva_word[1] = hdr->b_dva.dva_word[1];
216 __entry->hdr_birth = hdr->b_birth;
49ee64e5 217 __entry->hdr_flags = hdr->b_flags;
b9541d6b 218 __entry->hdr_datacnt = hdr->b_l1hdr.b_datacnt;
49ee64e5
NB
219 __entry->hdr_size = hdr->b_size;
220 __entry->hdr_spa = hdr->b_spa;
b9541d6b
CW
221 __entry->hdr_state_type = hdr->b_l1hdr.b_state->arcs_state;
222 __entry->hdr_access = hdr->b_l1hdr.b_arc_access;
223 __entry->hdr_mru_hits = hdr->b_l1hdr.b_mru_hits;
224 __entry->hdr_mru_ghost_hits = hdr->b_l1hdr.b_mru_ghost_hits;
225 __entry->hdr_mfu_hits = hdr->b_l1hdr.b_mfu_hits;
226 __entry->hdr_mfu_ghost_hits = hdr->b_l1hdr.b_mfu_ghost_hits;
227 __entry->hdr_l2_hits = hdr->b_l1hdr.b_l2_hits;
228 __entry->hdr_refcount = hdr->b_l1hdr.b_refcnt.rc_count;
49ee64e5
NB
229
230 __entry->bp_dva0[0] = bp->blk_dva[0].dva_word[0];
231 __entry->bp_dva0[1] = bp->blk_dva[0].dva_word[1];
232 __entry->bp_dva1[0] = bp->blk_dva[1].dva_word[0];
233 __entry->bp_dva1[1] = bp->blk_dva[1].dva_word[1];
234 __entry->bp_dva2[0] = bp->blk_dva[2].dva_word[0];
235 __entry->bp_dva2[1] = bp->blk_dva[2].dva_word[1];
236 __entry->bp_cksum[0] = bp->blk_cksum.zc_word[0];
237 __entry->bp_cksum[1] = bp->blk_cksum.zc_word[1];
238 __entry->bp_cksum[2] = bp->blk_cksum.zc_word[2];
239 __entry->bp_cksum[3] = bp->blk_cksum.zc_word[3];
240
241 __entry->bp_lsize = size;
242
243 __entry->zb_objset = zb->zb_objset;
244 __entry->zb_object = zb->zb_object;
245 __entry->zb_level = zb->zb_level;
246 __entry->zb_blkid = zb->zb_blkid;
247 ),
b9541d6b
CW
248 TP_printk("hdr { dva 0x%llx:0x%llx birth %llu "
249 "flags 0x%x datacnt %u size %llu spa %llu state_type %u "
49ee64e5
NB
250 "access %lu mru_hits %u mru_ghost_hits %u mfu_hits %u "
251 "mfu_ghost_hits %u l2_hits %u refcount %lli } "
252 "bp { dva0 0x%llx:0x%llx dva1 0x%llx:0x%llx dva2 "
253 "0x%llx:0x%llx cksum 0x%llx:0x%llx:0x%llx:0x%llx "
254 "lsize %llu } zb { objset %llu object %llu level %lli "
255 "blkid %llu }",
256 __entry->hdr_dva_word[0], __entry->hdr_dva_word[1],
b9541d6b
CW
257 __entry->hdr_birth, __entry->hdr_flags,
258 __entry->hdr_datacnt, __entry->hdr_size,
49ee64e5
NB
259 __entry->hdr_spa, __entry->hdr_state_type, __entry->hdr_access,
260 __entry->hdr_mru_hits, __entry->hdr_mru_ghost_hits,
261 __entry->hdr_mfu_hits, __entry->hdr_mfu_ghost_hits,
262 __entry->hdr_l2_hits, __entry->hdr_refcount,
263 __entry->bp_dva0[0], __entry->bp_dva0[1],
264 __entry->bp_dva1[0], __entry->bp_dva1[1],
265 __entry->bp_dva2[0], __entry->bp_dva2[1],
266 __entry->bp_cksum[0], __entry->bp_cksum[1],
267 __entry->bp_cksum[2], __entry->bp_cksum[3],
268 __entry->bp_lsize, __entry->zb_objset, __entry->zb_object,
269 __entry->zb_level, __entry->zb_blkid)
270);
271
272#define DEFINE_ARC_MISS_EVENT(name) \
273DEFINE_EVENT(zfs_arc_miss_class, name, \
274 TP_PROTO(arc_buf_hdr_t *hdr, \
275 const blkptr_t *bp, uint64_t size, const zbookmark_phys_t *zb), \
276 TP_ARGS(hdr, bp, size, zb))
277DEFINE_ARC_MISS_EVENT(zfs_arc__miss);
278
279/*
280 * Generic support for four argument tracepoints of the form:
281 *
282 * DTRACE_PROBE4(...,
283 * l2arc_dev_t *, ...,
284 * list_t *, ...,
285 * uint64_t, ...,
286 * boolean_t, ...);
287 */
288
289DECLARE_EVENT_CLASS(zfs_l2arc_evict_class,
290 TP_PROTO(l2arc_dev_t *dev,
291 list_t *buflist, uint64_t taddr, boolean_t all),
292 TP_ARGS(dev, buflist, taddr, all),
293 TP_STRUCT__entry(
294 __field(uint64_t, vdev_id)
295 __field(uint64_t, vdev_guid)
296 __field(uint64_t, vdev_state)
297
298 __field(uint64_t, l2ad_hand)
299 __field(uint64_t, l2ad_start)
300 __field(uint64_t, l2ad_end)
49ee64e5
NB
301 __field(boolean_t, l2ad_first)
302 __field(boolean_t, l2ad_writing)
303
304 __field(uint64_t, taddr)
305 __field(boolean_t, all)
306 ),
307 TP_fast_assign(
308 __entry->vdev_id = dev->l2ad_vdev->vdev_id;
309 __entry->vdev_guid = dev->l2ad_vdev->vdev_guid;
310 __entry->vdev_state = dev->l2ad_vdev->vdev_state;
311
312 __entry->l2ad_hand = dev->l2ad_hand;
313 __entry->l2ad_start = dev->l2ad_start;
314 __entry->l2ad_end = dev->l2ad_end;
49ee64e5
NB
315 __entry->l2ad_first = dev->l2ad_first;
316 __entry->l2ad_writing = dev->l2ad_writing;
317
318 __entry->taddr = taddr;
319 __entry->all = all;
320 ),
321 TP_printk("l2ad { vdev { id %llu guid %llu state %llu } "
84045c2d 322 "hand %llu start %llu end %llu "
49ee64e5
NB
323 "first %d writing %d } taddr %llu all %d",
324 __entry->vdev_id, __entry->vdev_guid, __entry->vdev_state,
325 __entry->l2ad_hand, __entry->l2ad_start,
84045c2d 326 __entry->l2ad_end, __entry->l2ad_first, __entry->l2ad_writing,
49ee64e5
NB
327 __entry->taddr, __entry->all)
328);
329
330#define DEFINE_L2ARC_EVICT_EVENT(name) \
331DEFINE_EVENT(zfs_l2arc_evict_class, name, \
332 TP_PROTO(l2arc_dev_t *dev, \
333 list_t *buflist, uint64_t taddr, boolean_t all), \
334 TP_ARGS(dev, buflist, taddr, all))
335DEFINE_L2ARC_EVICT_EVENT(zfs_l2arc__evict);
336
337#endif /* _TRACE_ARC_H */
338
339#undef TRACE_INCLUDE_PATH
340#undef TRACE_INCLUDE_FILE
341#define TRACE_INCLUDE_PATH sys
342#define TRACE_INCLUDE_FILE trace_arc
343#include <trace/define_trace.h>
344
345#endif /* _KERNEL && HAVE_DECLARE_EVENT_CLASS */