Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 20 Apr 2006 21:57:04 GMT
From:      John Birrell <jb@FreeBSD.org>
To:        Perforce Change Reviews <perforce@freebsd.org>
Subject:   PERFORCE change 95730 for review
Message-ID:  <200604202157.k3KLv4MX024825@repoman.freebsd.org>

next in thread | raw e-mail | index | archive | help
http://perforce.freebsd.org/chv.cgi?CH=95730

Change 95730 by jb@jb_freebsd2 on 2006/04/20 21:56:40

	Use macros for memory and mutex calls where possible.
	
	Destroy the extra 2 mutexes which are part of the hack. See dtrace_load.c
	
	This function doesn't exist in Sun's dtrace.c. The code here comes
	from their dtrace_detach(). This device doesn't attach to a bus, so I
	prefer not to use the term 'detach'.

Affected files ...

.. //depot/projects/dtrace/src/sys/cddl/dev/dtrace/dtrace_unload.c#3 edit

Differences ...

==== //depot/projects/dtrace/src/sys/cddl/dev/dtrace/dtrace_unload.c#3 (text+ko) ====

@@ -29,31 +29,23 @@
 {
 	int error = 0;
 
-#ifdef DOODAD
 	mutex_enter(&cpu_lock);
-#endif
 	mutex_enter(&dtrace_provider_lock);
 	mutex_enter(&dtrace_lock);
 
-#ifdef DOODAD
 	ASSERT(dtrace_opens == 0);
-#endif
 
 	if (dtrace_helpers > 0) {
 		mutex_exit(&dtrace_provider_lock);
 		mutex_exit(&dtrace_lock);
-#ifdef DOODAD
 		mutex_exit(&cpu_lock);
-#endif
 		return (DDI_FAILURE);
 	}
 
 	if (dtrace_unregister((dtrace_provider_id_t)dtrace_provider) != 0) {
 		mutex_exit(&dtrace_provider_lock);
 		mutex_exit(&dtrace_lock);
-#ifdef DOODAD
 		mutex_exit(&cpu_lock);
-#endif
 		return (DDI_FAILURE);
 	}
 
@@ -78,6 +70,9 @@
 
 	bzero(&dtrace_anon, sizeof (dtrace_anon_t));
 	unregister_cpu_setup_func((cpu_setup_func_t *)dtrace_cpu_setup, NULL);
+#endif
+
+#ifdef DOODAD
 	dtrace_cpu_init = NULL;
 	dtrace_helpers_cleanup = NULL;
 	dtrace_helpers_fork = NULL;
@@ -89,17 +84,20 @@
 	dtrace_kreloc_fini = NULL;
 	dtrace_modload = NULL;
 	dtrace_modunload = NULL;
+#endif
 
 	mutex_exit(&cpu_lock);
 
 	if (dtrace_helptrace_enabled) {
-		kmem_free(dtrace_helptrace_buffer, dtrace_helptrace_bufsize);
+		free(dtrace_helptrace_buffer, M_DTRACE);
 		dtrace_helptrace_buffer = NULL;
 	}
 
-	kmem_free(dtrace_probes, dtrace_nprobes * sizeof (dtrace_probe_t *));
-	dtrace_probes = NULL;
-	dtrace_nprobes = 0;
+	if (dtrace_probes != NULL) {
+		free(dtrace_probes, M_DTRACE);
+		dtrace_probes = NULL;
+		dtrace_nprobes = 0;
+	}
 
 	dtrace_hash_destroy(dtrace_bymod);
 	dtrace_hash_destroy(dtrace_byfunc);
@@ -108,27 +106,29 @@
 	dtrace_byfunc = NULL;
 	dtrace_byname = NULL;
 
+#ifdef DOODAD
 	kmem_cache_destroy(dtrace_state_cache);
 	vmem_destroy(dtrace_minor);
 	vmem_destroy(dtrace_arena);
+#endif
 
 	if (dtrace_toxrange != NULL) {
-		kmem_free(dtrace_toxrange,
-		    dtrace_toxranges_max * sizeof (dtrace_toxrange_t));
+		free(dtrace_toxrange, M_DTRACE);
 		dtrace_toxrange = NULL;
 		dtrace_toxranges = 0;
 		dtrace_toxranges_max = 0;
 	}
 
+#ifdef DOODAD
 	ddi_remove_minor_node(dtrace_devi, NULL);
 	dtrace_devi = NULL;
 
 	ddi_soft_state_fini(&dtrace_softstate);
+#endif
 
 	ASSERT(dtrace_vtime_references == 0);
 	ASSERT(dtrace_opens == 0);
 	ASSERT(dtrace_retained == NULL);
-#endif
 
 	mtx_unlock(&dtrace_lock);
 	mtx_unlock(&dtrace_provider_lock);
@@ -153,5 +153,9 @@
 	mtx_destroy(&dtrace_provider_lock);
 	mtx_destroy(&dtrace_lock);
 
+	/* XXX Hack */
+	mtx_destroy(&cpu_lock);
+	mtx_destroy(&mod_lock);
+
 	return (error);
 }



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200604202157.k3KLv4MX024825>