1eda14cbcSMatt Macy /*
2eda14cbcSMatt Macy  * CDDL HEADER START
3eda14cbcSMatt Macy  *
4eda14cbcSMatt Macy  * The contents of this file are subject to the terms of the
5eda14cbcSMatt Macy  * Common Development and Distribution License (the "License").
6eda14cbcSMatt Macy  * You may not use this file except in compliance with the License.
7eda14cbcSMatt Macy  *
8eda14cbcSMatt Macy  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9*271171e0SMartin Matuska  * or https://opensource.org/licenses/CDDL-1.0.
10eda14cbcSMatt Macy  * See the License for the specific language governing permissions
11eda14cbcSMatt Macy  * and limitations under the License.
12eda14cbcSMatt Macy  *
13eda14cbcSMatt Macy  * When distributing Covered Code, include this CDDL HEADER in each
14eda14cbcSMatt Macy  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15eda14cbcSMatt Macy  * If applicable, add the following below this CDDL HEADER, with the
16eda14cbcSMatt Macy  * fields enclosed by brackets "[]" replaced with your own identifying
17eda14cbcSMatt Macy  * information: Portions Copyright [yyyy] [name of copyright owner]
18eda14cbcSMatt Macy  *
19eda14cbcSMatt Macy  * CDDL HEADER END
20eda14cbcSMatt Macy  */
21eda14cbcSMatt Macy 
22eda14cbcSMatt Macy #if defined(_KERNEL)
23eda14cbcSMatt Macy #if defined(HAVE_DECLARE_EVENT_CLASS)
24eda14cbcSMatt Macy 
25eda14cbcSMatt Macy #undef TRACE_SYSTEM
26eda14cbcSMatt Macy #define	TRACE_SYSTEM zfs
27eda14cbcSMatt Macy 
28eda14cbcSMatt Macy #undef TRACE_SYSTEM_VAR
29eda14cbcSMatt Macy #define	TRACE_SYSTEM_VAR zfs_zrlock
30eda14cbcSMatt Macy 
31eda14cbcSMatt Macy #if !defined(_TRACE_ZRLOCK_H) || defined(TRACE_HEADER_MULTI_READ)
32eda14cbcSMatt Macy #define	_TRACE_ZRLOCK_H
33eda14cbcSMatt Macy 
34eda14cbcSMatt Macy #include <linux/tracepoint.h>
35eda14cbcSMatt Macy #include <sys/types.h>
36eda14cbcSMatt Macy 
37eda14cbcSMatt Macy /*
38eda14cbcSMatt Macy  * Generic support for two argument tracepoints of the form:
39eda14cbcSMatt Macy  *
40eda14cbcSMatt Macy  * DTRACE_PROBE2(...,
41eda14cbcSMatt Macy  *     zrlock_t *, ...,
42eda14cbcSMatt Macy  *     uint32_t, ...);
43eda14cbcSMatt Macy  */
44eda14cbcSMatt Macy /* BEGIN CSTYLED */
45eda14cbcSMatt Macy DECLARE_EVENT_CLASS(zfs_zrlock_class,
46eda14cbcSMatt Macy 	TP_PROTO(zrlock_t *zrl, kthread_t *owner, uint32_t n),
47eda14cbcSMatt Macy 	TP_ARGS(zrl, owner, n),
48eda14cbcSMatt Macy 	TP_STRUCT__entry(
49eda14cbcSMatt Macy 	    __field(int32_t,		refcount)
50eda14cbcSMatt Macy #ifdef	ZFS_DEBUG
51eda14cbcSMatt Macy 	    __field(pid_t,		owner_pid)
52eda14cbcSMatt Macy 	    __field(const char *,	caller)
53eda14cbcSMatt Macy #endif
54eda14cbcSMatt Macy 	    __field(uint32_t,		n)
55eda14cbcSMatt Macy 	),
56eda14cbcSMatt Macy 	TP_fast_assign(
57eda14cbcSMatt Macy 	    __entry->refcount	= zrl->zr_refcount;
58eda14cbcSMatt Macy #ifdef	ZFS_DEBUG
59eda14cbcSMatt Macy 	    __entry->owner_pid	= owner ? owner->pid : 0;
60eda14cbcSMatt Macy 	    __entry->caller = zrl->zr_caller ? zrl->zr_caller : "(null)";
61eda14cbcSMatt Macy #endif
62eda14cbcSMatt Macy 	    __entry->n		= n;
63eda14cbcSMatt Macy 	),
64eda14cbcSMatt Macy #ifdef	ZFS_DEBUG
65eda14cbcSMatt Macy 	TP_printk("zrl { refcount %d owner_pid %d caller %s } n %u",
66eda14cbcSMatt Macy 	    __entry->refcount, __entry->owner_pid, __entry->caller,
67eda14cbcSMatt Macy 	    __entry->n)
68eda14cbcSMatt Macy #else
69eda14cbcSMatt Macy 	TP_printk("zrl { refcount %d } n %u",
70eda14cbcSMatt Macy 	    __entry->refcount, __entry->n)
71eda14cbcSMatt Macy #endif
72eda14cbcSMatt Macy );
73c03c5b1cSMartin Matuska /* END CSTYLED */
74eda14cbcSMatt Macy 
75eda14cbcSMatt Macy #define	DEFINE_ZRLOCK_EVENT(name) \
76eda14cbcSMatt Macy DEFINE_EVENT(zfs_zrlock_class, name, \
77eda14cbcSMatt Macy     TP_PROTO(zrlock_t *zrl, kthread_t *owner, uint32_t n), \
78eda14cbcSMatt Macy     TP_ARGS(zrl, owner, n))
79eda14cbcSMatt Macy DEFINE_ZRLOCK_EVENT(zfs_zrlock__reentry);
80eda14cbcSMatt Macy 
81eda14cbcSMatt Macy #endif /* _TRACE_ZRLOCK_H */
82eda14cbcSMatt Macy 
83eda14cbcSMatt Macy #undef TRACE_INCLUDE_PATH
84eda14cbcSMatt Macy #undef TRACE_INCLUDE_FILE
85eda14cbcSMatt Macy #define	TRACE_INCLUDE_PATH sys
86eda14cbcSMatt Macy #define	TRACE_INCLUDE_FILE trace_zrlock
87eda14cbcSMatt Macy #include <trace/define_trace.h>
88eda14cbcSMatt Macy 
89eda14cbcSMatt Macy #else
90eda14cbcSMatt Macy 
91eda14cbcSMatt Macy DEFINE_DTRACE_PROBE3(zrlock__reentry);
92eda14cbcSMatt Macy 
93eda14cbcSMatt Macy #endif /* HAVE_DECLARE_EVENT_CLASS */
94eda14cbcSMatt Macy #endif /* _KERNEL */
95