summaryrefslogtreecommitdiff
path: root/sys/kern/kern_lock.c
diff options
context:
space:
mode:
authorMartin Pieuchot <mpi@cvs.openbsd.org>2017-12-04 09:51:04 +0000
committerMartin Pieuchot <mpi@cvs.openbsd.org>2017-12-04 09:51:04 +0000
commit1764f0df2a112e820709360ae1c631b59cc1bc05 (patch)
tree6882f126f28754a7a4010a36ac6b74bde6cbb1bf /sys/kern/kern_lock.c
parent7c011d9e8d8db99faeb35a7df465a3d0da5621ac (diff)
Change __mp_lock_held() to work with an arbitrary CPU info structure and
extend ddb(4) "ps /o" output to print which CPU is currently holding the KERNEL_LOCK(). Tested by dhill@, ok visa@
Diffstat (limited to 'sys/kern/kern_lock.c')
-rw-r--r--sys/kern/kern_lock.c14
1 files changed, 7 insertions, 7 deletions
diff --git a/sys/kern/kern_lock.c b/sys/kern/kern_lock.c
index 3b6adb16c93..f067a508bc7 100644
--- a/sys/kern/kern_lock.c
+++ b/sys/kern/kern_lock.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: kern_lock.c,v 1.51 2017/10/17 14:25:35 visa Exp $ */
+/* $OpenBSD: kern_lock.c,v 1.52 2017/12/04 09:51:03 mpi Exp $ */
/*
* Copyright (c) 1995
@@ -96,7 +96,7 @@ _kernel_lock_held(void)
{
if (panicstr)
return 1;
- return (__mp_lock_held(&kernel_lock));
+ return (__mp_lock_held(&kernel_lock, curcpu()));
}
#ifdef __USE_MI_MPLOCK
@@ -168,7 +168,7 @@ ___mp_lock(struct __mp_lock *mpl LOCK_FL_VARS)
unsigned long s;
#ifdef WITNESS
- if (!__mp_lock_held(mpl))
+ if (!__mp_lock_held(mpl, curcpu()))
WITNESS_CHECKORDER(&mpl->mpl_lock_obj,
LOP_EXCLUSIVE | LOP_NEWORDER, file, line, NULL);
#endif
@@ -191,7 +191,7 @@ ___mp_unlock(struct __mp_lock *mpl LOCK_FL_VARS)
unsigned long s;
#ifdef MP_LOCKDEBUG
- if (!__mp_lock_held(mpl)) {
+ if (!__mp_lock_held(mpl, curcpu())) {
db_printf("__mp_unlock(%p): not held lock\n", mpl);
db_enter();
}
@@ -244,7 +244,7 @@ ___mp_release_all_but_one(struct __mp_lock *mpl LOCK_FL_VARS)
#endif
#ifdef MP_LOCKDEBUG
- if (!__mp_lock_held(mpl)) {
+ if (!__mp_lock_held(mpl, curcpu())) {
db_printf("__mp_release_all_but_one(%p): not held lock\n", mpl);
db_enter();
}
@@ -263,9 +263,9 @@ ___mp_acquire_count(struct __mp_lock *mpl, int count LOCK_FL_VARS)
}
int
-__mp_lock_held(struct __mp_lock *mpl)
+__mp_lock_held(struct __mp_lock *mpl, struct cpu_info *ci)
{
- struct __mp_lock_cpu *cpu = &mpl->mpl_cpus[cpu_number()];
+ struct __mp_lock_cpu *cpu = &mpl->mpl_cpus[CPU_INFO_UNIT(ci)];
return (cpu->mplc_ticket == mpl->mpl_ticket && cpu->mplc_depth > 0);
}