summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjhb <jhb@FreeBSD.org>2001-03-07 03:53:39 +0000
committerjhb <jhb@FreeBSD.org>2001-03-07 03:53:39 +0000
commit9c1fb038d7d49d0f13914c9cf74abbaf2252f87c (patch)
treeea5c5756813dfc5f6d0f22d45ad1cfb40be1cc74
parentf75a181b19d1c3a7bc52017f779a09ea9c8cecb0 (diff)
downloadFreeBSD-src-9c1fb038d7d49d0f13914c9cf74abbaf2252f87c.zip
FreeBSD-src-9c1fb038d7d49d0f13914c9cf74abbaf2252f87c.tar.gz
- 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.
-rw-r--r--sys/alpha/alpha/trap.c23
-rw-r--r--sys/amd64/amd64/trap.c34
-rw-r--r--sys/i386/i386/trap.c34
-rw-r--r--sys/ia64/ia64/trap.c21
-rw-r--r--sys/kern/subr_trap.c34
5 files changed, 59 insertions, 87 deletions
diff --git a/sys/alpha/alpha/trap.c b/sys/alpha/alpha/trap.c
index 9800090..3f182e5 100644
--- a/sys/alpha/alpha/trap.c
+++ b/sys/alpha/alpha/trap.c
@@ -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);
diff --git a/sys/amd64/amd64/trap.c b/sys/amd64/amd64/trap.c
index bb03fa6..7088d0c 100644
--- a/sys/amd64/amd64/trap.c
+++ b/sys/amd64/amd64/trap.c
@@ -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 @@ restart:
*/
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;
}
@@ -1247,18 +1241,18 @@ bad:
#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
* is not the case, this code will need to be revisited.
*/
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);
diff --git a/sys/i386/i386/trap.c b/sys/i386/i386/trap.c
index bb03fa6..7088d0c 100644
--- a/sys/i386/i386/trap.c
+++ b/sys/i386/i386/trap.c
@@ -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 @@ restart:
*/
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;
}
@@ -1247,18 +1241,18 @@ bad:
#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
* is not the case, this code will need to be revisited.
*/
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);
diff --git a/sys/ia64/ia64/trap.c b/sys/ia64/ia64/trap.c
index 1858ded..8486877 100644
--- a/sys/ia64/ia64/trap.c
+++ b/sys/ia64/ia64/trap.c
@@ -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);
diff --git a/sys/kern/subr_trap.c b/sys/kern/subr_trap.c
index bb03fa6..7088d0c 100644
--- a/sys/kern/subr_trap.c
+++ b/sys/kern/subr_trap.c
@@ -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 @@ restart:
*/
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;
}
@@ -1247,18 +1241,18 @@ bad:
#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
* is not the case, this code will need to be revisited.
*/
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);
OpenPOWER on IntegriCloud