Optimized fast-paths for rw_enter() / rw_tryenter() / rw_exit().diff -r1.28 -r1.29 src/sys/arch/alpha/alpha/genassym.cf
(thorpej)
--- src/sys/arch/alpha/alpha/genassym.cf 2021/07/11 01:54:42 1.28
+++ src/sys/arch/alpha/alpha/genassym.cf 2021/07/11 01:58:41 1.29
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | # $NetBSD: genassym.cf,v 1.28 2021/07/11 01:54:42 thorpej Exp $ | 1 | # $NetBSD: genassym.cf,v 1.29 2021/07/11 01:58:41 thorpej Exp $ | |
2 | 2 | |||
3 | # | 3 | # | |
4 | # Copyright (c) 1982, 1990, 1993 | 4 | # Copyright (c) 1982, 1990, 1993 | |
5 | # The Regents of the University of California. All rights reserved. | 5 | # The Regents of the University of California. All rights reserved. | |
6 | # | 6 | # | |
7 | # Redistribution and use in source and binary forms, with or without | 7 | # Redistribution and use in source and binary forms, with or without | |
8 | # modification, are permitted provided that the following conditions | 8 | # modification, are permitted provided that the following conditions | |
9 | # are met: | 9 | # are met: | |
10 | # 1. Redistributions of source code must retain the above copyright | 10 | # 1. Redistributions of source code must retain the above copyright | |
11 | # notice, this list of conditions and the following disclaimer. | 11 | # notice, this list of conditions and the following disclaimer. | |
12 | # 2. Redistributions in binary form must reproduce the above copyright | 12 | # 2. Redistributions in binary form must reproduce the above copyright | |
13 | # notice, this list of conditions and the following disclaimer in the | 13 | # notice, this list of conditions and the following disclaimer in the | |
14 | # documentation and/or other materials provided with the distribution. | 14 | # documentation and/or other materials provided with the distribution. | |
@@ -56,32 +56,35 @@ | @@ -56,32 +56,35 @@ | |||
56 | # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | 56 | # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | |
57 | # ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE | 57 | # ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE | |
58 | # FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | 58 | # FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | |
59 | # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | 59 | # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | |
60 | # OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | 60 | # OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | |
61 | # HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | 61 | # HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | |
62 | # LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | 62 | # LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | |
63 | # OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | 63 | # OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | |
64 | # SUCH DAMAGE. | 64 | # SUCH DAMAGE. | |
65 | # | 65 | # | |
66 | # from: @(#)genassym.c 8.3 (Berkeley) 1/4/94 | 66 | # from: @(#)genassym.c 8.3 (Berkeley) 1/4/94 | |
67 | # | 67 | # | |
68 | 68 | |||
69 | quote #define __RWLOCK_PRIVATE | |||
70 | ||||
69 | include <sys/param.h> | 71 | include <sys/param.h> | |
70 | include <sys/buf.h> | 72 | include <sys/buf.h> | |
71 | include <sys/proc.h> | 73 | include <sys/proc.h> | |
72 | include <sys/sched.h> | 74 | include <sys/sched.h> | |
73 | include <sys/mbuf.h> | 75 | include <sys/mbuf.h> | |
74 | include <sys/msgbuf.h> | 76 | include <sys/msgbuf.h> | |
77 | include <sys/rwlock.h> | |||
75 | include <sys/syscall.h> | 78 | include <sys/syscall.h> | |
76 | 79 | |||
77 | include <machine/cpu.h> | 80 | include <machine/cpu.h> | |
78 | include <machine/reg.h> | 81 | include <machine/reg.h> | |
79 | include <machine/frame.h> | 82 | include <machine/frame.h> | |
80 | include <machine/rpb.h> | 83 | include <machine/rpb.h> | |
81 | include <machine/vmparam.h> | 84 | include <machine/vmparam.h> | |
82 | 85 | |||
83 | include <uvm/uvm_extern.h> | 86 | include <uvm/uvm_extern.h> | |
84 | 87 | |||
85 | # general constants | 88 | # general constants | |
86 | define VM_MAX_ADDRESS VM_MAX_ADDRESS | 89 | define VM_MAX_ADDRESS VM_MAX_ADDRESS | |
87 | define ALPHA_PGBYTES ALPHA_PGBYTES | 90 | define ALPHA_PGBYTES ALPHA_PGBYTES | |
@@ -186,13 +189,19 @@ define ALPHA_KENTRY_UNA ALPHA_KENTRY_UNA | @@ -186,13 +189,19 @@ define ALPHA_KENTRY_UNA ALPHA_KENTRY_UNA | |||
186 | define ENAMETOOLONG ENAMETOOLONG | 189 | define ENAMETOOLONG ENAMETOOLONG | |
187 | define EFAULT EFAULT | 190 | define EFAULT EFAULT | |
188 | 191 | |||
189 | # Syscalls called from sigreturn. | 192 | # Syscalls called from sigreturn. | |
190 | define SYS_compat_16___sigreturn14 SYS_compat_16___sigreturn14 | 193 | define SYS_compat_16___sigreturn14 SYS_compat_16___sigreturn14 | |
191 | define SYS_exit SYS_exit | 194 | define SYS_exit SYS_exit | |
192 | 195 | |||
193 | # CPU info | 196 | # CPU info | |
194 | define CPU_INFO_CURLWP offsetof(struct cpu_info, ci_curlwp) | 197 | define CPU_INFO_CURLWP offsetof(struct cpu_info, ci_curlwp) | |
195 | define CPU_INFO_IDLE_LWP offsetof(struct cpu_info, ci_data.cpu_idlelwp) | 198 | define CPU_INFO_IDLE_LWP offsetof(struct cpu_info, ci_data.cpu_idlelwp) | |
196 | define CPU_INFO_SSIR offsetof(struct cpu_info, ci_ssir) | 199 | define CPU_INFO_SSIR offsetof(struct cpu_info, ci_ssir) | |
197 | define CPU_INFO_MTX_COUNT offsetof(struct cpu_info, ci_mtx_count) | 200 | define CPU_INFO_MTX_COUNT offsetof(struct cpu_info, ci_mtx_count) | |
198 | define CPU_INFO_SIZEOF sizeof(struct cpu_info) | 201 | define CPU_INFO_SIZEOF sizeof(struct cpu_info) | |
202 | ||||
203 | # Bits in lock fields | |||
204 | define RW_WRITE_WANTED RW_WRITE_WANTED | |||
205 | define RW_WRITE_LOCKED RW_WRITE_LOCKED | |||
206 | define RW_READ_INCR RW_READ_INCR | |||
207 | define RW_READ_COUNT_SHIFT RW_READ_COUNT_SHIFT |
--- src/sys/arch/alpha/alpha/lock_stubs.s 2020/09/04 02:54:56 1.4
+++ src/sys/arch/alpha/alpha/lock_stubs.s 2021/07/11 01:58:41 1.5
@@ -1,21 +1,21 @@ | @@ -1,21 +1,21 @@ | |||
1 | /* $NetBSD: lock_stubs.s,v 1.4 2020/09/04 02:54:56 thorpej Exp $ */ | 1 | /* $NetBSD: lock_stubs.s,v 1.5 2021/07/11 01:58:41 thorpej Exp $ */ | |
2 | 2 | |||
3 | /*- | 3 | /*- | |
4 | * Copyright (c) 2007 The NetBSD Foundation, Inc. | 4 | * Copyright (c) 2007, 2021 The NetBSD Foundation, Inc. | |
5 | * All rights reserved. | 5 | * All rights reserved. | |
6 | * | 6 | * | |
7 | * This code is derived from software contributed to The NetBSD Foundation | 7 | * This code is derived from software contributed to The NetBSD Foundation | |
8 | * by Andrew Doran. | 8 | * by Andrew Doran, and by Jason R. Thorpe. | |
9 | * | 9 | * | |
10 | * Redistribution and use in source and binary forms, with or without | 10 | * Redistribution and use in source and binary forms, with or without | |
11 | * modification, are permitted provided that the following conditions | 11 | * modification, are permitted provided that the following conditions | |
12 | * are met: | 12 | * are met: | |
13 | * 1. Redistributions of source code must retain the above copyright | 13 | * 1. Redistributions of source code must retain the above copyright | |
14 | * notice, this list of conditions and the following disclaimer. | 14 | * notice, this list of conditions and the following disclaimer. | |
15 | * 2. Redistributions in binary form must reproduce the above copyright | 15 | * 2. Redistributions in binary form must reproduce the above copyright | |
16 | * notice, this list of conditions and the following disclaimer in the | 16 | * notice, this list of conditions and the following disclaimer in the | |
17 | * documentation and/or other materials provided with the distribution. | 17 | * documentation and/or other materials provided with the distribution. | |
18 | * | 18 | * | |
19 | * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS | 19 | * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS | |
20 | * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED | 20 | * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED | |
21 | * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | 21 | * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | |
@@ -24,27 +24,27 @@ | @@ -24,27 +24,27 @@ | |||
24 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | 24 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | |
25 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | 25 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | |
26 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | 26 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | |
27 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | 27 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | |
28 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | 28 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | |
29 | * POSSIBILITY OF SUCH DAMAGE. | 29 | * POSSIBILITY OF SUCH DAMAGE. | |
30 | */ | 30 | */ | |
31 | 31 | |||
32 | #include "opt_lockdebug.h" | 32 | #include "opt_lockdebug.h" | |
33 | #include "opt_multiprocessor.h" | 33 | #include "opt_multiprocessor.h" | |
34 | 34 | |||
35 | #include <machine/asm.h> | 35 | #include <machine/asm.h> | |
36 | 36 | |||
37 | __KERNEL_RCSID(0, "$NetBSD: lock_stubs.s,v 1.4 2020/09/04 02:54:56 thorpej Exp $"); | 37 | __KERNEL_RCSID(0, "$NetBSD: lock_stubs.s,v 1.5 2021/07/11 01:58:41 thorpej Exp $"); | |
38 | 38 | |||
39 | #include "assym.h" | 39 | #include "assym.h" | |
40 | 40 | |||
41 | #if defined(MULTIPROCESSOR) | 41 | #if defined(MULTIPROCESSOR) | |
42 | #define MB mb | 42 | #define MB mb | |
43 | #else | 43 | #else | |
44 | #define MB /* nothing */ | 44 | #define MB /* nothing */ | |
45 | #endif | 45 | #endif | |
46 | 46 | |||
47 | /* | 47 | /* | |
48 | * int _lock_cas(uintptr_t *ptr, uintptr_t old, uintptr_t new) | 48 | * int _lock_cas(uintptr_t *ptr, uintptr_t old, uintptr_t new) | |
49 | */ | 49 | */ | |
50 | LEAF(_lock_cas, 3) | 50 | LEAF(_lock_cas, 3) | |
@@ -53,61 +53,217 @@ LEAF(_lock_cas, 3) | @@ -53,61 +53,217 @@ LEAF(_lock_cas, 3) | |||
53 | ldq_l t1, 0(a0) | 53 | ldq_l t1, 0(a0) | |
54 | cmpeq t1, a1, t1 | 54 | cmpeq t1, a1, t1 | |
55 | beq t1, 2f | 55 | beq t1, 2f | |
56 | stq_c v0, 0(a0) | 56 | stq_c v0, 0(a0) | |
57 | beq v0, 3f | 57 | beq v0, 3f | |
58 | MB | 58 | MB | |
59 | RET | 59 | RET | |
60 | 2: | 60 | 2: | |
61 | mov zero, v0 | 61 | mov zero, v0 | |
62 | MB | 62 | MB | |
63 | RET | 63 | RET | |
64 | 3: | 64 | 3: | |
65 | br 1b | 65 | br 1b | |
66 | END(_lock_cas) | 66 | END(_lock_cas) | |
67 | 67 | |||
68 | #if !defined(LOCKDEBUG) | 68 | #if !defined(LOCKDEBUG) | |
69 | 69 | |||
70 | /* | 70 | /* | |
71 | * void mutex_enter(kmutex_t *mtx); | 71 | * void mutex_enter(kmutex_t *mtx); | |
72 | */ | 72 | */ | |
73 | LEAF(mutex_enter, 1) | 73 | LEAF(mutex_enter, 1) | |
74 | LDGP(pv) | 74 | LDGP(pv) | |
75 | GET_CURLWP | 75 | GET_CURLWP /* Note: GET_CURLWP clobbers v0, t0, t8...t11. */ | |
76 | 1: | 76 | 1: | |
77 | mov v0, t1 | 77 | mov v0, t1 | |
78 | ldq_l t2, 0(a0) | 78 | ldq_l t2, 0(a0) | |
79 | bne t2, 2f | 79 | bne t2, 2f | |
80 | stq_c t1, 0(a0) | 80 | stq_c t1, 0(a0) | |
81 | beq t1, 3f | 81 | beq t1, 3f | |
82 | MB | 82 | MB | |
83 | RET | 83 | RET | |
84 | 2: | 84 | 2: | |
85 | lda t12, mutex_vector_enter | 85 | lda t12, mutex_vector_enter | |
86 | jmp (t12) | 86 | jmp (t12) | |
87 | 3: | 87 | 3: | |
88 | br 1b | 88 | br 1b | |
89 | END(mutex_enter) | 89 | END(mutex_enter) | |
90 | 90 | |||
91 | /* | 91 | /* | |
92 | * void mutex_exit(kmutex_t *mtx); | 92 | * void mutex_exit(kmutex_t *mtx); | |
93 | */ | 93 | */ | |
94 | LEAF(mutex_exit, 1) | 94 | LEAF(mutex_exit, 1) | |
95 | LDGP(pv) | 95 | LDGP(pv) | |
96 | MB | 96 | MB | |
97 | GET_CURLWP | 97 | GET_CURLWP /* Note: GET_CURLWP clobbers v0, t0, t8...t11. */ | |
98 | mov zero, t3 | 98 | mov zero, t3 | |
99 | 1: | 99 | 1: | |
100 | ldq_l t2, 0(a0) | 100 | ldq_l t2, 0(a0) | |
101 | cmpeq v0, t2, t2 | 101 | cmpeq v0, t2, t2 | |
102 | beq t2, 2f | 102 | beq t2, 2f | |
103 | stq_c t3, 0(a0) | 103 | stq_c t3, 0(a0) | |
104 | beq t3, 3f | 104 | beq t3, 3f | |
105 | RET | 105 | RET | |
106 | 2: | 106 | 2: | |
107 | lda t12, mutex_vector_exit | 107 | lda t12, mutex_vector_exit | |
108 | jmp (t12) | 108 | jmp (t12) | |
109 | 3: | 109 | 3: | |
110 | br 1b | 110 | br 1b | |
111 | END(mutex_exit) | 111 | END(mutex_exit) | |
112 | ||||
113 | /* | |||
114 | * void rw_enter(krwlock_t *rwl, krw_t op); | |||
115 | * | |||
116 | * Acquire one hold on a RW lock. | |||
117 | */ | |||
118 | LEAF(rw_enter, 2) | |||
119 | LDGP(pv) | |||
120 | ||||
121 | /* | |||
122 | * RW_READER == 0 (we have a compile-time assert in machdep.c | |||
123 | * to ensure this). | |||
124 | * | |||
125 | * Acquire for read is the most common case. | |||
126 | */ | |||
127 | bne a1, 3f | |||
128 | ||||
129 | /* Acquiring for read. */ | |||
130 | 1: ldq_l t0, 0(a0) | |||
131 | and t0, (RW_WRITE_LOCKED|RW_WRITE_WANTED), t1 | |||
132 | addq t0, RW_READ_INCR, t2 | |||
133 | bne t1, 4f /* contended */ | |||
134 | stq_c t2, 0(a0) | |||
135 | beq t2, 2f /* STQ_C failed; retry */ | |||
136 | MB | |||
137 | RET | |||
138 | ||||
139 | 2: br 1b | |||
140 | ||||
141 | 3: /* Acquiring for write. */ | |||
142 | GET_CURLWP /* Note: GET_CURLWP clobbers v0, t0, t8...t11. */ | |||
143 | ldq_l t0, 0(a0) | |||
144 | or v0, RW_WRITE_LOCKED, t2 | |||
145 | bne t0, 4f /* contended */ | |||
146 | stq_c t2, 0(a0) | |||
147 | beq t2, 4f /* STQ_C failed; consider it contended */ | |||
148 | MB | |||
149 | RET | |||
150 | ||||
151 | 4: lda pv, rw_vector_enter | |||
152 | jmp (pv) | |||
153 | END(rw_enter) | |||
154 | ||||
155 | /* | |||
156 | * int rw_tryenter(krwlock_t *rwl, krw_t op); | |||
157 | * | |||
158 | * Try to acquire one hold on a RW lock. | |||
159 | */ | |||
160 | LEAF(rw_tryenter, 2) | |||
161 | LDGP(pv) | |||
162 | ||||
163 | /* See above. */ | |||
164 | bne a1, 3f | |||
165 | ||||
166 | /* Acquiring for read. */ | |||
167 | 1: ldq_l t0, 0(a0) | |||
168 | and t0, (RW_WRITE_LOCKED|RW_WRITE_WANTED), t1 | |||
169 | addq t0, RW_READ_INCR, v0 | |||
170 | bne t1, 4f /* contended */ | |||
171 | stq_c v0, 0(a0) | |||
172 | beq v0, 2f /* STQ_C failed; retry */ | |||
173 | MB | |||
174 | RET /* v0 contains non-zero LOCK_FLAG from STQ_C */ | |||
175 | ||||
176 | 2: br 1b | |||
177 | ||||
178 | /* Acquiring for write. */ | |||
179 | 3: GET_CURLWP /* Note: GET_CURLWP clobbers v0, t0, t8...t11. */ | |||
180 | ldq_l t0, 0(a0) | |||
181 | or v0, RW_WRITE_LOCKED, v0 | |||
182 | bne t0, 4f /* contended */ | |||
183 | stq_c v0, 0(a0) | |||
184 | /* | |||
185 | * v0 now contains the LOCK_FLAG value from STQ_C, which is either | |||
186 | * 0 for failure, or non-zero for success. In either case, v0's | |||
187 | * value is correct. Go ahead and perform the memory barrier even | |||
188 | * in the failure case because we expect it to be rare and it saves | |||
189 | * a branch-not-taken instruction in the success case. | |||
190 | */ | |||
191 | MB | |||
192 | RET | |||
193 | ||||
194 | 4: mov zero, v0 /* return 0 (failure) */ | |||
195 | RET | |||
196 | END(rw_tryenter) | |||
197 | ||||
198 | /* | |||
199 | * void rw_exit(krwlock_t *rwl); | |||
200 | * | |||
201 | * Release one hold on a RW lock. | |||
202 | */ | |||
203 | LEAF(rw_exit, 1) | |||
204 | LDGP(pv) | |||
205 | MB | |||
206 | ||||
207 | /* | |||
208 | * Check for write-lock release, and get the owner/count field | |||
209 | * on its own for sanity-checking against expected values. | |||
210 | */ | |||
211 | ldq a1, 0(a0) | |||
212 | and a1, RW_WRITE_LOCKED, t1 | |||
213 | srl a1, RW_READ_COUNT_SHIFT, a2 | |||
214 | bne t1, 3f | |||
215 | ||||
216 | /* | |||
217 | * Releasing a read-lock. Make sure the count is non-zero. | |||
218 | * If it is zero, take the slow path where the juicy diagnostic | |||
219 | * checks are located. | |||
220 | */ | |||
221 | beq a2, 4f | |||
222 | ||||
223 | /* | |||
224 | * We do the following trick to check to see if we're releasing | |||
225 | * the last read-count and there are waiters: | |||
226 | * | |||
227 | * 1. Set v0 to 1. | |||
228 | * 2. Shift the new read count into t1. | |||
229 | * 3. Conditally move t1 to v0 based on low-bit-set of t0 | |||
230 | * (RW_HAS_WAITERS). If RW_HAS_WAITERS is not set, then | |||
231 | * the move will not take place, and v0 will remain 1. | |||
232 | * Otherwise, v0 will contain the updated read count. | |||
233 | * 4. Jump to slow path if v0 == 0. | |||
234 | */ | |||
235 | 1: ldq_l t0, 0(a0) | |||
236 | ldiq v0, 1 | |||
237 | subq t0, RW_READ_INCR, t2 | |||
238 | srl t2, RW_READ_COUNT_SHIFT, t1 | |||
239 | cmovlbs t0, t1, v0 | |||
240 | beq v0, 4f | |||
241 | stq_c t2, 0(a0) | |||
242 | beq t2, 2f /* STQ_C failed; try again */ | |||
243 | RET | |||
244 | ||||
245 | 2: br 1b | |||
246 | ||||
247 | /* | |||
248 | * Releasing a write-lock. Make sure the owner field points | |||
249 | * to our LWP. If it does not, take the slow path where the | |||
250 | * juicy diagnostic checks are located. a2 contains the owner | |||
251 | * field shifted down. Shift it back up to compare to curlwp; | |||
252 | * this conveniently discards the bits we don't want to compare. | |||
253 | */ | |||
254 | 3: GET_CURLWP /* Note: GET_CURLWP clobbers v0, t0, t8...t11. */ | |||
255 | sll a2, RW_READ_COUNT_SHIFT, a2 | |||
256 | mov zero, t2 /* fast-path write-unlock stores NULL */ | |||
257 | cmpeq v0, a2, v0 /* v0 = (owner == curlwp) */ | |||
258 | ldq_l t0, 0(a0) | |||
259 | beq v0, 4f /* owner field mismatch; need slow path */ | |||
260 | blbs t0, 4f /* RW_HAS_WAITERS set; need slow-path */ | |||
261 | stq_c t2, 0(a0) | |||
262 | beq t2, 4f /* STQ_C failed; need slow-path */ | |||
263 | RET | |||
264 | ||||
265 | 4: lda pv, rw_vector_exit | |||
266 | jmp (pv) | |||
267 | END(rw_exit) | |||
112 | 268 | |||
113 | #endif /* !LOCKDEBUG */ | 269 | #endif /* !LOCKDEBUG */ |
--- src/sys/arch/alpha/alpha/machdep.c 2021/07/04 22:42:35 1.373
+++ src/sys/arch/alpha/alpha/machdep.c 2021/07/11 01:58:41 1.374
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: machdep.c,v 1.373 2021/07/04 22:42:35 thorpej Exp $ */ | 1 | /* $NetBSD: machdep.c,v 1.374 2021/07/11 01:58:41 thorpej Exp $ */ | |
2 | 2 | |||
3 | /*- | 3 | /*- | |
4 | * Copyright (c) 1998, 1999, 2000, 2019, 2020 The NetBSD Foundation, Inc. | 4 | * Copyright (c) 1998, 1999, 2000, 2019, 2020 The NetBSD Foundation, Inc. | |
5 | * All rights reserved. | 5 | * All rights reserved. | |
6 | * | 6 | * | |
7 | * This code is derived from software contributed to The NetBSD Foundation | 7 | * This code is derived from software contributed to The NetBSD Foundation | |
8 | * by Jason R. Thorpe of the Numerical Aerospace Simulation Facility, | 8 | * by Jason R. Thorpe of the Numerical Aerospace Simulation Facility, | |
9 | * NASA Ames Research Center and by Chris G. Demetriou. | 9 | * NASA Ames Research Center and by Chris G. Demetriou. | |
10 | * | 10 | * | |
11 | * Redistribution and use in source and binary forms, with or without | 11 | * Redistribution and use in source and binary forms, with or without | |
12 | * modification, are permitted provided that the following conditions | 12 | * modification, are permitted provided that the following conditions | |
13 | * are met: | 13 | * are met: | |
14 | * 1. Redistributions of source code must retain the above copyright | 14 | * 1. Redistributions of source code must retain the above copyright | |
@@ -55,29 +55,31 @@ | @@ -55,29 +55,31 @@ | |||
55 | * | 55 | * | |
56 | * any improvements or extensions that they make and grant Carnegie the | 56 | * any improvements or extensions that they make and grant Carnegie the | |
57 | * rights to redistribute these changes. | 57 | * rights to redistribute these changes. | |
58 | */ | 58 | */ | |
59 | 59 | |||
60 | #include "opt_ddb.h" | 60 | #include "opt_ddb.h" | |
61 | #include "opt_kgdb.h" | 61 | #include "opt_kgdb.h" | |
62 | #include "opt_modular.h" | 62 | #include "opt_modular.h" | |
63 | #include "opt_multiprocessor.h" | 63 | #include "opt_multiprocessor.h" | |
64 | #include "opt_dec_3000_300.h" | 64 | #include "opt_dec_3000_300.h" | |
65 | #include "opt_dec_3000_500.h" | 65 | #include "opt_dec_3000_500.h" | |
66 | #include "opt_execfmt.h" | 66 | #include "opt_execfmt.h" | |
67 | 67 | |||
68 | #define __RWLOCK_PRIVATE | |||
69 | ||||
68 | #include <sys/cdefs.h> /* RCS ID & Copyright macro defns */ | 70 | #include <sys/cdefs.h> /* RCS ID & Copyright macro defns */ | |
69 | 71 | |||
70 | __KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.373 2021/07/04 22:42:35 thorpej Exp $"); | 72 | __KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.374 2021/07/11 01:58:41 thorpej Exp $"); | |
71 | 73 | |||
72 | #include <sys/param.h> | 74 | #include <sys/param.h> | |
73 | #include <sys/systm.h> | 75 | #include <sys/systm.h> | |
74 | #include <sys/signalvar.h> | 76 | #include <sys/signalvar.h> | |
75 | #include <sys/kernel.h> | 77 | #include <sys/kernel.h> | |
76 | #include <sys/cpu.h> | 78 | #include <sys/cpu.h> | |
77 | #include <sys/proc.h> | 79 | #include <sys/proc.h> | |
78 | #include <sys/ras.h> | 80 | #include <sys/ras.h> | |
79 | #include <sys/sched.h> | 81 | #include <sys/sched.h> | |
80 | #include <sys/reboot.h> | 82 | #include <sys/reboot.h> | |
81 | #include <sys/device.h> | 83 | #include <sys/device.h> | |
82 | #include <sys/module.h> | 84 | #include <sys/module.h> | |
83 | #include <sys/mman.h> | 85 | #include <sys/mman.h> | |
@@ -85,26 +87,27 @@ __KERNEL_RCSID(0, "$NetBSD: machdep.c,v | @@ -85,26 +87,27 @@ __KERNEL_RCSID(0, "$NetBSD: machdep.c,v | |||
85 | #include <sys/ioctl.h> | 87 | #include <sys/ioctl.h> | |
86 | #include <sys/tty.h> | 88 | #include <sys/tty.h> | |
87 | #include <sys/exec.h> | 89 | #include <sys/exec.h> | |
88 | #include <sys/exec_aout.h> /* for MID_* */ | 90 | #include <sys/exec_aout.h> /* for MID_* */ | |
89 | #include <sys/exec_ecoff.h> | 91 | #include <sys/exec_ecoff.h> | |
90 | #include <sys/core.h> | 92 | #include <sys/core.h> | |
91 | #include <sys/kcore.h> | 93 | #include <sys/kcore.h> | |
92 | #include <sys/ucontext.h> | 94 | #include <sys/ucontext.h> | |
93 | #include <sys/conf.h> | 95 | #include <sys/conf.h> | |
94 | #include <sys/ksyms.h> | 96 | #include <sys/ksyms.h> | |
95 | #include <sys/kauth.h> | 97 | #include <sys/kauth.h> | |
96 | #include <sys/atomic.h> | 98 | #include <sys/atomic.h> | |
97 | #include <sys/cpu.h> | 99 | #include <sys/cpu.h> | |
100 | #include <sys/rwlock.h> | |||
98 | 101 | |||
99 | #include <machine/kcore.h> | 102 | #include <machine/kcore.h> | |
100 | #include <machine/fpu.h> | 103 | #include <machine/fpu.h> | |
101 | 104 | |||
102 | #include <sys/mount.h> | 105 | #include <sys/mount.h> | |
103 | #include <sys/syscallargs.h> | 106 | #include <sys/syscallargs.h> | |
104 | 107 | |||
105 | #include <uvm/uvm.h> | 108 | #include <uvm/uvm.h> | |
106 | #include <sys/sysctl.h> | 109 | #include <sys/sysctl.h> | |
107 | 110 | |||
108 | #include <dev/cons.h> | 111 | #include <dev/cons.h> | |
109 | #include <dev/mm.h> | 112 | #include <dev/mm.h> | |
110 | 113 | |||
@@ -123,26 +126,30 @@ __KERNEL_RCSID(0, "$NetBSD: machdep.c,v | @@ -123,26 +126,30 @@ __KERNEL_RCSID(0, "$NetBSD: machdep.c,v | |||
123 | #include <ddb/db_interface.h> | 126 | #include <ddb/db_interface.h> | |
124 | #endif | 127 | #endif | |
125 | 128 | |||
126 | #ifdef KGDB | 129 | #ifdef KGDB | |
127 | #include <sys/kgdb.h> | 130 | #include <sys/kgdb.h> | |
128 | #endif | 131 | #endif | |
129 | 132 | |||
130 | #ifdef DEBUG | 133 | #ifdef DEBUG | |
131 | #include <machine/sigdebug.h> | 134 | #include <machine/sigdebug.h> | |
132 | int sigdebug = 0x0; | 135 | int sigdebug = 0x0; | |
133 | int sigpid = 0; | 136 | int sigpid = 0; | |
134 | #endif | 137 | #endif | |
135 | 138 | |||
139 | /* Assert some assumptions made in lock_stubs.s */ | |||
140 | __CTASSERT(RW_READER == 0); | |||
141 | __CTASSERT(RW_HAS_WAITERS == 1); | |||
142 | ||||
136 | #include <machine/alpha.h> | 143 | #include <machine/alpha.h> | |
137 | 144 | |||
138 | #include "ksyms.h" | 145 | #include "ksyms.h" | |
139 | 146 | |||
140 | struct vm_map *phys_map = NULL; | 147 | struct vm_map *phys_map = NULL; | |
141 | 148 | |||
142 | void *msgbufaddr; | 149 | void *msgbufaddr; | |
143 | 150 | |||
144 | int maxmem; /* max memory per process */ | 151 | int maxmem; /* max memory per process */ | |
145 | 152 | |||
146 | int totalphysmem; /* total amount of physical memory in system */ | 153 | int totalphysmem; /* total amount of physical memory in system */ | |
147 | int resvmem; /* amount of memory reserved for PROM */ | 154 | int resvmem; /* amount of memory reserved for PROM */ | |
148 | int unusedmem; /* amount of memory for OS that we don't use */ | 155 | int unusedmem; /* amount of memory for OS that we don't use */ |
--- src/sys/arch/alpha/include/rwlock.h 2019/11/29 20:04:52 1.5
+++ src/sys/arch/alpha/include/rwlock.h 2021/07/11 01:58:41 1.6