]>
Commit | Line | Data |
---|---|---|
0b39b9f9 PS |
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 | */ | |
0b39b9f9 | 21 | |
cb709642 BL |
22 | #if defined(_KERNEL) |
23 | ||
24 | /* | |
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. | |
30 | * | |
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 follwed by includes of all the general | |
42 | * tracing headers thereby defining all stub functions in one place via | |
43 | * the DEFINE_DTRACE_PROBE macros. | |
44 | * | |
45 | * When adding new DTRACE_PROBEs to zfs source, both a tracepoint event | |
46 | * class defintition and a DEFINE_DTRACE_PROBE definition are needed to | |
47 | * avoid undefined function errors. | |
48 | */ | |
49 | ||
50 | #if defined(HAVE_DECLARE_EVENT_CLASS) | |
0b39b9f9 PS |
51 | |
52 | #undef TRACE_SYSTEM | |
53 | #define TRACE_SYSTEM zfs | |
54 | ||
55 | #if !defined(_TRACE_ZFS_H) || defined(TRACE_HEADER_MULTI_READ) | |
56 | #define _TRACE_ZFS_H | |
57 | ||
58 | #include <linux/tracepoint.h> | |
59 | #include <sys/types.h> | |
49ee64e5 NB |
60 | |
61 | /* | |
62 | * The sys/trace_dbgmsg.h header defines tracepoint events for | |
63 | * dprintf(), dbgmsg(), and SET_ERROR(). | |
64 | */ | |
65 | #define _SYS_TRACE_DBGMSG_INDIRECT | |
66 | #include <sys/trace_dbgmsg.h> | |
67 | #undef _SYS_TRACE_DBGMSG_INDIRECT | |
0b39b9f9 PS |
68 | |
69 | /* | |
cb709642 BL |
70 | * DTRACE_PROBE with 0 arguments is not currently available with |
71 | * tracepoint events | |
0b39b9f9 | 72 | */ |
cb709642 BL |
73 | #define DTRACE_PROBE(name) \ |
74 | ((void)0) | |
75 | ||
0b39b9f9 PS |
76 | #define DTRACE_PROBE1(name, t1, arg1) \ |
77 | trace_zfs_##name((arg1)) | |
78 | ||
0b39b9f9 PS |
79 | #define DTRACE_PROBE2(name, t1, arg1, t2, arg2) \ |
80 | trace_zfs_##name((arg1), (arg2)) | |
81 | ||
0b39b9f9 PS |
82 | #define DTRACE_PROBE3(name, t1, arg1, t2, arg2, t3, arg3) \ |
83 | trace_zfs_##name((arg1), (arg2), (arg3)) | |
84 | ||
0b39b9f9 PS |
85 | #define DTRACE_PROBE4(name, t1, arg1, t2, arg2, t3, arg3, t4, arg4) \ |
86 | trace_zfs_##name((arg1), (arg2), (arg3), (arg4)) | |
87 | ||
0b39b9f9 PS |
88 | #endif /* _TRACE_ZFS_H */ |
89 | ||
90 | #undef TRACE_INCLUDE_PATH | |
49ee64e5 | 91 | #undef TRACE_INCLUDE_FILE |
0b39b9f9 PS |
92 | #define TRACE_INCLUDE_PATH sys |
93 | #define TRACE_INCLUDE_FILE trace | |
94 | #include <trace/define_trace.h> | |
95 | ||
cb709642 BL |
96 | #else /* HAVE_DECLARE_EVENT_CLASS */ |
97 | ||
98 | #define DTRACE_PROBE(name) \ | |
99 | trace_zfs_##name() | |
100 | ||
101 | #define DTRACE_PROBE1(name, t1, arg1) \ | |
102 | trace_zfs_##name((uintptr_t)(arg1)) | |
103 | ||
104 | #define DTRACE_PROBE2(name, t1, arg1, t2, arg2) \ | |
105 | trace_zfs_##name((uintptr_t)(arg1), (uintptr_t)(arg2)) | |
106 | ||
107 | #define DTRACE_PROBE3(name, t1, arg1, t2, arg2, t3, arg3) \ | |
108 | trace_zfs_##name((uintptr_t)(arg1), (uintptr_t)(arg2), \ | |
109 | (uintptr_t)(arg3)) | |
110 | ||
111 | #define DTRACE_PROBE4(name, t1, arg1, t2, arg2, t3, arg3, t4, arg4) \ | |
112 | trace_zfs_##name((uintptr_t)(arg1), (uintptr_t)(arg2), \ | |
113 | (uintptr_t)(arg3), (uintptr_t)(arg4)) | |
114 | ||
115 | #if defined(CREATE_TRACE_POINTS) | |
116 | ||
117 | #define FUNC_DTRACE_PROBE(name) \ | |
118 | noinline void trace_zfs_##name(void) { } \ | |
119 | EXPORT_SYMBOL(trace_zfs_##name) | |
120 | ||
121 | #define FUNC_DTRACE_PROBE1(name) \ | |
122 | noinline void trace_zfs_##name(uintptr_t arg1) { } \ | |
123 | EXPORT_SYMBOL(trace_zfs_##name) | |
124 | ||
125 | #define FUNC_DTRACE_PROBE2(name) \ | |
126 | noinline void trace_zfs_##name(uintptr_t arg1, \ | |
127 | uintptr_t arg2) { } \ | |
128 | EXPORT_SYMBOL(trace_zfs_##name) | |
129 | ||
130 | #define FUNC_DTRACE_PROBE3(name) \ | |
131 | noinline void trace_zfs_##name(uintptr_t arg1, \ | |
132 | uintptr_t arg2, uintptr_t arg3) { } \ | |
133 | EXPORT_SYMBOL(trace_zfs_##name) | |
134 | ||
135 | #define FUNC_DTRACE_PROBE4(name) \ | |
136 | noinline void trace_zfs_##name(uintptr_t arg1, \ | |
137 | uintptr_t arg2, uintptr_t arg3, uintptr_t arg4) { } \ | |
138 | EXPORT_SYMBOL(trace_zfs_##name) | |
139 | ||
140 | #undef DEFINE_DTRACE_PROBE | |
141 | #define DEFINE_DTRACE_PROBE(name) FUNC_DTRACE_PROBE(name) | |
142 | ||
143 | #undef DEFINE_DTRACE_PROBE1 | |
144 | #define DEFINE_DTRACE_PROBE1(name) FUNC_DTRACE_PROBE1(name) | |
145 | ||
146 | #undef DEFINE_DTRACE_PROBE2 | |
147 | #define DEFINE_DTRACE_PROBE2(name) FUNC_DTRACE_PROBE2(name) | |
148 | ||
149 | #undef DEFINE_DTRACE_PROBE3 | |
150 | #define DEFINE_DTRACE_PROBE3(name) FUNC_DTRACE_PROBE3(name) | |
151 | ||
152 | #undef DEFINE_DTRACE_PROBE4 | |
153 | #define DEFINE_DTRACE_PROBE4(name) FUNC_DTRACE_PROBE4(name) | |
154 | ||
155 | #else /* CREATE_TRACE_POINTS */ | |
156 | ||
157 | #define PROTO_DTRACE_PROBE(name) \ | |
158 | noinline void trace_zfs_##name(void) | |
159 | #define PROTO_DTRACE_PROBE1(name) \ | |
160 | noinline void trace_zfs_##name(uintptr_t) | |
161 | #define PROTO_DTRACE_PROBE2(name) \ | |
162 | noinline void trace_zfs_##name(uintptr_t, uintptr_t) | |
163 | #define PROTO_DTRACE_PROBE3(name) \ | |
164 | noinline void trace_zfs_##name(uintptr_t, uintptr_t, \ | |
165 | uintptr_t) | |
166 | #define PROTO_DTRACE_PROBE4(name) \ | |
167 | noinline void trace_zfs_##name(uintptr_t, uintptr_t, \ | |
168 | uintptr_t, uintptr_t) | |
169 | ||
170 | #define DEFINE_DTRACE_PROBE(name) PROTO_DTRACE_PROBE(name) | |
171 | #define DEFINE_DTRACE_PROBE1(name) PROTO_DTRACE_PROBE1(name) | |
172 | #define DEFINE_DTRACE_PROBE2(name) PROTO_DTRACE_PROBE2(name) | |
173 | #define DEFINE_DTRACE_PROBE3(name) PROTO_DTRACE_PROBE3(name) | |
174 | #define DEFINE_DTRACE_PROBE4(name) PROTO_DTRACE_PROBE4(name) | |
175 | ||
176 | #endif /* CREATE_TRACE_POINTS */ | |
177 | ||
178 | /* | |
179 | * The sys/trace_dbgmsg.h header defines tracepoint events for | |
180 | * dprintf(), dbgmsg(), and SET_ERROR(). | |
181 | */ | |
182 | #define _SYS_TRACE_DBGMSG_INDIRECT | |
183 | #include <sys/trace_dbgmsg.h> | |
184 | #undef _SYS_TRACE_DBGMSG_INDIRECT | |
185 | ||
186 | #endif /* HAVE_DECLARE_EVENT_CLASS */ | |
187 | #endif /* _KERNEL */ |