summaryrefslogtreecommitdiffstats
path: root/sys/kern/kern_fork.c
diff options
context:
space:
mode:
authorjulian <julian@FreeBSD.org>2002-02-22 23:58:22 +0000
committerjulian <julian@FreeBSD.org>2002-02-22 23:58:22 +0000
commit53eb1d92192d6566baf1ef330f636ab7b9d70f4f (patch)
tree7d75b1e48c3b7ef34eb52967d22fcf93f2addadc /sys/kern/kern_fork.c
parent5b69d7da62f2398a3ef361c86be5ab099fd92ad0 (diff)
downloadFreeBSD-src-53eb1d92192d6566baf1ef330f636ab7b9d70f4f.zip
FreeBSD-src-53eb1d92192d6566baf1ef330f636ab7b9d70f4f.tar.gz
Add some DIAGNOSTIC code.
While in userland, keep the thread's ucred reference in a shadow field so that the usual place to store it is NULL. If DIAGNOSTIC is not set, the thread ucred is kept valid until the next kernel entry, at which time it is checked against the process cred and possibly corrected. Produces a BIG speedup in kernels with INVARIANTS set. (A previous commit corrected it for the non INVARIANTS case already) Reviewed by: dillon@freebsd.org
Diffstat (limited to 'sys/kern/kern_fork.c')
-rw-r--r--sys/kern/kern_fork.c15
1 files changed, 9 insertions, 6 deletions
diff --git a/sys/kern/kern_fork.c b/sys/kern/kern_fork.c
index 3cd3017..8fe1006 100644
--- a/sys/kern/kern_fork.c
+++ b/sys/kern/kern_fork.c
@@ -477,6 +477,9 @@ again:
PROC_LOCK(p1);
p2->p_ucred = crhold(p1->p_ucred);
td2->td_ucred = crhold(p2->p_ucred); /* XXXKSE */
+#ifdef DIAGNOSTIC /* see the comment in ast() */
+ td2->td_ucred_cache = NULL;
+#endif
if (p2->p_args)
p2->p_args->ar_ref++;
@@ -802,12 +805,12 @@ fork_exit(callout, arg, frame)
kthread_exit(0);
}
PROC_UNLOCK(p);
-#ifdef INVARIANTS
- mtx_lock(&Giant);
- crfree(td->td_ucred);
- mtx_unlock(&Giant);
- td->td_ucred = NULL;
-#endif
+#ifdef DIAGNOSTIC /* see the comment in ast() */
+ if (td->td_ucred_cache)
+ panic("fork_exit:thread already has cached ucred");
+ td->td_ucred_cache = td->td_ucred;
+ td->td_ucred = NULL;
+#endif /* DIAGNOSTIC */
mtx_assert(&Giant, MA_NOTOWNED);
}
OpenPOWER on IntegriCloud