- Release Giant a bit earlier on syscall exit.

- Don't try to grab Giant before postsig() in userret() as it is no longer
  needed.
- Don't grab Giant before psignal() in ast() but get the proc lock instead.
This commit is contained in:
John Baldwin 2001-03-07 03:53:39 +00:00
parent 5493ca946e
commit f227364a17
5 changed files with 59 additions and 87 deletions

View File

@ -104,11 +104,9 @@ userret(p, frame, oticks)
int sig;
/* take pending signals */
while ((sig = CURSIG(p)) != 0) {
if (!mtx_owned(&Giant))
mtx_lock(&Giant);
while ((sig = CURSIG(p)) != 0)
postsig(sig);
}
mtx_lock_spin(&sched_lock);
p->p_pri.pri_level = p->p_pri.pri_user;
if (resched_wanted()) {
@ -126,11 +124,8 @@ userret(p, frame, oticks)
mi_switch();
mtx_unlock_spin(&sched_lock);
PICKUP_GIANT();
while ((sig = CURSIG(p)) != 0) {
if (!mtx_owned(&Giant))
mtx_lock(&Giant);
while ((sig = CURSIG(p)) != 0)
postsig(sig);
}
mtx_lock_spin(&sched_lock);
}
@ -729,6 +724,7 @@ syscall(code, framep)
if (KTRPOINT(p, KTR_SYSRET))
ktrsysret(p->p_tracep, code, error, p->p_retval[0]);
#endif
mtx_unlock(&Giant);
/*
* This works because errno is findable through the
@ -736,7 +732,6 @@ syscall(code, framep)
* is not the case, this code will need to be revisited.
*/
STOPEVENT(p, S_SCX, code);
mtx_unlock(&Giant);
#ifdef WITNESS
if (witness_list(p)) {
@ -781,24 +776,24 @@ ast(framep)
p->p_sflag &= ~PS_OWEUPC;
mtx_unlock_spin(&sched_lock);
mtx_lock(&Giant);
mtx_lock_spin(&sched_lock);
mtx_lock_spin(&sched_lock); /* XXX */
addupc_task(p, p->p_stats->p_prof.pr_addr,
p->p_stats->p_prof.pr_ticks);
}
if (p->p_sflag & PS_ALRMPEND) {
p->p_sflag &= ~PS_ALRMPEND;
mtx_unlock_spin(&sched_lock);
if (!mtx_owned(&Giant))
mtx_lock(&Giant);
PROC_LOCK(p);
psignal(p, SIGVTALRM);
PROC_UNLOCK(p);
mtx_lock_spin(&sched_lock);
}
if (p->p_sflag & PS_PROFPEND) {
p->p_sflag &= ~PS_PROFPEND;
mtx_unlock_spin(&sched_lock);
if (!mtx_owned(&Giant))
mtx_lock(&Giant);
PROC_LOCK(p);
psignal(p, SIGPROF);
PROC_UNLOCK(p);
} else
mtx_unlock_spin(&sched_lock);

View File

