ktrace: do a lockless check on fork to see if tracing is enabled

This saves 2 lock acquisitions in the common case.
This commit is contained in:
mjg 2016-08-10 15:25:44 +00:00
parent 0a1afe2a20
commit 6d8d343a28

View File

@ -572,9 +572,14 @@ void
ktrprocfork(struct proc *p1, struct proc *p2)
{
MPASS(p2->p_tracevp == NULL);
MPASS(p2->p_traceflag == 0);
if (p1->p_traceflag == 0)
return;
PROC_LOCK(p1);
mtx_lock(&ktrace_mtx);
KASSERT(p2->p_tracevp == NULL, ("new process has a ktrace vnode"));
if (p1->p_traceflag & KTRFAC_INHERIT) {
p2->p_traceflag = p1->p_traceflag;
if ((p2->p_tracevp = p1->p_tracevp) != NULL) {