- Grab the proc lock around CURSIG and postsig(). Don't release the proc

lock until after grabbing the sched_lock to avoid CURSIG racing with
  psignal.
- Don't grab Giant for addupc_task() as it isn't needed.

Reported by:	tegge (signal race), bde (addupc_task a while back)
This commit is contained in:
jhb 2001-06-22 23:05:11 +00:00
parent 8210b8d106
commit e5e16e09ad
5 changed files with 20 additions and 13 deletions

View File

@ -145,10 +145,12 @@ userret(p, frame, oticks)
int sig;
/* take pending signals */
PROC_LOCK(p);
while ((sig = CURSIG(p)) != 0)
postsig(sig);
mtx_lock_spin(&sched_lock);
PROC_UNLOCK_NOSWITCH();
p->p_pri.pri_level = p->p_pri.pri_user;
if (resched_wanted(p)) {
/*
@ -165,9 +167,11 @@ userret(p, frame, oticks)
mi_switch();
mtx_unlock_spin(&sched_lock);
PICKUP_GIANT();
PROC_LOCK(p);
while ((sig = CURSIG(p)) != 0)
postsig(sig);
mtx_lock_spin(&sched_lock);
PROC_UNLOCK_NOSWITCH(p);
}
/*
@ -175,8 +179,6 @@ userret(p, frame, oticks)
*/
if (p->p_sflag & PS_PROFIL) {
mtx_unlock_spin(&sched_lock);
if (!mtx_owned(&Giant))
mtx_lock(&Giant);
addupc_task(p, TRAPF_PC(frame),
(int)(p->p_sticks - oticks) * psratio);
} else

View File

@ -171,10 +171,12 @@ userret(p, frame, oticks)
{
int sig;
PROC_LOCK(p);
while ((sig = CURSIG(p)) != 0)
postsig(sig);
mtx_lock_spin(&sched_lock);
PROC_UNLOCK_NOSWITCH(p);
p->p_pri.pri_level = p->p_pri.pri_user;
if (resched_wanted(p)) {
/*
@ -191,9 +193,11 @@ userret(p, frame, oticks)
mi_switch();
mtx_unlock_spin(&sched_lock);
PICKUP_GIANT();
PROC_LOCK(p);
while ((sig = CURSIG(p)) != 0)
postsig(sig);
mtx_lock_spin(&sched_lock);
PROC_UNLOCK_NOSWITCH(p);
}
/*
@ -201,9 +205,6 @@ userret(p, frame, oticks)
*/
if (p->p_sflag & PS_PROFIL) {
mtx_unlock_spin(&sched_lock);
/* XXX - do we need Giant? */
if (!mtx_owned(&Giant))
mtx_lock(&Giant);
addupc_task(p, TRAPF_PC(frame),
(u_int)(p->p_sticks - oticks) * psratio);
} else

View File

@ -171,10 +171,12 @@ userret(p, frame, oticks)
{
int sig;
PROC_LOCK(p);
while ((sig = CURSIG(p)) != 0)
postsig(sig);
mtx_lock_spin(&sched_lock);
PROC_UNLOCK_NOSWITCH(p);
p->p_pri.pri_level = p->p_pri.pri_user;
if (resched_wanted(p)) {
/*
@ -191,9 +193,11 @@ userret(p, frame, oticks)
mi_switch();
mtx_unlock_spin(&sched_lock);
PICKUP_GIANT();
PROC_LOCK(p);
while ((sig = CURSIG(p)) != 0)
postsig(sig);
mtx_lock_spin(&sched_lock);
PROC_UNLOCK_NOSWITCH(p);
}
/*
@ -201,9 +205,6 @@ userret(p, frame, oticks)
*/
if (p->p_sflag & PS_PROFIL) {
mtx_unlock_spin(&sched_lock);
/* XXX - do we need Giant? */
if (!mtx_owned(&Giant))
mtx_lock(&Giant);
addupc_task(p, TRAPF_PC(frame),
(u_int)(p->p_sticks - oticks) * psratio);
} else

View File

@ -85,10 +85,12 @@ userret(register struct proc *p, struct trapframe *frame, u_quad_t oticks)
int sig;
/* take pending signals */
PROC_LOCK(p);
while ((sig = CURSIG(p)) != 0)
postsig(sig);
mtx_lock_spin(&sched_lock);
PROC_UNLOCK_NOSWITCH();
p->p_pri.pri_level = p->p_pri.pri_user;
if (resched_wanted(p)) {
/*
@ -105,9 +107,11 @@ userret(register struct proc *p, struct trapframe *frame, u_quad_t oticks)
mi_switch();
mtx_unlock_spin(&sched_lock);
PICKUP_GIANT();
PROC_LOCK(p);
while ((sig = CURSIG(p)) != 0)
postsig(sig);
mtx_lock_spin(&sched_lock);
PROC_UNLOCK_NOSWITCH(p);
}
/*
@ -115,8 +119,6 @@ userret(register struct proc *p, struct trapframe *frame, u_quad_t oticks)
*/
if (p->p_sflag & PS_PROFIL) {
mtx_unlock_spin(&sched_lock);
if (!mtx_owned(&Giant))
mtx_lock(&Giant);
addupc_task(p, TRAPF_PC(frame),
(int)(p->p_sticks - oticks) * psratio);
} else

View File

@ -171,10 +171,12 @@ userret(p, frame, oticks)
{
int sig;
PROC_LOCK(p);
while ((sig = CURSIG(p)) != 0)
postsig(sig);
mtx_lock_spin(&sched_lock);
PROC_UNLOCK_NOSWITCH(p);
p->p_pri.pri_level = p->p_pri.pri_user;
if (resched_wanted(p)) {
/*
@ -191,9 +193,11 @@ userret(p, frame, oticks)
mi_switch();
mtx_unlock_spin(&sched_lock);
PICKUP_GIANT();
PROC_LOCK(p);
while ((sig = CURSIG(p)) != 0)
postsig(sig);
mtx_lock_spin(&sched_lock);
PROC_UNLOCK_NOSWITCH(p);
}
/*
@ -201,9 +205,6 @@ userret(p, frame, oticks)
*/
if (p->p_sflag & PS_PROFIL) {
mtx_unlock_spin(&sched_lock);
/* XXX - do we need Giant? */
if (!mtx_owned(&Giant))
mtx_lock(&Giant);
addupc_task(p, TRAPF_PC(frame),
(u_int)(p->p_sticks - oticks) * psratio);
} else