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
This commit is contained in:
David Xu
2010-10-09 02:50:23 +00:00
parent a362d75576
commit cf7d9a8ca8
15 changed files with 216 additions and 155 deletions
+11 -3
View File
@@ -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;