Avoid unnecessary ppeers_lock acquisition in exit1.

MFC after:	1 week
This commit is contained in:
Mateusz Guzik 2014-10-05 07:21:41 +00:00
parent 6c572040c6
commit bad2520a2b

View File

@ -265,8 +265,8 @@ exit1(struct thread *td, int rv)
AUDIT_SYSCALL_EXIT(0, td);
#endif
/* Are we a task leader? */
if (p == p->p_leader) {
/* Are we a task leader with peers? */
if (p->p_peers != NULL && p == p->p_leader) {
mtx_lock(&ppeers_lock);
q = p->p_peers;
while (q != NULL) {
@ -337,15 +337,17 @@ exit1(struct thread *td, int rv)
/*
* Remove ourself from our leader's peer list and wake our leader.
*/
mtx_lock(&ppeers_lock);
if (p->p_leader->p_peers) {
q = p->p_leader;
while (q->p_peers != p)
q = q->p_peers;
q->p_peers = p->p_peers;
wakeup(p->p_leader);
if (p->p_leader->p_peers != NULL) {
mtx_lock(&ppeers_lock);
if (p->p_leader->p_peers != NULL) {
q = p->p_leader;
while (q->p_peers != p)
q = q->p_peers;
q->p_peers = p->p_peers;
wakeup(p->p_leader);
}
mtx_unlock(&ppeers_lock);
}
mtx_unlock(&ppeers_lock);
vmspace_exit(td);