Skip to content

Commit 248c7ed

Browse files
robnbehlendorf
authored andcommitted
libspl: move DTRACE_PROBE macros from zfs_context.h
Sponsored-by: https://despairlabs.com/sponsor/ Reviewed-by: Brian Behlendorf <[email protected]> Signed-off-by: Rob Norris <[email protected]> Closes #17861
1 parent 03b2e5c commit 248c7ed

File tree

3 files changed

+75
-41
lines changed

3 files changed

+75
-41
lines changed

include/sys/zfs_context.h

Lines changed: 1 addition & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,7 @@ extern "C" {
129129
#include <sys/misc.h>
130130
#include <sys/random.h>
131131
#include <sys/callb.h>
132+
#include <sys/trace.h>
132133

133134
#include <sys/zfs_context_os.h>
134135

@@ -140,47 +141,6 @@ extern "C" {
140141
#define likely(x) __builtin_expect((x), 1)
141142
#define unlikely(x) __builtin_expect((x), 0)
142143

143-
/*
144-
* DTrace SDT probes have different signatures in userland than they do in
145-
* the kernel. If they're being used in kernel code, re-define them out of
146-
* existence for their counterparts in libzpool.
147-
*
148-
* Here's an example of how to use the set-error probes in userland:
149-
* zfs$target:::set-error /arg0 == EBUSY/ {stack();}
150-
*
151-
* Here's an example of how to use DTRACE_PROBE probes in userland:
152-
* If there is a probe declared as follows:
153-
* DTRACE_PROBE2(zfs__probe_name, uint64_t, blkid, dnode_t *, dn);
154-
* Then you can use it as follows:
155-
* zfs$target:::probe2 /copyinstr(arg0) == "zfs__probe_name"/
156-
* {printf("%u %p\n", arg1, arg2);}
157-
*/
158-
159-
#ifdef DTRACE_PROBE
160-
#undef DTRACE_PROBE
161-
#endif /* DTRACE_PROBE */
162-
#define DTRACE_PROBE(a)
163-
164-
#ifdef DTRACE_PROBE1
165-
#undef DTRACE_PROBE1
166-
#endif /* DTRACE_PROBE1 */
167-
#define DTRACE_PROBE1(a, b, c)
168-
169-
#ifdef DTRACE_PROBE2
170-
#undef DTRACE_PROBE2
171-
#endif /* DTRACE_PROBE2 */
172-
#define DTRACE_PROBE2(a, b, c, d, e)
173-
174-
#ifdef DTRACE_PROBE3
175-
#undef DTRACE_PROBE3
176-
#endif /* DTRACE_PROBE3 */
177-
#define DTRACE_PROBE3(a, b, c, d, e, f, g)
178-
179-
#ifdef DTRACE_PROBE4
180-
#undef DTRACE_PROBE4
181-
#endif /* DTRACE_PROBE4 */
182-
#define DTRACE_PROBE4(a, b, c, d, e, f, g, h, i)
183-
184144
#ifdef __FreeBSD__
185145
typedef off_t loff_t;
186146
#endif

lib/libspl/include/Makefile.am

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ libspl_sys_HEADERS = \
6767
%D%/sys/taskq.h \
6868
%D%/sys/time.h \
6969
%D%/sys/timer.h \
70+
%D%/sys/trace.h \
7071
%D%/sys/trace_spl.h \
7172
%D%/sys/tsd.h \
7273
%D%/sys/tunables.h \

lib/libspl/include/sys/trace.h

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
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+
* Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
24+
* Copyright 2011 Nexenta Systems, Inc. All rights reserved.
25+
* Copyright (c) 2012, 2018 by Delphix. All rights reserved.
26+
* Copyright (c) 2012, Joyent, Inc. All rights reserved.
27+
*/
28+
29+
#ifndef _SYS_TRACE_H
30+
#define _SYS_TRACE_H
31+
32+
/*
33+
* DTrace SDT probes have different signatures in userland than they do in
34+
* the kernel. If they're being used in kernel code, re-define them out of
35+
* existence for their counterparts in libzpool.
36+
*
37+
* Here's an example of how to use the set-error probes in userland:
38+
* zfs$target:::set-error /arg0 == EBUSY/ {stack();}
39+
*
40+
* Here's an example of how to use DTRACE_PROBE probes in userland:
41+
* If there is a probe declared as follows:
42+
* DTRACE_PROBE2(zfs__probe_name, uint64_t, blkid, dnode_t *, dn);
43+
* Then you can use it as follows:
44+
* zfs$target:::probe2 /copyinstr(arg0) == "zfs__probe_name"/
45+
* {printf("%u %p\n", arg1, arg2);}
46+
*/
47+
48+
#ifdef DTRACE_PROBE
49+
#undef DTRACE_PROBE
50+
#endif /* DTRACE_PROBE */
51+
#define DTRACE_PROBE(a)
52+
53+
#ifdef DTRACE_PROBE1
54+
#undef DTRACE_PROBE1
55+
#endif /* DTRACE_PROBE1 */
56+
#define DTRACE_PROBE1(a, b, c)
57+
58+
#ifdef DTRACE_PROBE2
59+
#undef DTRACE_PROBE2
60+
#endif /* DTRACE_PROBE2 */
61+
#define DTRACE_PROBE2(a, b, c, d, e)
62+
63+
#ifdef DTRACE_PROBE3
64+
#undef DTRACE_PROBE3
65+
#endif /* DTRACE_PROBE3 */
66+
#define DTRACE_PROBE3(a, b, c, d, e, f, g)
67+
68+
#ifdef DTRACE_PROBE4
69+
#undef DTRACE_PROBE4
70+
#endif /* DTRACE_PROBE4 */
71+
#define DTRACE_PROBE4(a, b, c, d, e, f, g, h, i)
72+
73+
#endif /* _SYS_TRACE_H */

0 commit comments

Comments
 (0)