version 1.151, 2011/07/17 20:54:52 |
version 1.151.2.3, 2014/05/22 11:41:03 |
Line 53 __KERNEL_RCSID(0, "$NetBSD$"); |
|
Line 53 __KERNEL_RCSID(0, "$NetBSD$"); |
|
bool kernel_lock_dodebug; |
bool kernel_lock_dodebug; |
|
|
__cpu_simple_lock_t kernel_lock[CACHE_LINE_SIZE / sizeof(__cpu_simple_lock_t)] |
__cpu_simple_lock_t kernel_lock[CACHE_LINE_SIZE / sizeof(__cpu_simple_lock_t)] |
__aligned(CACHE_LINE_SIZE); |
__cacheline_aligned; |
|
|
void |
void |
assert_sleepable(void) |
assert_sleepable(void) |
|
|
kernel_lock_init(void) |
kernel_lock_init(void) |
{ |
{ |
|
|
CTASSERT(CACHE_LINE_SIZE >= sizeof(__cpu_simple_lock_t)); |
|
__cpu_simple_lock_init(kernel_lock); |
__cpu_simple_lock_init(kernel_lock); |
kernel_lock_dodebug = LOCKDEBUG_ALLOC(kernel_lock, &_kernel_lock_ops, |
kernel_lock_dodebug = LOCKDEBUG_ALLOC(kernel_lock, &_kernel_lock_ops, |
RETURN_ADDRESS); |
RETURN_ADDRESS); |
} |
} |
|
CTASSERT(CACHE_LINE_SIZE >= sizeof(__cpu_simple_lock_t)); |
|
|
/* |
/* |
* Print debugging information about the kernel lock. |
* Print debugging information about the kernel lock. |
Line 175 _kernel_lock(int nlocks) |
|
Line 175 _kernel_lock(int nlocks) |
|
|
|
_KERNEL_LOCK_ASSERT(l->l_blcnt == 0); |
_KERNEL_LOCK_ASSERT(l->l_blcnt == 0); |
LOCKDEBUG_WANTLOCK(kernel_lock_dodebug, kernel_lock, RETURN_ADDRESS, |
LOCKDEBUG_WANTLOCK(kernel_lock_dodebug, kernel_lock, RETURN_ADDRESS, |
false, false); |
0); |
|
|
if (__cpu_simple_lock_try(kernel_lock)) { |
if (__cpu_simple_lock_try(kernel_lock)) { |
ci->ci_biglock_count = nlocks; |
ci->ci_biglock_count = nlocks; |
Line 305 _kernel_unlock(int nlocks, int *countp) |
|
Line 305 _kernel_unlock(int nlocks, int *countp) |
|
if (countp != NULL) |
if (countp != NULL) |
*countp = olocks; |
*countp = olocks; |
} |
} |
|
|
|
bool |
|
_kernel_locked_p(void) |
|
{ |
|
return __SIMPLELOCK_LOCKED_P(kernel_lock); |
|
} |