diff --git a/sys/alpha/alpha/trap.c b/sys/alpha/alpha/trap.c index 159ef751bea7..4106aef6b64a 100644 --- a/sys/alpha/alpha/trap.c +++ b/sys/alpha/alpha/trap.c @@ -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 diff --git a/sys/amd64/amd64/trap.c b/sys/amd64/amd64/trap.c index c1a4e2ec7537..5167ceb5c12a 100644 --- a/sys/amd64/amd64/trap.c +++ b/sys/amd64/amd64/trap.c @@ -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 diff --git a/sys/i386/i386/trap.c b/sys/i386/i386/trap.c index c1a4e2ec7537..5167ceb5c12a 100644 --- a/sys/i386/i386/trap.c +++ b/sys/i386/i386/trap.c @@ -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 diff --git a/sys/ia64/ia64/trap.c b/sys/ia64/ia64/trap.c index 5573178e176e..edb8767c3531 100644 --- a/sys/ia64/ia64/trap.c +++ b/sys/ia64/ia64/trap.c @@ -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 diff --git a/sys/kern/subr_trap.c b/sys/kern/subr_trap.c index c1a4e2ec7537..5167ceb5c12a 100644 --- a/sys/kern/subr_trap.c +++ b/sys/kern/subr_trap.c @@ -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