Date: Wed, 13 Jun 2007 13:53:53 GMT From: John Baldwin <jhb@FreeBSD.org> To: Perforce Change Reviews <perforce@freebsd.org> Subject: PERFORCE change 121575 for review Message-ID: <200706131353.l5DDrrdD012717@repoman.freebsd.org>
next in thread | raw e-mail | index | archive | help
http://perforce.freebsd.org/chv.cgi?CH=121575 Change 121575 by jhb@jhb_mutex on 2007/06/13 13:53:32 Try to de-pessimize ktrace locking some. Affected files ... .. //depot/projects/smpng/sys/kern/kern_exit.c#124 edit .. //depot/projects/smpng/sys/kern/kern_ktrace.c#60 edit Differences ... ==== //depot/projects/smpng/sys/kern/kern_exit.c#124 (text+ko) ==== @@ -355,26 +355,32 @@ mtx_unlock(&Giant); #ifdef KTRACE /* - * Drain any pending records on the thread and release the trace - * file. It might be better if drain-and-clear were atomic. + * Disable tracing, then drain any pending records and release + * the trace file. */ - ktrprocexit(td); - PROC_LOCK(p); - mtx_lock(&ktrace_mtx); - p->p_traceflag = 0; /* don't trace the vrele() */ - tracevp = p->p_tracevp; - p->p_tracevp = NULL; - tracecred = p->p_tracecred; - p->p_tracecred = NULL; - mtx_unlock(&ktrace_mtx); - PROC_UNLOCK(p); - if (tracevp != NULL) { - locked = VFS_LOCK_GIANT(tracevp->v_mount); - vrele(tracevp); - VFS_UNLOCK_GIANT(locked); + if (p->p_traceflag != 0) { + PROC_LOCK(p); + mtx_lock(&ktrace_mtx); + p->p_traceflag = 0; + mtx_unlock(&ktrace_mtx); + PROC_UNLOCK(p); + ktrprocexit(td); + PROC_LOCK(p); + mtx_lock(&ktrace_mtx); + tracevp = p->p_tracevp; + p->p_tracevp = NULL; + tracecred = p->p_tracecred; + p->p_tracecred = NULL; + mtx_unlock(&ktrace_mtx); + PROC_UNLOCK(p); + if (tracevp != NULL) { + locked = VFS_LOCK_GIANT(tracevp->v_mount); + vrele(tracevp); + VFS_UNLOCK_GIANT(locked); + } + if (tracecred != NULL) + crfree(tracecred); } - if (tracecred != NULL) - crfree(tracecred); #endif /* * Release reference to text vnode ==== //depot/projects/smpng/sys/kern/kern_ktrace.c#60 (text+ko) ==== @@ -444,6 +444,8 @@ ktruserret(struct thread *td) { + if (STAILQ_EMPTY(&td->td_proc->p_ktr)) + return; ktrace_enter(td); sx_xlock(&ktrace_sx); ktr_drain(td);
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200706131353.l5DDrrdD012717>
