Date: Tue, 8 Oct 2013 12:56:46 +0000 (UTC) From: Mark Johnston <markj@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r256148 - in head/sys/cddl: contrib/opensolaris/uts/common/dtrace dev/dtrace Message-ID: <201310081256.r98CukaV008107@svn.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: markj Date: Tue Oct 8 12:56:46 2013 New Revision: 256148 URL: http://svnweb.freebsd.org/changeset/base/256148 Log: Initialize and free the DTrace taskqueue in the dtrace module load/unload handlers rather than in the dtrace device open/close methods. The current approach can cause a panic if the device is closed which the taskqueue thread is active, or if a kernel module containing a provider is unloaded while retained enablings are present and the dtrace device isn't opened. Submitted by: gibbs (original version) Reviewed by: gibbs Approved by: re (glebius) MFC after: 2 weeks Modified: head/sys/cddl/contrib/opensolaris/uts/common/dtrace/dtrace.c head/sys/cddl/dev/dtrace/dtrace_load.c head/sys/cddl/dev/dtrace/dtrace_unload.c Modified: head/sys/cddl/contrib/opensolaris/uts/common/dtrace/dtrace.c ============================================================================== --- head/sys/cddl/contrib/opensolaris/uts/common/dtrace/dtrace.c Tue Oct 8 12:42:52 2013 (r256147) +++ head/sys/cddl/contrib/opensolaris/uts/common/dtrace/dtrace.c Tue Oct 8 12:56:46 2013 (r256148) @@ -15751,10 +15751,6 @@ dtrace_open(struct cdev *dev, int oflags #else devfs_set_cdevpriv(state, dtrace_dtr); #endif - /* This code actually belongs in dtrace_attach() */ - if (dtrace_opens == 1) - dtrace_taskq = taskq_create("dtrace_taskq", 1, maxclsyspri, - 1, INT_MAX, 0); #endif mutex_exit(&cpu_lock); @@ -15842,11 +15838,6 @@ dtrace_dtr(void *data) (void) kdi_dtrace_set(KDI_DTSET_DTRACE_DEACTIVATE); #else --dtrace_opens; - /* This code actually belongs in dtrace_detach() */ - if ((dtrace_opens == 0) && (dtrace_taskq != NULL)) { - taskq_destroy(dtrace_taskq); - dtrace_taskq = NULL; - } #endif mutex_exit(&dtrace_lock); Modified: head/sys/cddl/dev/dtrace/dtrace_load.c ============================================================================== --- head/sys/cddl/dev/dtrace/dtrace_load.c Tue Oct 8 12:42:52 2013 (r256147) +++ head/sys/cddl/dev/dtrace/dtrace_load.c Tue Oct 8 12:56:46 2013 (r256148) @@ -56,6 +56,8 @@ dtrace_load(void *dummy) /* Hang our hook for exceptions. */ dtrace_invop_init(); + dtrace_taskq = taskq_create("dtrace_taskq", 1, maxclsyspri, 0, 0, 0); + /* Register callbacks for linker file load and unload events. */ dtrace_kld_load_tag = EVENTHANDLER_REGISTER(kld_load, dtrace_kld_load, NULL, EVENTHANDLER_PRI_ANY); Modified: head/sys/cddl/dev/dtrace/dtrace_unload.c ============================================================================== --- head/sys/cddl/dev/dtrace/dtrace_unload.c Tue Oct 8 12:42:52 2013 (r256147) +++ head/sys/cddl/dev/dtrace/dtrace_unload.c Tue Oct 8 12:56:46 2013 (r256148) @@ -127,6 +127,8 @@ dtrace_unload() mutex_destroy(&dtrace_errlock); #endif + taskq_destroy(dtrace_taskq); + /* Reset our hook for exceptions. */ dtrace_invop_uninit();
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201310081256.r98CukaV008107>