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/uipc_mqueue.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/uipc_mqueue.c')
-rw-r--r-- | sys/kern/uipc_mqueue.c | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/sys/kern/uipc_mqueue.c b/sys/kern/uipc_mqueue.c index de65462..30c1aa9 100644 --- a/sys/kern/uipc_mqueue.c +++ b/sys/kern/uipc_mqueue.c @@ -1747,15 +1747,23 @@ static void mqueue_send_notification(struct mqueue *mq) { struct mqueue_notifier *nt; + struct thread *td; struct proc *p; + int error; mtx_assert(&mq->mq_mutex, MA_OWNED); nt = mq->mq_notifier; if (nt->nt_sigev.sigev_notify != SIGEV_NONE) { p = nt->nt_proc; - PROC_LOCK(p); - if (!KSI_ONQ(&nt->nt_ksi)) - psignal_event(p, &nt->nt_sigev, &nt->nt_ksi); + error = sigev_findtd(p, &nt->nt_sigev, &td); + if (error) { + mq->mq_notifier = NULL; + return; + } + if (!KSI_ONQ(&nt->nt_ksi)) { + ksiginfo_set_sigev(&nt->nt_ksi, &nt->nt_sigev); + tdsendsignal(p, td, nt->nt_ksi.ksi_signo, &nt->nt_ksi); + } PROC_UNLOCK(p); } mq->mq_notifier = NULL; |