diff options
author | davidxu <davidxu@FreeBSD.org> | 2010-10-09 02:50:23 +0000 |
---|---|---|
committer | davidxu <davidxu@FreeBSD.org> | 2010-10-09 02:50:23 +0000 |
commit | 55194e796cd9e8eb27d9bb4ec9f07184e390d01a (patch) | |
tree | 84ad0652e39fc58da6ca522cc6bf55a188109780 /sys/kern/kern_kthread.c | |
parent | 6afff59f3c11c8f879672f8dbcb0a74bcbae79a5 (diff) | |
download | FreeBSD-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_kthread.c')
-rw-r--r-- | sys/kern/kern_kthread.c | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/sys/kern/kern_kthread.c b/sys/kern/kern_kthread.c index 264fc4a..9ab0922 100644 --- a/sys/kern/kern_kthread.c +++ b/sys/kern/kern_kthread.c @@ -295,6 +295,7 @@ kthread_add(void (*func)(void *), void *arg, struct proc *p, thread_unlock(oldtd); PROC_UNLOCK(p); + tidhash_add(newtd); /* Delay putting it on the run queue until now. */ if (!(flags & RFSTOPPED)) { @@ -314,6 +315,8 @@ kthread_exit(void) p = curthread->td_proc; + tidhash_remove(curthread); + /* A module may be waiting for us to exit. */ wakeup(curthread); PROC_LOCK(p); |