summaryrefslogtreecommitdiffstats
path: root/sys/kern/kern_umtx.c
diff options
context:
space:
mode:
authordavidxu <davidxu@FreeBSD.org>2010-10-09 02:50:23 +0000
committerdavidxu <davidxu@FreeBSD.org>2010-10-09 02:50:23 +0000
commit55194e796cd9e8eb27d9bb4ec9f07184e390d01a (patch)
tree84ad0652e39fc58da6ca522cc6bf55a188109780 /sys/kern/kern_umtx.c
parent6afff59f3c11c8f879672f8dbcb0a74bcbae79a5 (diff)
downloadFreeBSD-src-55194e796cd9e8eb27d9bb4ec9f07184e390d01a.zip
FreeBSD-src-55194e796cd9e8eb27d9bb4ec9f07184e390d01a.tar.gz
Create a global thread hash table to speed up thread lookup, use
rwlock to protect the table. In old code, thread lookup is done with process lock held, to find a thread, kernel has to iterate through process and thread list, this is quite inefficient. With this change, test shows in extreme case performance is dramatically improved. Earlier patch was reviewed by: jhb, julian
Diffstat (limited to 'sys/kern/kern_umtx.c')
-rw-r--r--sys/kern/kern_umtx.c11
1 files changed, 3 insertions, 8 deletions
diff --git a/sys/kern/kern_umtx.c b/sys/kern/kern_umtx.c
index bdae3e8..cf8c534 100644
--- a/sys/kern/kern_umtx.c
+++ b/sys/kern/kern_umtx.c
@@ -1588,20 +1588,15 @@ umtxq_sleep_pi(struct umtx_q *uq, struct umtx_pi *pi,
umtxq_insert(uq);
mtx_lock_spin(&umtx_lock);
if (pi->pi_owner == NULL) {
- /* XXX
- * Current, We only support process private PI-mutex,
- * we need a faster way to find an owner thread for
- * process-shared mutex (not available yet).
- */
mtx_unlock_spin(&umtx_lock);
- PROC_LOCK(curproc);
- td1 = thread_find(curproc, owner);
+ /* XXX Only look up thread in current process. */
+ td1 = tdfind(owner, curproc->p_pid);
mtx_lock_spin(&umtx_lock);
if (td1 != NULL && pi->pi_owner == NULL) {
uq1 = td1->td_umtxq;
umtx_pi_setowner(pi, td1);
}
- PROC_UNLOCK(curproc);
+ PROC_UNLOCK(td1->td_proc);
}
TAILQ_FOREACH(uq1, &pi->pi_blocked, uq_lockq) {
OpenPOWER on IntegriCloud