xref: /freebsd/sys/contrib/openzfs/include/os/linux/zfs/sys/trace_multilist.h (revision 61145dc2b94f12f6a47344fb9aac702321880e43)
1 // SPDX-License-Identifier: CDDL-1.0
2 /*
3  * CDDL HEADER START
4  *
5  * The contents of this file are subject to the terms of the
6  * Common Development and Distribution License (the "License").
7  * You may not use this file except in compliance with the License.
8  *
9  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10  * or https://opensource.org/licenses/CDDL-1.0.
11  * See the License for the specific language governing permissions
12  * and limitations under the License.
13  *
14  * When distributing Covered Code, include this CDDL HEADER in each
15  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16  * If applicable, add the following below this CDDL HEADER, with the
17  * fields enclosed by brackets "[]" replaced with your own identifying
18  * information: Portions Copyright [yyyy] [name of copyright owner]
19  *
20  * CDDL HEADER END
21  */
22 
23 #if defined(_KERNEL)
24 #if 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_multilist
31 
32 #if !defined(_TRACE_MULTILIST_H) || defined(TRACE_HEADER_MULTI_READ)
33 #define	_TRACE_MULTILIST_H
34 
35 #include <linux/tracepoint.h>
36 #include <sys/types.h>
37 
38 /*
39  * Generic support for three argument tracepoints of the form:
40  *
41  * DTRACE_PROBE3(...,
42  *     multilist_t *, ...,
43  *     unsigned int, ...,
44  *     void *, ...);
45  */
46 /* BEGIN CSTYLED */
47 DECLARE_EVENT_CLASS(zfs_multilist_insert_remove_class,
48 	TP_PROTO(multilist_t *ml, unsigned sublist_idx, void *obj),
49 	TP_ARGS(ml, sublist_idx, obj),
50 	TP_STRUCT__entry(
51 	    __field(size_t,		ml_offset)
52 	    __field(uint64_t,		ml_num_sublists)
53 
54 	    __field(unsigned int,	sublist_idx)
55 	),
56 	TP_fast_assign(
57 	    __entry->ml_offset		= ml->ml_offset;
58 	    __entry->ml_num_sublists	= ml->ml_num_sublists;
59 
60 	    __entry->sublist_idx	= sublist_idx;
61 	),
62 	TP_printk("ml { offset %ld numsublists %llu sublistidx %u } ",
63 	    __entry->ml_offset, __entry->ml_num_sublists, __entry->sublist_idx)
64 );
65 /* END CSTYLED */
66 
67 #define	DEFINE_MULTILIST_INSERT_REMOVE_EVENT(name) \
68 DEFINE_EVENT(zfs_multilist_insert_remove_class, name, \
69     TP_PROTO(multilist_t *ml, unsigned int sublist_idx, void *obj), \
70     TP_ARGS(ml, sublist_idx, obj))
71 DEFINE_MULTILIST_INSERT_REMOVE_EVENT(zfs_multilist__insert);
72 DEFINE_MULTILIST_INSERT_REMOVE_EVENT(zfs_multilist__remove);
73 
74 #endif /* _TRACE_MULTILIST_H */
75 
76 #undef TRACE_INCLUDE_PATH
77 #undef TRACE_INCLUDE_FILE
78 #define	TRACE_INCLUDE_PATH sys
79 #define	TRACE_INCLUDE_FILE trace_multilist
80 #include <trace/define_trace.h>
81 
82 #else
83 
84 DEFINE_DTRACE_PROBE3(multilist__insert);
85 DEFINE_DTRACE_PROBE3(multilist__remove);
86 
87 #endif /* HAVE_DECLARE_EVENT_CLASS */
88 #endif /* _KERNEL */
89