PERFORCE change 134244 for review

John Birrell jb at FreeBSD.org
Sun Jan 27 13:45:30 PST 2008


http://perforce.freebsd.org/chv.cgi?CH=134244

Change 134244 by jb at jb_freebsd1 on 2008/01/27 21:45:22

	It seems I need an sx lock to be able to check if it locked.
	It's an internal lock here, so the lock consistency is determined
	by the code in this file only.
	
	Specify SX_NOWITNESS to avoid the bogis LOR reports that WITNESS
	outputs when internal locks like this are obtained when there
	are various other locks already obtained. This lock has no bearing
	on the order that other locks are obtained.

Affected files ...

.. //depot/projects/dtrace/src/sys/kern/kern_sdt.c#8 edit

Differences ...

==== //depot/projects/dtrace/src/sys/kern/kern_sdt.c#8 (text+ko) ====

@@ -39,8 +39,8 @@
 #include <sys/kernel.h>
 #include <sys/linker.h>
 #include <sys/lock.h>
-#include <sys/mutex.h>
 #include <sys/proc.h>
+#include <sys/sx.h>
 #include <sys/sdt.h>
 
 /*
@@ -51,8 +51,7 @@
 /*
  * Mutex to serialise access to the SDT provider list.
  */
-static struct mtx sdt_mtx;
-MTX_SYSINIT(&sdt_mtx, "Statically Defined Tracing", NULL, MTX_DEF);
+static struct sx sdt_sx;
 
 /*
  * Hook for the DTrace probe function. The 'sdt' provider will set this
@@ -80,13 +79,13 @@
 {
 	struct sdt_provider *prov = arg;
 
-	mtx_lock(&sdt_mtx);
+	sx_xlock(&sdt_sx);
 
 	TAILQ_INSERT_TAIL(&sdt_provider_list, prov, prov_entry);
 
 	TAILQ_INIT(&prov->probe_list);
 
-	mtx_unlock(&sdt_mtx);
+	sx_xunlock(&sdt_sx);
 }
 
 /*
@@ -97,11 +96,11 @@
 {
 	struct sdt_provider *prov = arg;
 
-	mtx_lock(&sdt_mtx);
+	sx_xlock(&sdt_sx);
 
 	TAILQ_REMOVE(&sdt_provider_list, prov, prov_entry);
 
-	mtx_unlock(&sdt_mtx);
+	sx_xunlock(&sdt_sx);
 }
 
 /*
@@ -121,7 +120,7 @@
 		return;
 	}
 
-	mtx_lock(&sdt_mtx);
+	sx_xlock(&sdt_sx);
 
 	TAILQ_INSERT_TAIL(&probe->prov->probe_list, probe, probe_entry);
 
@@ -129,7 +128,7 @@
 
 	probe->state = SDT_INIT;
 
-	mtx_unlock(&sdt_mtx);
+	sx_xunlock(&sdt_sx);
 }
 
 /*
@@ -140,14 +139,14 @@
 {
 	struct sdt_probe *probe = arg;
 
-	mtx_lock(&sdt_mtx);
+	sx_xlock(&sdt_sx);
 
 	if (probe->state == SDT_INIT) {
 		TAILQ_REMOVE(&probe->prov->probe_list, probe, probe_entry);
 		probe->state = SDT_UNINIT;
 	}
 
-	mtx_unlock(&sdt_mtx);
+	sx_xunlock(&sdt_sx);
 }
 
 /*
@@ -158,13 +157,13 @@
 {
 	struct sdt_argtype *argtype = arg;
 
-	mtx_lock(&sdt_mtx);
+	sx_xlock(&sdt_sx);
 
 	TAILQ_INSERT_TAIL(&argtype->probe->argtype_list, argtype, argtype_entry);
 
 	argtype->probe->n_args++;
 
-	mtx_unlock(&sdt_mtx);
+	sx_xunlock(&sdt_sx);
 }
 
 /*
@@ -175,17 +174,17 @@
 {
 	struct sdt_argtype *argtype = arg;
 
-	mtx_lock(&sdt_mtx);
+	sx_xlock(&sdt_sx);
 
 	TAILQ_REMOVE(&argtype->probe->argtype_list, argtype, argtype_entry);
 
-	mtx_unlock(&sdt_mtx);
+	sx_xunlock(&sdt_sx);
 }
 
 static void
 sdt_init(void *arg)
 { 
-	sx_init(&sdt_mtx, "Statically Defined Tracing");
+	sx_init_flags(&sdt_sx, "Statically Defined Tracing", SX_NOWITNESS);
 
 	TAILQ_INIT(&sdt_provider_list);
 }
@@ -195,7 +194,7 @@
 static void
 sdt_uninit(void *arg)
 { 
-	sx_destroy(&sdt_mtx);
+	sx_destroy(&sdt_sx);
 }
 
 SYSUNINIT(sdt, SI_SUB_KDTRACE, SI_ORDER_FIRST, sdt_uninit, NULL);
@@ -209,14 +208,14 @@
 	int error = 0;
 	struct sdt_provider *prov;
 
-	mtx_lock(&sdt_mtx);
+	sx_xlock(&sdt_sx);
 
 	TAILQ_FOREACH(prov, &sdt_provider_list, prov_entry) {
 		if ((error = callback_func(prov, arg)) != 0)
 			break;
 	}
 
-	mtx_unlock(&sdt_mtx);
+	sx_xunlock(&sdt_sx);
 
 	return (error);
 }
@@ -232,9 +231,9 @@
 	int locked;
 	struct sdt_probe *probe;
 
-	locked = mtx_locked(&sdt_mtx);
+	locked = sx_xlocked(&sdt_sx);
 	if (!locked)
-		mtx_lock(&sdt_mtx);
+		sx_xlock(&sdt_sx);
 
 	TAILQ_FOREACH(probe, &prov->probe_list, probe_entry) {
 		if ((error = callback_func(probe, arg)) != 0)
@@ -242,7 +241,7 @@
 	}
 
 	if (!locked)
-		mtx_unlock(&sdt_mtx);
+		sx_xunlock(&sdt_sx);
 
 	return (error);
 }
@@ -258,9 +257,9 @@
 	int locked;
 	struct sdt_argtype *argtype;
 
-	locked = mtx_locked(&sdt_mtx);
+	locked = sx_xlocked(&sdt_sx);
 	if (!locked)
-		mtx_lock(&sdt_mtx);
+		sx_xlock(&sdt_sx);
 
 	TAILQ_FOREACH(argtype, &probe->argtype_list, argtype_entry) {
 		if ((error = callback_func(argtype, arg)) != 0)
@@ -268,7 +267,7 @@
 	}
 
 	if (!locked)
-		mtx_unlock(&sdt_mtx);
+		sx_xunlock(&sdt_sx);
 
 	return (error);
 }


More information about the p4-projects mailing list