From 35a86b35c172e8d9d3e39b2da6167f6c6e19dfe5 Mon Sep 17 00:00:00 2001 From: Andrew Gallatin Date: Tue, 19 Feb 2002 03:13:39 +0000 Subject: [PATCH] MFi386: merge changes from i386/trap.c rev 1.212 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 going to userland. We are guaranteed to need it when we come back, (which we are guaranteed to do). --- sys/alpha/alpha/trap.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/sys/alpha/alpha/trap.c b/sys/alpha/alpha/trap.c index c4c402a4d73..2cdf540d17f 100644 --- a/sys/alpha/alpha/trap.c +++ b/sys/alpha/alpha/trap.c @@ -298,9 +298,8 @@ trap(a0, a1, a2, entry, framep) sticks = td->td_kse->ke_sticks; td->td_frame = framep; 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); } else { sticks = 0; /* XXX bogus -Wuninitialized warning */ KASSERT(cold || td->td_ucred != NULL, @@ -626,10 +625,12 @@ out: framep->tf_regs[FRAME_SP] = alpha_pal_rdusp(); userret(td, framep, sticks); mtx_assert(&Giant, MA_NOTOWNED); +#ifdef INVARIANTS mtx_lock(&Giant); crfree(td->td_ucred); mtx_unlock(&Giant); td->td_ucred = NULL; +#endif } return; @@ -699,9 +700,8 @@ syscall(code, framep) opc = framep->tf_regs[FRAME_PC] - 4; sticks = td->td_kse->ke_sticks; 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); #ifdef DIAGNOSTIC alpha_fpstate_check(td); @@ -822,10 +822,12 @@ syscall(code, framep) */ 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",