config/dracut/90zfs: handle cases where hostid(1) returns all zeros
[zfs.git] / include / os / linux / spl / sys / trace.h
blobb148ace6abd35aed2b6672e410489500519de821
1 /*
2 * CDDL HEADER START
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.
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.
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]
19 * CDDL HEADER END
22 #if defined(_KERNEL)
25 * Calls to DTRACE_PROBE* are mapped to standard Linux kernel trace points
26 * when they are available(when HAVE_DECLARE_EVENT_CLASS is defined). The
27 * tracepoint event class definitions are found in the general tracing
28 * header file: include/sys/trace_*.h. See include/sys/trace_vdev.h for
29 * a good example.
31 * If tracepoints are not available, stub functions are generated which can
32 * be traced using kprobes. In this case, the DEFINE_DTRACE_PROBE* macros
33 * are used to provide the stub functions and also the prototypes for
34 * those functions. The mechanism to do this relies on DEFINE_DTRACE_PROBE
35 * macros defined in the general tracing headers(see trace_vdev.h) and
36 * CREATE_TRACE_POINTS being defined only in module/zfs/trace.c. When ZFS
37 * source files include the general tracing headers, e.g.
38 * module/zfs/vdev_removal.c including trace_vdev.h, DTRACE_PROBE calls
39 * are mapped to stub functions calls and prototypes for those calls are
40 * declared via DEFINE_DTRACE_PROBE*. Only module/zfs/trace.c defines
41 * CREATE_TRACE_POINTS. That is followed by includes of all the general
42 * tracing headers thereby defining all stub functions in one place via
43 * the DEFINE_DTRACE_PROBE macros.
45 * When adding new DTRACE_PROBEs to zfs source, both a tracepoint event
46 * class definition and a DEFINE_DTRACE_PROBE definition are needed to
47 * avoid undefined function errors.
50 #if defined(HAVE_DECLARE_EVENT_CLASS)
52 #undef TRACE_SYSTEM
53 #define TRACE_SYSTEM zfs
55 #if !defined(_TRACE_ZFS_H) || defined(TRACE_HEADER_MULTI_READ)
56 #define _TRACE_ZFS_H
58 #include <linux/tracepoint.h>
59 #include <sys/types.h>
62 * DTRACE_PROBE with 0 arguments is not currently available with
63 * tracepoint events
65 #define DTRACE_PROBE(name) \
66 ((void)0)
68 #define DTRACE_PROBE1(name, t1, arg1) \
69 trace_zfs_##name((arg1))
71 #define DTRACE_PROBE2(name, t1, arg1, t2, arg2) \
72 trace_zfs_##name((arg1), (arg2))
74 #define DTRACE_PROBE3(name, t1, arg1, t2, arg2, t3, arg3) \
75 trace_zfs_##name((arg1), (arg2), (arg3))
77 #define DTRACE_PROBE4(name, t1, arg1, t2, arg2, t3, arg3, t4, arg4) \
78 trace_zfs_##name((arg1), (arg2), (arg3), (arg4))
80 #endif /* _TRACE_ZFS_H */
82 #undef TRACE_INCLUDE_PATH
83 #undef TRACE_INCLUDE_FILE
84 #define TRACE_INCLUDE_PATH sys
85 #define TRACE_INCLUDE_FILE trace
86 #include <trace/define_trace.h>
88 #else /* HAVE_DECLARE_EVENT_CLASS */
90 #define DTRACE_PROBE(name) \
91 trace_zfs_##name()
93 #define DTRACE_PROBE1(name, t1, arg1) \
94 trace_zfs_##name((uintptr_t)(arg1))
96 #define DTRACE_PROBE2(name, t1, arg1, t2, arg2) \
97 trace_zfs_##name((uintptr_t)(arg1), (uintptr_t)(arg2))
99 #define DTRACE_PROBE3(name, t1, arg1, t2, arg2, t3, arg3) \
100 trace_zfs_##name((uintptr_t)(arg1), (uintptr_t)(arg2), \
101 (uintptr_t)(arg3))
103 #define DTRACE_PROBE4(name, t1, arg1, t2, arg2, t3, arg3, t4, arg4) \
104 trace_zfs_##name((uintptr_t)(arg1), (uintptr_t)(arg2), \
105 (uintptr_t)(arg3), (uintptr_t)(arg4))
107 #define PROTO_DTRACE_PROBE(name) \
108 noinline void trace_zfs_##name(void)
109 #define PROTO_DTRACE_PROBE1(name) \
110 noinline void trace_zfs_##name(uintptr_t)
111 #define PROTO_DTRACE_PROBE2(name) \
112 noinline void trace_zfs_##name(uintptr_t, uintptr_t)
113 #define PROTO_DTRACE_PROBE3(name) \
114 noinline void trace_zfs_##name(uintptr_t, uintptr_t, \
115 uintptr_t)
116 #define PROTO_DTRACE_PROBE4(name) \
117 noinline void trace_zfs_##name(uintptr_t, uintptr_t, \
118 uintptr_t, uintptr_t)
120 #if defined(CREATE_TRACE_POINTS)
122 #define FUNC_DTRACE_PROBE(name) \
123 PROTO_DTRACE_PROBE(name); \
124 noinline void trace_zfs_##name(void) { } \
125 EXPORT_SYMBOL(trace_zfs_##name)
127 #define FUNC_DTRACE_PROBE1(name) \
128 PROTO_DTRACE_PROBE1(name); \
129 noinline void trace_zfs_##name(uintptr_t arg1) { } \
130 EXPORT_SYMBOL(trace_zfs_##name)
132 #define FUNC_DTRACE_PROBE2(name) \
133 PROTO_DTRACE_PROBE2(name); \
134 noinline void trace_zfs_##name(uintptr_t arg1, \
135 uintptr_t arg2) { } \
136 EXPORT_SYMBOL(trace_zfs_##name)
138 #define FUNC_DTRACE_PROBE3(name) \
139 PROTO_DTRACE_PROBE3(name); \
140 noinline void trace_zfs_##name(uintptr_t arg1, \
141 uintptr_t arg2, uintptr_t arg3) { } \
142 EXPORT_SYMBOL(trace_zfs_##name)
144 #define FUNC_DTRACE_PROBE4(name) \
145 PROTO_DTRACE_PROBE4(name); \
146 noinline void trace_zfs_##name(uintptr_t arg1, \
147 uintptr_t arg2, uintptr_t arg3, uintptr_t arg4) { } \
148 EXPORT_SYMBOL(trace_zfs_##name)
150 #undef DEFINE_DTRACE_PROBE
151 #define DEFINE_DTRACE_PROBE(name) FUNC_DTRACE_PROBE(name)
153 #undef DEFINE_DTRACE_PROBE1
154 #define DEFINE_DTRACE_PROBE1(name) FUNC_DTRACE_PROBE1(name)
156 #undef DEFINE_DTRACE_PROBE2
157 #define DEFINE_DTRACE_PROBE2(name) FUNC_DTRACE_PROBE2(name)
159 #undef DEFINE_DTRACE_PROBE3
160 #define DEFINE_DTRACE_PROBE3(name) FUNC_DTRACE_PROBE3(name)
162 #undef DEFINE_DTRACE_PROBE4
163 #define DEFINE_DTRACE_PROBE4(name) FUNC_DTRACE_PROBE4(name)
165 #else /* CREATE_TRACE_POINTS */
167 #define DEFINE_DTRACE_PROBE(name) PROTO_DTRACE_PROBE(name)
168 #define DEFINE_DTRACE_PROBE1(name) PROTO_DTRACE_PROBE1(name)
169 #define DEFINE_DTRACE_PROBE2(name) PROTO_DTRACE_PROBE2(name)
170 #define DEFINE_DTRACE_PROBE3(name) PROTO_DTRACE_PROBE3(name)
171 #define DEFINE_DTRACE_PROBE4(name) PROTO_DTRACE_PROBE4(name)
173 #endif /* CREATE_TRACE_POINTS */
174 #endif /* HAVE_DECLARE_EVENT_CLASS */
175 #endif /* _KERNEL */