summaryrefslogtreecommitdiffstats
path: root/sys/i386
diff options
context:
space:
mode:
authorjulian <julian@FreeBSD.org>2002-02-17 01:09:56 +0000
committerjulian <julian@FreeBSD.org>2002-02-17 01:09:56 +0000
commitabe785e035306225e97c6f57f5c2e4f6345f3b8d (patch)
tree3dd328b38aee15fdbfd88129f31df6365b57a0d8 /sys/i386
parent6308e9245c1de5e4199690f0516a64f552824f07 (diff)
downloadFreeBSD-src-abe785e035306225e97c6f57f5c2e4f6345f3b8d.zip
FreeBSD-src-abe785e035306225e97c6f57f5c2e4f6345f3b8d.tar.gz
If the credential on an incoming thread is correct, don't bother
reaquiring it. In the same vein, don't bother dropping the thread cred when goinf ot userland. We are guaranteed to nned it when we come back, (which we are guaranteed to do). Reviewed by: jhb@freebsd.org, bde@freebsd.org (slightly different version)
Diffstat (limited to 'sys/i386')
-rw-r--r--sys/i386/i386/trap.c14
1 files changed, 8 insertions, 6 deletions
diff --git a/sys/i386/i386/trap.c b/sys/i386/i386/trap.c
index 07067c4..bc31c8c 100644
--- a/sys/i386/i386/trap.c
+++ b/sys/i386/i386/trap.c
@@ -256,9 +256,8 @@ trap(frame)
sticks = td->td_kse->ke_sticks;
td->td_frame = &frame;
KASSERT(td->td_ucred == NULL, ("already have a ucred"));
- PROC_LOCK(p);
- td->td_ucred = crhold(p->p_ucred);
- PROC_UNLOCK(p);
+ if (td->td_ucred != p->p_ucred)
+ cred_update_thread(td);
switch (type) {
case T_PRIVINFLT: /* privileged instruction fault */
@@ -644,10 +643,12 @@ user:
userret(td, &frame, sticks);
mtx_assert(&Giant, MA_NOTOWNED);
userout:
+#ifdef INVARIANTS
mtx_lock(&Giant);
crfree(td->td_ucred);
mtx_unlock(&Giant);
td->td_ucred = NULL;
+#endif
out:
return;
}
@@ -954,9 +955,8 @@ syscall(frame)
sticks = td->td_kse->ke_sticks;
td->td_frame = &frame;
KASSERT(td->td_ucred == NULL, ("already have a ucred"));
- PROC_LOCK(p);
- td->td_ucred = crhold(p->p_ucred);
- PROC_UNLOCK(p);
+ if (td->td_ucred != p->p_ucred)
+ cred_update_thread(td);
params = (caddr_t)frame.tf_esp + sizeof(int);
code = frame.tf_eax;
orig_tf_eflags = frame.tf_eflags;
@@ -1099,10 +1099,12 @@ bad:
*/
STOPEVENT(p, S_SCX, code);
+#ifdef INVARIANTS
mtx_lock(&Giant);
crfree(td->td_ucred);
mtx_unlock(&Giant);
td->td_ucred = NULL;
+#endif
#ifdef WITNESS
if (witness_list(td)) {
panic("system call %s returning with mutex(s) held\n",
OpenPOWER on IntegriCloud