@ -172,11 +172,8 @@ userret(p, frame, oticks)
{
int sig;
while ((sig = CURSIG(p)) != 0) {
if (!mtx_owned(&Giant))
mtx_lock(&Giant);
while ((sig = CURSIG(p)) != 0)
postsig(sig);
}
mtx_lock_spin(&sched_lock);
p->p_pri.pri_level = p->p_pri.pri_user;
@ -195,11 +192,8 @@ userret(p, frame, oticks)
mi_switch();
mtx_unlock_spin(&sched_lock);
PICKUP_GIANT();
while ((sig = CURSIG(p)) != 0) {
if (!mtx_owned(&Giant))
mtx_lock(&Giant);
while ((sig = CURSIG(p)) != 0)
postsig(sig);
}
mtx_lock_spin(&sched_lock);
}
@ -508,9 +502,9 @@ trap(frame)
*/
if (frame.tf_eip == (int)cpu_switch_load_gs) {
PCPU_GET(curpcb)->pcb_gs = 0;
mtx_lock(&Giant);
PROC_LOCK(p);
psignal(p, SIGBUS);
mtx_unlock(&Giant);
PROC_UNLOCK(p);
goto out;
}
@ -1246,6 +1240,12 @@ syscall(frame)
}
#endif
/*
* Release Giant if we had to get it
*/
if (mtx_owned(&Giant))
mtx_unlock(&Giant);
/*
* This works because errno is findable through the
* register set. If we ever support an emulation where this
@ -1253,12 +1253,6 @@ syscall(frame)
*/
STOPEVENT(p, S_SCX, code);
/*
* Release Giant if we had to get it
*/
if (mtx_owned(&Giant))
mtx_unlock(&Giant);
#ifdef WITNESS
if (witness_list(p)) {
panic("system call %s returning with mutex(s) held\n",
@ -1305,17 +1299,17 @@ ast(framep)
if (p->p_sflag & PS_ALRMPEND) {
p->p_sflag &= ~PS_ALRMPEND;
mtx_unlock_spin(&sched_lock);
if (!mtx_owned(&Giant))
mtx_lock(&Giant);
PROC_LOCK(p);
psignal(p, SIGVTALRM);
PROC_UNLOCK(p);
mtx_lock_spin(&sched_lock);
}
if (p->p_sflag & PS_PROFPEND) {
p->p_sflag &= ~PS_PROFPEND;
mtx_unlock_spin(&sched_lock);
if (!mtx_owned(&Giant))
mtx_lock(&Giant);
PROC_LOCK(p);
psignal(p, SIGPROF);
PROC_UNLOCK(p);
} else
mtx_unlock_spin(&sched_lock);

View File

@ -172,11 +172,8 @@ userret(p, frame, oticks)
{
int sig;
while ((sig = CURSIG(p)) != 0) {
if (!mtx_owned(&Giant))
mtx_lock(&Giant);
while ((sig = CURSIG(p)) != 0)
postsig(sig);
}
mtx_lock_spin(&sched_lock);
p->p_pri.pri_level = p->p_pri.pri_user;
@ -195,11 +192,8 @@ userret(p, frame, oticks)
mi_switch();
mtx_unlock_spin(&sched_lock);
PICKUP_GIANT();
while ((sig = CURSIG(p)) != 0) {
if (!mtx_owned(&Giant))
mtx_lock(&Giant);
while ((sig = CURSIG(p)) != 0)
postsig(sig);
}
mtx_lock_spin(&sched_lock);
}
@ -508,9 +502,9 @@ trap(frame)
*/
if (frame.tf_eip == (int)cpu_switch_load_gs) {
PCPU_GET(curpcb)->pcb_gs = 0;
mtx_lock(&Giant);
PROC_LOCK(p);
psignal(p, SIGBUS);
mtx_unlock(&Giant);
PROC_UNLOCK(p);
goto out;
}
@ -1246,6 +1240,12 @@ syscall(frame)
}
#endif
/*
* Release Giant if we had to get it
*/
if (mtx_owned(&Giant))
mtx_unlock(&Giant);
/*
* This works because errno is findable through the
* register set. If we ever support an emulation where this
@ -1253,12 +1253,6 @@ syscall(frame)
*/
STOPEVENT(p, S_SCX, code);
/*
* Release Giant if we had to get it
*/
if (mtx_owned(&Giant))
mtx_unlock(&Giant);
#ifdef WITNESS
if (witness_list(p)) {
panic("system call %s returning with mutex(s) held\n",
@ -1305,17 +1299,17 @@ ast(framep)
if (p->p_sflag & PS_ALRMPEND) {
p->p_sflag &= ~PS_ALRMPEND;
mtx_unlock_spin(&sched_lock);
if (!mtx_owned(&Giant))
mtx_lock(&Giant);
PROC_LOCK(p);
psignal(p, SIGVTALRM);
PROC_UNLOCK(p);
mtx_lock_spin(&sched_lock);
}
if (p->p_sflag & PS_PROFPEND) {
p->p_sflag &= ~PS_PROFPEND;
mtx_unlock_spin(&sched_lock);
if (!mtx_owned(&Giant))
mtx_lock(&Giant);
PROC_LOCK(p);
psignal(p, SIGPROF);
PROC_UNLOCK(p);
} else
mtx_unlock_spin(&sched_lock);

View File

@ -85,11 +85,9 @@ userret(register struct proc *p, struct trapframe *frame, u_quad_t oticks)
int sig;
/* take pending signals */
while ((sig = CURSIG(p)) != 0) {
if (!mtx_owned(&Giant))
mtx_lock(&Giant);
while ((sig = CURSIG(p)) != 0)
postsig(sig);
}
mtx_lock_spin(&sched_lock);
p->p_pri.pri_level = p->p_pri.pri_user;
if (resched_wanted()) {
@ -107,11 +105,8 @@ userret(register struct proc *p, struct trapframe *frame, u_quad_t oticks)
mi_switch();
mtx_unlock_spin(&sched_lock);
PICKUP_GIANT();
while ((sig = CURSIG(p)) != 0) {
if (!mtx_owned(&Giant))
mtx_lock(&Giant);
while ((sig = CURSIG(p)) != 0)
postsig(sig);
}
mtx_lock_spin(&sched_lock);
}
@ -604,6 +599,7 @@ syscall(int code, u_int64_t *args, struct trapframe *framep)
if (KTRPOINT(p, KTR_SYSRET))
ktrsysret(p->p_tracep, code, error, p->p_retval[0]);
#endif
mtx_unlock(&Giant);
/*
* This works because errno is findable through the
@ -611,7 +607,6 @@ syscall(int code, u_int64_t *args, struct trapframe *framep)
* is not the case, this code will need to be revisited.
*/
STOPEVENT(p, S_SCX, code);
mtx_unlock(&Giant);
#ifdef WITNESS
if (witness_list(p)) {
@ -665,17 +660,17 @@ ast(framep)
if (p->p_sflag & PS_ALRMPEND) {
p->p_sflag &= ~PS_ALRMPEND;
mtx_unlock_spin(&sched_lock);
if (!mtx_owned(&Giant))
mtx_lock(&Giant);
PROC_LOCK(p);
psignal(p, SIGVTALRM);
PROC_UNLOCK(p);
mtx_lock_spin(&sched_lock);
}
if (p->p_sflag & PS_PROFPEND) {
p->p_sflag &= ~PS_PROFPEND;
mtx_unlock_spin(&sched_lock);
if (!mtx_owned(&Giant))
mtx_lock(&Giant);
PROC_LOCK(p);
psignal(p, SIGPROF);
PROC_UNLOCK(p);
} else
mtx_unlock_spin(&sched_lock);

View File

@ -172,11 +172,8 @@ userret(p, frame, oticks)
{
int sig;
while ((sig = CURSIG(p)) != 0) {
if (!mtx_owned(&Giant))
mtx_lock(&Giant);
while ((sig = CURSIG(p)) != 0)
postsig(sig);
}
mtx_lock_spin(&sched_lock);
p->p_pri.pri_level = p->p_pri.pri_user;
@ -195,11 +192,8 @@ userret(p, frame, oticks)
mi_switch();
mtx_unlock_spin(&sched_lock);
PICKUP_GIANT();
while ((sig = CURSIG(p)) != 0) {
if (!mtx_owned(&Giant))
mtx_lock(&Giant);
while ((sig = CURSIG(p)) != 0)
postsig(sig);
}
mtx_lock_spin(&sched_lock);
}
@ -508,9 +502,9 @@ trap(frame)
*/
if (frame.tf_eip == (int)cpu_switch_load_gs) {
PCPU_GET(curpcb)->pcb_gs = 0;
mtx_lock(&Giant);
PROC_LOCK(p);
psignal(p, SIGBUS);
mtx_unlock(&Giant);
PROC_UNLOCK(p);
goto out;
}
@ -1246,6 +1240,12 @@ syscall(frame)
}
#endif
/*
* Release Giant if we had to get it
*/
if (mtx_owned(&Giant))
mtx_unlock(&Giant);
/*
* This works because errno is findable through the
* register set. If we ever support an emulation where this
@ -1253,12 +1253,6 @@ syscall(frame)
*/
STOPEVENT(p, S_SCX, code);
/*
* Release Giant if we had to get it
*/
if (mtx_owned(&Giant))
mtx_unlock(&Giant);
#ifdef WITNESS
if (witness_list(p)) {
panic("system call %s returning with mutex(s) held\n",
@ -1305,17 +1299,17 @@ ast(framep)
if (p->p_sflag & PS_ALRMPEND) {
p->p_sflag &= ~PS_ALRMPEND;
mtx_unlock_spin(&sched_lock);
if (!mtx_owned(&Giant))
mtx_lock(&Giant);
PROC_LOCK(p);
psignal(p, SIGVTALRM);
PROC_UNLOCK(p);
mtx_lock_spin(&sched_lock);
}
if (p->p_sflag & PS_PROFPEND) {
p->p_sflag &= ~PS_PROFPEND;
mtx_unlock_spin(&sched_lock);
if (!mtx_owned(&Giant))
mtx_lock(&Giant);
PROC_LOCK(p);
psignal(p, SIGPROF);
PROC_UNLOCK(p);
} else
mtx_unlock_spin(&sched_lock);