summaryrefslogtreecommitdiffstats
path: root/sys
diff options
context:
space:
mode:
authorjhb <jhb@FreeBSD.org>2002-03-20 21:12:04 +0000
committerjhb <jhb@FreeBSD.org>2002-03-20 21:12:04 +0000
commit2e425ee2fc74fd1bddb7f85e68599a682a2863fc (patch)
treefa3eed8e2b21cc26e95902d813d08e70311eee11 /sys
parent715dfdbcbe8ff5e275313a83ef7be76229d87ebf (diff)
downloadFreeBSD-src-2e425ee2fc74fd1bddb7f85e68599a682a2863fc.zip
FreeBSD-src-2e425ee2fc74fd1bddb7f85e68599a682a2863fc.tar.gz
Change the way we ensure td_ucred is NULL if DIAGNOSTIC is defined.
Instead of caching the ucred reference, just go ahead and eat the decerement and increment of the refcount. Now that Giant is pushed down into crfree(), we no longer have to get Giant in the common case. In the case when we are actually free'ing the ucred, we would normally free it on the next kernel entry, so the cost there is not new, just in a different place. This also removse td_cache_ucred from struct thread. This is still only done #ifdef DIAGNOSTIC. [ missed this file in the previous commit ] Tested on: i386, alpha
Diffstat (limited to 'sys')
-rw-r--r--sys/kern/subr_trap.c33
1 files changed, 3 insertions, 30 deletions
diff --git a/sys/kern/subr_trap.c b/sys/kern/subr_trap.c
index 4f18b28..ebd807e 100644
--- a/sys/kern/subr_trap.c
+++ b/sys/kern/subr_trap.c
@@ -161,29 +161,6 @@ ast(framep)
}
mtx_unlock_spin(&sched_lock);
-#ifdef DIAGNOSTIC
- /*
- * As a diagnostic tool we make sure that td->td_ucred
- * is NULL while we are in user space. This is
- * because theoreticaly this field is only defined
- * while the thread is in the kernel. Making it NULL
- * will immediatly trap invalid usage of this field.
- * In practice however we keep the reference to the ucred
- * because it's almost always going to be the same cred we will
- * need at the next syscall, and it can be expensive
- * to keep dropping and reacquiring the reference.
- * We thus stash it away elsewhere until we return
- * to the kernel, where we bring it back. If
- * DIAGNOSTIC is not defined we don't bother with
- * making it NULL, and just leave it in place.
- * (don't remove this comment without removing the pointers
- * to it in sys/proc.h, trap.c, kern/kern_fork.c and here.)
- */
- if (td->td_ucred)
- panic("ast:thread got a cred before reaching AST");
- td->td_ucred = td->td_ucred_cache;
- td->td_ucred_cache = NULL;
-#endif /* DIAGNOSTIC */
if (td->td_ucred != p->p_ucred)
cred_update_thread(td);
if (flags & KEF_OWEUPC && sflag & PS_PROFIL)
@@ -210,13 +187,9 @@ ast(framep)
}
userret(td, framep, sticks);
-#ifdef DIAGNOSTIC /* see comment above */
- if (td->td_ucred_cache)
- panic("ast:thread already has cached ucred");
- td->td_ucred_cache = td->td_ucred;
- td->td_ucred = NULL;
-#endif /* DIAGNOSTIC */
-
+#ifdef DIAGNOSTIC
+ cred_free_thread(td);
+#endif
s = cpu_critical_enter();
}
mtx_assert(&Giant, MA_NOTOWNED);
OpenPOWER on IntegriCloud