PERFORCE change 229882 for review

Jonathan Anderson jonathan at FreeBSD.org
Tue Jun 18 10:26:57 UTC 2013


http://p4web.freebsd.org/@@229882?ac=10

Change 229882 by jonathan at jonathan-on-zenith on 2013/06/18 10:26:28

	Impprove printf-based handling of TESLA events in the kernel.

Affected files ...

.. //depot/projects/ctsrd/tesla/src/sys/contrib/tesla/libtesla/tesla_debug.c#4 edit
.. //depot/projects/ctsrd/tesla/src/sys/contrib/tesla/libtesla/tesla_notification.c#8 edit

Differences ...

==== //depot/projects/ctsrd/tesla/src/sys/contrib/tesla/libtesla/tesla_debug.c#4 (text+ko) ====

@@ -132,6 +132,24 @@
 tesla_debugging(const char *name)
 {
 #ifdef _KERNEL
+	/*
+	 * In the kernel, only print 'libtesla.{event,instance}*' output.
+	 */
+	static const char* allowed[] = {
+		"libtesla.event",
+		"libtesla.instance",
+		NULL,
+	};
+	const size_t len = sizeof(allowed) / sizeof(allowed[0]);
+
+	for (size_t i = 0; (i < len) && (allowed[i] != NULL); i++) {
+		const char *s = allowed[i];
+		const size_t len = strlen(s);
+
+		if (strncmp(s, name, len) == 0)
+			return 1;
+	}
+
 	return 0;
 #else
 #ifdef HAVE_ISSETUGID

==== //depot/projects/ctsrd/tesla/src/sys/contrib/tesla/libtesla/tesla_notification.c#8 (text+ko) ====

@@ -229,7 +229,7 @@
 	next = sprint_transitions(next, end, transp);
 	assert(next > buffer);
 
-	error("%s", buffer);
+	DEBUG(libtesla.instance.fail, "%s", buffer);
 }
 
 static void
@@ -255,7 +255,7 @@
 	next = sprint_transitions(next, end, transp);
 	assert(next > buffer);
 
-	error("%s", buffer);
+	DEBUG(libtesla.instance.fail, "%s", buffer);
 }
 
 static void
@@ -326,8 +326,8 @@
 
 
 /**
- * Default event handlers: always print, then use DTrace in the kernel
- * if it's available; if it isn't, panic on failure.
+ * Default event handlers: printf first (but disable in kernel), then
+ * either use DTrace or fail-stop if DTrace is not available.
  */
 const static struct tesla_event_handlers* const default_handlers[] = {
 	&printf_handlers,
@@ -340,7 +340,11 @@
 
 static struct tesla_event_metahandler default_event_handlers = {
 	.tem_length = sizeof(default_handlers) / sizeof(*default_handlers),
-	.tem_mask = 0xFFFF,
+#if defined(_KERNEL) && defined(KDTRACE_HOOKS)
+	.tem_mask = 0x2,
+#else
+	.tem_mask = 0x3,
+#endif
 	.tem_handlers = default_handlers,
 };
 


More information about the p4-projects mailing list