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
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.
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]
23 * Copyright 1997-2003 Sun Microsystems, Inc. All rights reserved.
24 * Use is subject to license terms.
27 #ifndef _SYS_LOCKSTAT_H
28 #define _SYS_LOCKSTAT_H
31 /* #pragma ident "@(#)lockstat.h 1.6 05/06/08 SMI" */
38 * Spin locks - we have less variants
40 #define LS_LCK_SPIN_LOCK_ACQUIRE 0
41 #define LS_LCK_SPIN_LOCK_SPIN 1
42 #define LS_LCK_SPIN_UNLOCK_RELEASE 2
44 * Mutexes can also have interlock-spin events, which are
45 * unique to our lock implementation.
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
55 #define LS_LCK_MTX_LOCK_SPIN_ACQUIRE 39
57 * Provide a parallel set for indirect mutexes
59 #define LS_LCK_MTX_EXT_LOCK_ACQUIRE 17
60 #define LS_LCK_MTX_EXT_LOCK_BLOCK 18
61 #define LS_LCK_MTX_EXT_LOCK_SPIN 19
62 #define LS_LCK_MTX_EXT_LOCK_ILK_SPIN 20
63 #define LS_LCK_MTX_TRY_EXT_LOCK_ACQUIRE 21
64 #define LS_LCK_MTX_EXT_UNLOCK_RELEASE 22
66 * Our reader-writer locks support a blocking upgrade primitive, as
67 * well as the possibility of spinning on the interlock.
69 #define LS_LCK_RW_LOCK_SHARED_ACQUIRE 23
70 #define LS_LCK_RW_LOCK_SHARED_BLOCK 24
71 #define LS_LCK_RW_LOCK_SHARED_SPIN 25
73 #define LS_LCK_RW_LOCK_EXCL_ACQUIRE 26
74 #define LS_LCK_RW_LOCK_EXCL_BLOCK 27
75 #define LS_LCK_RW_LOCK_EXCL_SPIN 28
77 #define LS_LCK_RW_DONE_RELEASE 29
79 #define LS_LCK_RW_TRY_LOCK_SHARED_ACQUIRE 30
80 #define LS_LCK_RW_TRY_LOCK_SHARED_SPIN 31
82 #define LS_LCK_RW_TRY_LOCK_EXCL_ACQUIRE 32
83 #define LS_LCK_RW_TRY_LOCK_EXCL_ILK_SPIN 33
85 #define LS_LCK_RW_LOCK_SHARED_TO_EXCL_UPGRADE 34
86 #define LS_LCK_RW_LOCK_SHARED_TO_EXCL_SPIN 35
87 #define LS_LCK_RW_LOCK_SHARED_TO_EXCL_BLOCK 36
89 #define LS_LCK_RW_LOCK_EXCL_TO_SHARED_DOWNGRADE 37
90 #define LS_LCK_RW_LOCK_EXCL_TO_SHARED_ILK_SPIN 38
93 #define LS_LCK_INVALID LS_NPROBES
96 * Name the various locking functions...
98 #define LS_LCK_MTX_LOCK "lck_mtx_lock"
99 #define LS_LCK_MTX_SPIN_LOCK "lck_mtx_spin_lock"
100 #define LS_LCK_MTX_UNLOCK "lck_mtx_unlock"
101 #define LS_LCK_MTX_TRY_LOCK "lck_mtx_try_lock"
102 #define LS_LCK_MTX_TRY_SPIN_LOCK "lck_mtx_try_spin_lock"
103 #define LS_LCK_MTX_EXT_LOCK "lck_mtx_ext_lock"
104 #define LS_LCK_MTX_EXT_UNLOCK "lck_mtx_ext_unlock"
105 #define LS_LCK_MTX_EXT_TRY_LOCK "lck_mtx_ext_try_lock"
106 #define LS_LCK_MTX_LOCK_SPIN_LOCK "lck_mtx_lock_spin"
108 #define LS_LCK_SPIN_LOCK "lck_spin_lock"
109 #define LS_LCK_SPIN_TRY_LOCK "lck_spin_try_lock"
110 #define LS_LCK_SPIN_UNLOCK "lck_spin_unlock"
111 #define LS_LCK_RW_LOCK_SHARED "lck_rw_lock_shared"
112 #define LS_LCK_RW_LOCK_EXCL "lck_rw_lock_exclusive"
113 #define LS_LCK_RW_DONE "lck_rw_done"
114 #define LS_LCK_RW_TRY_LOCK_EXCL "lck_rw_try_lock_exclusive"
115 #define LS_LCK_RW_TRY_LOCK_SHARED "lck_rw_try_lock_shared"
116 #define LS_LCK_RW_LOCK_SHARED_TO_EXCL "lck_rw_shared_to_exclusive"
117 #define LS_LCK_RW_LOCK_EXCL_TO_SHARED "lck_rw_exclusive_to_shared"
119 #define LS_ACQUIRE "acquire"
120 #define LS_RELEASE "release"
121 #define LS_SPIN "spin"
122 #define LS_BLOCK "block"
123 #define LS_UPGRADE "upgrade"
124 #define LS_DOWNGRADE "downgrade"
126 #define LS_TYPE_ADAPTIVE "adaptive"
127 #define LS_TYPE_SPIN "spin"
128 #define LS_TYPE_ILK "interlock" /* OS X only */
129 #define LS_TYPE_THREAD "thread" /* Solaris only */
130 #define LS_TYPE_RW "rw"
131 #define LS_TYPE_RWUPGRADE "rwupgrade" /* OS X only */
133 #define LSA_ACQUIRE (LS_TYPE_ADAPTIVE "-" LS_ACQUIRE)
134 #define LSA_RELEASE (LS_TYPE_ADAPTIVE "-" LS_RELEASE)
135 #define LSA_SPIN (LS_TYPE_ADAPTIVE "-" LS_SPIN)
136 #define LSA_BLOCK (LS_TYPE_ADAPTIVE "-" LS_BLOCK)
137 #define LSA_ILK_SPIN (LS_TYPE_ILK "-" LS_SPIN)
138 #define LSS_ACQUIRE (LS_TYPE_SPIN "-" LS_ACQUIRE)
139 #define LSS_RELEASE (LS_TYPE_SPIN "-" LS_RELEASE)
140 #define LSS_SPIN (LS_TYPE_SPIN "-" LS_SPIN)
141 #define LSR_ACQUIRE (LS_TYPE_RW "-" LS_ACQUIRE)
142 #define LSR_RELEASE (LS_TYPE_RW "-" LS_RELEASE)
143 #define LSR_BLOCK (LS_TYPE_RW "-" LS_BLOCK)
144 #define LSR_SPIN (LS_TYPE_RW "-" LS_SPIN)
145 #define LSR_UPGRADE (LS_TYPE_RW "-" LS_UPGRADE)
146 #define LSR_UPGRADE_BLOCK (LS_TYPE_RWUPGRADE "-" LS_BLOCK)
147 #define LSR_DOWNGRADE (LS_TYPE_RW "-" LS_DOWNGRADE)
148 #define LST_SPIN (LS_TYPE_THREAD "-" LS_SPIN)
156 #define _KERNEL /* Solaris vs. Darwin */
160 * Platform-independent kernel support for the lockstat driver.
162 #if defined(NEED_DTRACE_DEFS)
163 typedef uint32_t dtrace_id_t
; /* probe identifier - also in dtrace.h! */
164 typedef uint64_t u_longlong_t
; /* also in dtrace.h! */
167 extern dtrace_id_t lockstat_probemap
[LS_NPROBES
];
168 extern void (*lockstat_probe
)(dtrace_id_t
, uint64_t, uint64_t,
169 uint64_t, uint64_t, uint64_t);
177 extern void (lockstat_probe_wrapper
)(int, uintptr_t, int);
180 * Macros to record lockstat probes.
182 #define LOCKSTAT_RECORD4(probe, lp, arg0, arg1, arg2, arg3) \
185 if ((id = lockstat_probemap[(probe)])) { \
186 (*lockstat_probe)(id, (uintptr_t)(lp), (arg0), \
187 (arg1), (arg2), (arg3)); \
191 #define LOCKSTAT_RECORD2(probe, lp, arg1, arg2) \
192 LOCKSTAT_RECORD4(probe, lp, arg1, arg2, 0, 0)
194 #define LOCKSTAT_RECORD(probe, lp, arg) \
195 LOCKSTAT_RECORD4(probe, lp, arg, 0, 0, 0)
197 #define LOCKSTAT_RECORD0(probe, lp) \
198 LOCKSTAT_RECORD4(probe, lp, 0, 0, 0, 0)
200 /* No Lockstat provider */
202 #define LOCKSTAT_RECORD()
203 #define LOCKSTAT_RECORD0()
204 #define LOCKSTAT_RECORD2()
205 #define LOCKSTAT_RECORD4()
207 #endif /* !CONFIG_DTRACE */
217 #endif /* _SYS_LOCKSTAT_H */