| @@ -1,14 +1,14 @@ | | | @@ -1,14 +1,14 @@ |
1 | /* $NetBSD: kern_mutex.c,v 1.79 2019/05/09 05:00:31 ozaki-r Exp $ */ | | 1 | /* $NetBSD: kern_mutex.c,v 1.79.2.1 2020/03/08 11:21:29 martin Exp $ */ |
2 | | | 2 | |
3 | /*- | | 3 | /*- |
4 | * Copyright (c) 2002, 2006, 2007, 2008 The NetBSD Foundation, Inc. | | 4 | * Copyright (c) 2002, 2006, 2007, 2008 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 and Andrew Doran. | | 8 | * by Jason R. Thorpe and Andrew Doran. |
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. |
| @@ -30,27 +30,27 @@ | | | @@ -30,27 +30,27 @@ |
30 | */ | | 30 | */ |
31 | | | 31 | |
32 | /* | | 32 | /* |
33 | * Kernel mutex implementation, modeled after those found in Solaris, | | 33 | * Kernel mutex implementation, modeled after those found in Solaris, |
34 | * a description of which can be found in: | | 34 | * a description of which can be found in: |
35 | * | | 35 | * |
36 | * Solaris Internals: Core Kernel Architecture, Jim Mauro and | | 36 | * Solaris Internals: Core Kernel Architecture, Jim Mauro and |
37 | * Richard McDougall. | | 37 | * Richard McDougall. |
38 | */ | | 38 | */ |
39 | | | 39 | |
40 | #define __MUTEX_PRIVATE | | 40 | #define __MUTEX_PRIVATE |
41 | | | 41 | |
42 | #include <sys/cdefs.h> | | 42 | #include <sys/cdefs.h> |
43 | __KERNEL_RCSID(0, "$NetBSD: kern_mutex.c,v 1.79 2019/05/09 05:00:31 ozaki-r Exp $"); | | 43 | __KERNEL_RCSID(0, "$NetBSD: kern_mutex.c,v 1.79.2.1 2020/03/08 11:21:29 martin Exp $"); |
44 | | | 44 | |
45 | #include <sys/param.h> | | 45 | #include <sys/param.h> |
46 | #include <sys/atomic.h> | | 46 | #include <sys/atomic.h> |
47 | #include <sys/proc.h> | | 47 | #include <sys/proc.h> |
48 | #include <sys/mutex.h> | | 48 | #include <sys/mutex.h> |
49 | #include <sys/sched.h> | | 49 | #include <sys/sched.h> |
50 | #include <sys/sleepq.h> | | 50 | #include <sys/sleepq.h> |
51 | #include <sys/systm.h> | | 51 | #include <sys/systm.h> |
52 | #include <sys/lockdebug.h> | | 52 | #include <sys/lockdebug.h> |
53 | #include <sys/kernel.h> | | 53 | #include <sys/kernel.h> |
54 | #include <sys/intr.h> | | 54 | #include <sys/intr.h> |
55 | #include <sys/lock.h> | | 55 | #include <sys/lock.h> |
56 | #include <sys/types.h> | | 56 | #include <sys/types.h> |
| @@ -387,28 +387,28 @@ mutex_init(kmutex_t *mtx, kmutex_type_t | | | @@ -387,28 +387,28 @@ mutex_init(kmutex_t *mtx, kmutex_type_t |
387 | _mutex_init(mtx, type, ipl, (uintptr_t)__builtin_return_address(0)); | | 387 | _mutex_init(mtx, type, ipl, (uintptr_t)__builtin_return_address(0)); |
388 | } | | 388 | } |
389 | | | 389 | |
390 | /* | | 390 | /* |
391 | * mutex_destroy: | | 391 | * mutex_destroy: |
392 | * | | 392 | * |
393 | * Tear down a mutex. | | 393 | * Tear down a mutex. |
394 | */ | | 394 | */ |
395 | void | | 395 | void |
396 | mutex_destroy(kmutex_t *mtx) | | 396 | mutex_destroy(kmutex_t *mtx) |
397 | { | | 397 | { |
398 | | | 398 | |
399 | if (MUTEX_ADAPTIVE_P(mtx)) { | | 399 | if (MUTEX_ADAPTIVE_P(mtx)) { |
400 | MUTEX_ASSERT(mtx, !MUTEX_OWNED(mtx->mtx_owner) && | | 400 | MUTEX_ASSERT(mtx, !MUTEX_OWNED(mtx->mtx_owner)); |
401 | !MUTEX_HAS_WAITERS(mtx)); | | 401 | MUTEX_ASSERT(mtx, !MUTEX_HAS_WAITERS(mtx)); |
402 | } else { | | 402 | } else { |
403 | MUTEX_ASSERT(mtx, !MUTEX_SPINBIT_LOCKED_P(mtx)); | | 403 | MUTEX_ASSERT(mtx, !MUTEX_SPINBIT_LOCKED_P(mtx)); |
404 | } | | 404 | } |
405 | | | 405 | |
406 | LOCKDEBUG_FREE(MUTEX_DEBUG_P(mtx), mtx); | | 406 | LOCKDEBUG_FREE(MUTEX_DEBUG_P(mtx), mtx); |
407 | MUTEX_DESTROY(mtx); | | 407 | MUTEX_DESTROY(mtx); |
408 | } | | 408 | } |
409 | | | 409 | |
410 | #ifdef MULTIPROCESSOR | | 410 | #ifdef MULTIPROCESSOR |
411 | /* | | 411 | /* |
412 | * mutex_oncpu: | | 412 | * mutex_oncpu: |
413 | * | | 413 | * |
414 | * Return true if an adaptive mutex owner is running on a CPU in the | | 414 | * Return true if an adaptive mutex owner is running on a CPU in the |