| @@ -1,14 +1,14 @@ | | | @@ -1,14 +1,14 @@ |
1 | /* $NetBSD: kern_lock.c,v 1.168 2020/01/27 21:05:43 ad Exp $ */ | | 1 | /* $NetBSD: kern_lock.c,v 1.169 2020/02/10 22:11:09 christos Exp $ */ |
2 | | | 2 | |
3 | /*- | | 3 | /*- |
4 | * Copyright (c) 2002, 2006, 2007, 2008, 2009, 2020 The NetBSD Foundation, Inc. | | 4 | * Copyright (c) 2002, 2006, 2007, 2008, 2009, 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 Andrew Doran. | | 9 | * NASA Ames Research Center, and by Andrew Doran. |
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 |
| @@ -21,27 +21,27 @@ | | | @@ -21,27 +21,27 @@ |
21 | * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED | | 21 | * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED |
22 | * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | | 22 | * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR |
23 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS | | 23 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS |
24 | * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR | | 24 | * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR |
25 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | | 25 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF |
26 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | | 26 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS |
27 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | | 27 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN |
28 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | | 28 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
29 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | | 29 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE |
30 | * POSSIBILITY OF SUCH DAMAGE. | | 30 | * POSSIBILITY OF SUCH DAMAGE. |
31 | */ | | 31 | */ |
32 | | | 32 | |
33 | #include <sys/cdefs.h> | | 33 | #include <sys/cdefs.h> |
34 | __KERNEL_RCSID(0, "$NetBSD: kern_lock.c,v 1.168 2020/01/27 21:05:43 ad Exp $"); | | 34 | __KERNEL_RCSID(0, "$NetBSD: kern_lock.c,v 1.169 2020/02/10 22:11:09 christos Exp $"); |
35 | | | 35 | |
36 | #ifdef _KERNEL_OPT | | 36 | #ifdef _KERNEL_OPT |
37 | #include "opt_lockdebug.h" | | 37 | #include "opt_lockdebug.h" |
38 | #endif | | 38 | #endif |
39 | | | 39 | |
40 | #include <sys/param.h> | | 40 | #include <sys/param.h> |
41 | #include <sys/proc.h> | | 41 | #include <sys/proc.h> |
42 | #include <sys/lock.h> | | 42 | #include <sys/lock.h> |
43 | #include <sys/systm.h> | | 43 | #include <sys/systm.h> |
44 | #include <sys/kernel.h> | | 44 | #include <sys/kernel.h> |
45 | #include <sys/lockdebug.h> | | 45 | #include <sys/lockdebug.h> |
46 | #include <sys/cpu.h> | | 46 | #include <sys/cpu.h> |
47 | #include <sys/syslog.h> | | 47 | #include <sys/syslog.h> |
| @@ -233,26 +233,28 @@ _kernel_lock(int nlocks) | | | @@ -233,26 +233,28 @@ _kernel_lock(int nlocks) |
233 | */ | | 233 | */ |
234 | LOCKSTAT_ENTER(lsflag); | | 234 | LOCKSTAT_ENTER(lsflag); |
235 | LOCKSTAT_START_TIMER(lsflag, spintime); | | 235 | LOCKSTAT_START_TIMER(lsflag, spintime); |
236 | | | 236 | |
237 | do { | | 237 | do { |
238 | splx(s); | | 238 | splx(s); |
239 | while (__SIMPLELOCK_LOCKED_P(kernel_lock)) { | | 239 | while (__SIMPLELOCK_LOCKED_P(kernel_lock)) { |
240 | #ifdef LOCKDEBUG | | 240 | #ifdef LOCKDEBUG |
241 | if (SPINLOCK_SPINOUT(spins)) { | | 241 | if (SPINLOCK_SPINOUT(spins)) { |
242 | extern int start_init_exec; | | 242 | extern int start_init_exec; |
243 | if (!start_init_exec) | | 243 | if (!start_init_exec) |
244 | _KERNEL_LOCK_ABORT("spinout"); | | 244 | _KERNEL_LOCK_ABORT("spinout"); |
245 | } | | 245 | } |
| | | 246 | SPINLOCK_BACKOFF_HOOK; |
| | | 247 | SPINLOCK_SPIN_HOOK; |
246 | #endif | | 248 | #endif |
247 | } | | 249 | } |
248 | s = splvm(); | | 250 | s = splvm(); |
249 | } while (!__cpu_simple_lock_try(kernel_lock)); | | 251 | } while (!__cpu_simple_lock_try(kernel_lock)); |
250 | | | 252 | |
251 | ci->ci_biglock_count = nlocks; | | 253 | ci->ci_biglock_count = nlocks; |
252 | l->l_blcnt = nlocks; | | 254 | l->l_blcnt = nlocks; |
253 | LOCKSTAT_STOP_TIMER(lsflag, spintime); | | 255 | LOCKSTAT_STOP_TIMER(lsflag, spintime); |
254 | LOCKDEBUG_LOCKED(kernel_lock_dodebug, kernel_lock, NULL, | | 256 | LOCKDEBUG_LOCKED(kernel_lock_dodebug, kernel_lock, NULL, |
255 | RETURN_ADDRESS, 0); | | 257 | RETURN_ADDRESS, 0); |
256 | if (owant == NULL) { | | 258 | if (owant == NULL) { |
257 | LOCKSTAT_EVENT_RA(lsflag, kernel_lock, | | 259 | LOCKSTAT_EVENT_RA(lsflag, kernel_lock, |
258 | LB_KERNEL_LOCK | LB_SPIN, 1, spintime, RETURN_ADDRESS); | | 260 | LB_KERNEL_LOCK | LB_SPIN, 1, spintime, RETURN_ADDRESS); |