]>
Commit | Line | Data |
---|---|---|
2d21ac55 A |
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, Version 1.0 only | |
6 | * (the "License"). You may not use this file except in compliance | |
7 | * with the License. | |
8 | * | |
9 | * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE | |
10 | * or http://www.opensolaris.org/os/licensing. | |
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 1997-2003 Sun Microsystems, Inc. All rights reserved. | |
24 | * Use is subject to license terms. | |
25 | */ | |
26 | ||
27 | #ifndef _SYS_LOCKSTAT_H | |
28 | #define _SYS_LOCKSTAT_H | |
29 | #endif | |
30 | ||
31 | /* #pragma ident "@(#)lockstat.h 1.6 05/06/08 SMI" */ | |
32 | ||
33 | #ifdef __cplusplus | |
34 | extern "C" { | |
35 | #endif | |
36 | ||
37 | /* | |
38 | * Spin locks - we have less variants | |
39 | */ | |
40 | #define LS_LCK_SPIN_LOCK_ACQUIRE 0 | |
41 | #define LS_LCK_SPIN_LOCK_SPIN 1 | |
42 | #define LS_LCK_SPIN_UNLOCK_RELEASE 2 | |
43 | /* | |
44 | * Mutexes can also have interlock-spin events, which are | |
45 | * unique to our lock implementation. | |
46 | */ | |
47 | #define LS_LCK_MTX_LOCK_ACQUIRE 3 | |
48 | #define LS_LCK_MTX_LOCK_BLOCK 5 | |
49 | #define LS_LCK_MTX_LOCK_SPIN 6 | |
50 | #define LS_LCK_MTX_LOCK_ILK_SPIN 7 | |
51 | #define LS_LCK_MTX_TRY_LOCK_ACQUIRE 8 | |
52 | #define LS_LCK_MTX_TRY_SPIN_LOCK_ACQUIRE 9 | |
53 | #define LS_LCK_MTX_UNLOCK_RELEASE 10 | |
54 | /* | |
55 | * Although theoretically deprecated, there's still lots of uses of mutex_lock() style locks. | |
56 | * Block and spin events share code with lck_mtx_lock() and friends, so we only need events | |
57 | * for the acquire and release events. | |
58 | */ | |
59 | #define LS_MUTEX_LOCK_ACQUIRE 11 | |
60 | #define LS_MUTEX_TRY_LOCK_ACQUIRE 12 | |
61 | #define LS_MUTEX_TRY_SPIN_ACQUIRE 13 | |
62 | #define LS_MUTEX_UNLOCK_RELEASE 14 | |
63 | #define LS_MUTEX_LOCK_SPIN_ACQUIRE 15 | |
64 | ||
65 | #define LS_MUTEX_CONVERT_SPIN_ACQUIRE 16 | |
66 | /* | |
67 | * Provide a parallel set for indirect mutexes | |
68 | */ | |
69 | #define LS_LCK_MTX_EXT_LOCK_ACQUIRE 17 | |
70 | #define LS_LCK_MTX_EXT_LOCK_BLOCK 18 | |
71 | #define LS_LCK_MTX_EXT_LOCK_SPIN 19 | |
72 | #define LS_LCK_MTX_EXT_LOCK_ILK_SPIN 20 | |
73 | #define LS_LCK_MTX_TRY_EXT_LOCK_ACQUIRE 21 | |
74 | #define LS_LCK_MTX_EXT_UNLOCK_RELEASE 22 | |
75 | /* | |
76 | * Our reader-writer locks support a blocking upgrade primitive, as | |
77 | * well as the possibility of spinning on the interlock. | |
78 | */ | |
79 | #define LS_LCK_RW_LOCK_SHARED_ACQUIRE 23 | |
80 | #define LS_LCK_RW_LOCK_SHARED_BLOCK 24 | |
81 | #define LS_LCK_RW_LOCK_SHARED_SPIN 25 | |
82 | ||
83 | #define LS_LCK_RW_LOCK_EXCL_ACQUIRE 26 | |
84 | #define LS_LCK_RW_LOCK_EXCL_BLOCK 27 | |
85 | #define LS_LCK_RW_LOCK_EXCL_SPIN 28 | |
86 | ||
87 | #define LS_LCK_RW_DONE_RELEASE 29 | |
88 | ||
89 | #define LS_LCK_RW_TRY_LOCK_SHARED_ACQUIRE 30 | |
90 | #define LS_LCK_RW_TRY_LOCK_SHARED_SPIN 31 | |
91 | ||
92 | #define LS_LCK_RW_TRY_LOCK_EXCL_ACQUIRE 32 | |
93 | #define LS_LCK_RW_TRY_LOCK_EXCL_ILK_SPIN 33 | |
94 | ||
95 | #define LS_LCK_RW_LOCK_SHARED_TO_EXCL_UPGRADE 34 | |
96 | #define LS_LCK_RW_LOCK_SHARED_TO_EXCL_SPIN 35 | |
97 | #define LS_LCK_RW_LOCK_SHARED_TO_EXCL_BLOCK 36 | |
98 | ||
99 | #define LS_LCK_RW_LOCK_EXCL_TO_SHARED_DOWNGRADE 37 | |
100 | #define LS_LCK_RW_LOCK_EXCL_TO_SHARED_ILK_SPIN 38 | |
101 | ||
102 | #define LS_NPROBES 39 | |
103 | ||
104 | /* | |
105 | * Name the various locking functions... | |
106 | */ | |
107 | #define LS_LCK_MTX_LOCK "lck_mtx_lock" | |
108 | #define LS_LCK_MTX_SPIN_LOCK "lck_mtx_spin_lock" | |
109 | #define LS_LCK_MTX_UNLOCK "lck_mtx_unlock" | |
110 | #define LS_LCK_MTX_TRY_LOCK "lck_mtx_try_lock" | |
111 | #define LS_LCK_MTX_TRY_SPIN_LOCK "lck_mtx_try_spin_lock" | |
112 | #define LS_LCK_MTX_EXT_LOCK "lck_mtx_ext_lock" | |
113 | #define LS_LCK_MTX_EXT_UNLOCK "lck_mtx_ext_unlock" | |
114 | #define LS_LCK_MTX_EXT_TRY_LOCK "lck_mtx_ext_try_lock" | |
115 | #define LS_MUTEX_CONVERT_SPIN "mutex_convert_spin" | |
116 | #define LS_MUTEX_LOCK "mutex_lock" | |
117 | #define LS_MUTEX_UNLOCK "mutex_unlock" | |
118 | #define LS_MUTEX_TRY_LOCK "mutex_try_lock" | |
119 | #define LS_MUTEX_TRY_SPIN "mutex_try_spin" | |
120 | #define LS_MUTEX_LOCK_SPIN "mutex_lock_spin" | |
121 | #define LS_LCK_SPIN_LOCK "lck_spin_lock" | |
122 | #define LS_LCK_SPIN_TRY_LOCK "lck_spin_try_lock" | |
123 | #define LS_LCK_SPIN_UNLOCK "lck_spin_unlock" | |
124 | #define LS_LCK_RW_LOCK_SHARED "lck_rw_lock_shared" | |
125 | #define LS_LCK_RW_LOCK_EXCL "lck_rw_lock_exclusive" | |
126 | #define LS_LCK_RW_DONE "lck_rw_done" | |
127 | #define LS_LCK_RW_TRY_LOCK_EXCL "lck_rw_try_lock_exclusive" | |
128 | #define LS_LCK_RW_TRY_LOCK_SHARED "lck_rw_try_lock_shared" | |
129 | #define LS_LCK_RW_LOCK_SHARED_TO_EXCL "lck_rw_shared_to_exclusive" | |
130 | #define LS_LCK_RW_LOCK_EXCL_TO_SHARED "lck_rw_exclusive_to_shared" | |
131 | ||
132 | #define LS_ACQUIRE "acquire" | |
133 | #define LS_RELEASE "release" | |
134 | #define LS_SPIN "spin" | |
135 | #define LS_BLOCK "block" | |
136 | #define LS_UPGRADE "upgrade" | |
137 | #define LS_DOWNGRADE "downgrade" | |
138 | ||
139 | #define LS_TYPE_ADAPTIVE "adaptive" | |
140 | #define LS_TYPE_SPIN "spin" | |
141 | #define LS_TYPE_ILK "interlock" /* OS X only */ | |
142 | #define LS_TYPE_THREAD "thread" /* Solaris only */ | |
143 | #define LS_TYPE_RW "rw" | |
144 | #define LS_TYPE_RWUPGRADE "rwupgrade" /* OS X only */ | |
145 | ||
146 | #define LSA_ACQUIRE (LS_TYPE_ADAPTIVE "-" LS_ACQUIRE) | |
147 | #define LSA_RELEASE (LS_TYPE_ADAPTIVE "-" LS_RELEASE) | |
148 | #define LSA_SPIN (LS_TYPE_ADAPTIVE "-" LS_SPIN) | |
149 | #define LSA_BLOCK (LS_TYPE_ADAPTIVE "-" LS_BLOCK) | |
150 | #define LSA_ILK_SPIN (LS_TYPE_ILK "-" LS_SPIN) | |
151 | #define LSS_ACQUIRE (LS_TYPE_SPIN "-" LS_ACQUIRE) | |
152 | #define LSS_RELEASE (LS_TYPE_SPIN "-" LS_RELEASE) | |
153 | #define LSS_SPIN (LS_TYPE_SPIN "-" LS_SPIN) | |
154 | #define LSR_ACQUIRE (LS_TYPE_RW "-" LS_ACQUIRE) | |
155 | #define LSR_RELEASE (LS_TYPE_RW "-" LS_RELEASE) | |
156 | #define LSR_BLOCK (LS_TYPE_RW "-" LS_BLOCK) | |
157 | #define LSR_SPIN (LS_TYPE_RW "-" LS_SPIN) | |
158 | #define LSR_UPGRADE (LS_TYPE_RW "-" LS_UPGRADE) | |
159 | #define LSR_UPGRADE_BLOCK (LS_TYPE_RWUPGRADE "-" LS_BLOCK) | |
160 | #define LSR_DOWNGRADE (LS_TYPE_RW "-" LS_DOWNGRADE) | |
161 | #define LST_SPIN (LS_TYPE_THREAD "-" LS_SPIN) | |
162 | ||
163 | #ifndef _ASM | |
164 | ||
165 | #include <stdint.h> | |
166 | #ifdef KERNEL | |
167 | ||
168 | #ifndef _KERNEL | |
169 | #define _KERNEL /* Solaris vs. Darwin */ | |
170 | #endif | |
171 | ||
172 | /* | |
173 | * Platform-independent kernel support for the lockstat driver. | |
174 | */ | |
175 | #if defined(NEED_DTRACE_DEFS) | |
176 | typedef uint32_t dtrace_id_t; /* probe identifier - also in dtrace.h! */ | |
177 | typedef uint64_t u_longlong_t; /* also in dtrace.h! */ | |
178 | #endif | |
179 | ||
180 | extern dtrace_id_t lockstat_probemap[LS_NPROBES]; | |
181 | extern void (*lockstat_probe)(dtrace_id_t, uint64_t, uint64_t, | |
182 | uint64_t, uint64_t, uint64_t); | |
183 | ||
184 | ||
185 | #ifdef _KERNEL | |
186 | ||
187 | #if CONFIG_DTRACE | |
188 | extern int lockstat_depth(void); | |
189 | extern void lockstat_hot_patch(boolean_t); | |
2d21ac55 A |
190 | |
191 | /* | |
192 | * Macros to record lockstat probes. | |
193 | */ | |
194 | #define LOCKSTAT_RECORD4(probe, lp, arg0, arg1, arg2, arg3) \ | |
195 | { \ | |
196 | dtrace_id_t id; \ | |
197 | if ((id = lockstat_probemap[(probe)])) { \ | |
198 | (*lockstat_probe)(id, (uintptr_t)(lp), (arg0), \ | |
199 | (arg1), (arg2), (arg3)); \ | |
200 | } \ | |
201 | } | |
202 | ||
203 | #define LOCKSTAT_RECORD2(probe, lp, arg1, arg2) \ | |
204 | LOCKSTAT_RECORD4(probe, lp, arg1, arg2, 0, 0) | |
205 | ||
206 | #define LOCKSTAT_RECORD(probe, lp, arg) \ | |
207 | LOCKSTAT_RECORD4(probe, lp, arg, 0, 0, 0) | |
208 | ||
209 | #define LOCKSTAT_RECORD0(probe, lp) \ | |
210 | LOCKSTAT_RECORD4(probe, lp, 0, 0, 0, 0) | |
211 | #else | |
212 | /* No Lockstat provider */ | |
213 | ||
214 | #define LOCKSTAT_RECORD() | |
215 | #define LOCKSTAT_RECORD0() | |
216 | #define LOCKSTAT_RECORD2() | |
217 | #define LOCKSTAT_RECORD4() | |
218 | ||
219 | #endif /* !CONFIG_DTRACE */ | |
220 | ||
221 | #endif /* _KERNEL */ | |
222 | ||
223 | #endif /* _ASM */ | |
224 | ||
225 | #ifdef __cplusplus | |
226 | } | |
227 | #endif | |
228 | ||
229 | #endif /* _SYS_LOCKSTAT_H */ | |
230 |