summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjeff <jeff@FreeBSD.org>2003-05-25 18:18:32 +0000
committerjeff <jeff@FreeBSD.org>2003-05-25 18:18:32 +0000
commit4c8aa154ff7fbfb6beeb7489a9418f8b93e91b12 (patch)
treed968160f8f79381b45db7145527fc3e55cc1e6f6
parentf716dc5d968bece30da1ce41f673a328d1d4ef9f (diff)
downloadFreeBSD-src-4c8aa154ff7fbfb6beeb7489a9418f8b93e91b12.zip
FreeBSD-src-4c8aa154ff7fbfb6beeb7489a9418f8b93e91b12.tar.gz
- Create a new lock, umtx_lock, for use instead of the proc lock for
protecting the umtx queues. We can't use the proc lock because we need to hold the lock across calls to casuptr, which can fault. Approved by: re
-rw-r--r--sys/kern/kern_umtx.c19
1 files changed, 13 insertions, 6 deletions
diff --git a/sys/kern/kern_umtx.c b/sys/kern/kern_umtx.c
index 8c01669..bd0f524 100644
--- a/sys/kern/kern_umtx.c
+++ b/sys/kern/kern_umtx.c
@@ -39,6 +39,13 @@
#include <sys/thr.h>
#include <sys/umtx.h>
+#define UMTX_LOCK() mtx_lock(&umtx_lock);
+#define UMTX_UNLOCK() mtx_unlock(&umtx_lock);
+
+struct mtx umtx_lock;
+
+MTX_SYSINIT(umtx, &umtx_lock, "User-land mutex lock", MTX_DEF);
+
int
_umtx_lock(struct thread *td, struct _umtx_lock_args *uap)
/* struct umtx *umtx */
@@ -57,7 +64,7 @@ _umtx_lock(struct thread *td, struct _umtx_lock_args *uap)
*/
umtx = uap->umtx;
- PROC_LOCK(td->td_proc);
+ UMTX_LOCK();
for (;;) {
/*
@@ -103,7 +110,7 @@ _umtx_lock(struct thread *td, struct _umtx_lock_args *uap)
}
/*
- * We are now protected from further races via the proc lock.
+ * We are now protected from further races via umtx_lock.
* If userland messes with their mutex without using cmpset
* they will deadlock themselves but they will still be
* killable via signals.
@@ -146,7 +153,7 @@ _umtx_lock(struct thread *td, struct _umtx_lock_args *uap)
* used to maintain proper ordering.
*/
- error = msleep(&td->td_umtx, &td->td_proc->p_mtx,
+ error = msleep(&td->td_umtx, &umtx_lock,
td->td_priority | PCATCH, "umtx", 0);
/*
@@ -171,7 +178,7 @@ _umtx_lock(struct thread *td, struct _umtx_lock_args *uap)
}
out:
- PROC_UNLOCK(td->td_proc);
+ UMTX_UNLOCK();
return (error);
}
@@ -190,7 +197,7 @@ _umtx_unlock(struct thread *td, struct _umtx_unlock_args *uap)
error = 0;
umtx = uap->umtx;
- PROC_LOCK(td->td_proc);
+ UMTX_LOCK();
/*
* Make sure we own this mtx.
@@ -300,7 +307,7 @@ _umtx_unlock(struct thread *td, struct _umtx_unlock_args *uap)
wakeup(&td0->td_umtx);
out:
- PROC_UNLOCK(td->td_proc);
+ UMTX_UNLOCK();
return (error);
}
OpenPOWER on IntegriCloud