Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 31 Dec 2007 01:36:44 GMT
From:      John Birrell <jb@FreeBSD.org>
To:        Perforce Change Reviews <perforce@freebsd.org>
Subject:   PERFORCE change 132140 for review
Message-ID:  <200712310136.lBV1aivQ092398@repoman.freebsd.org>

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

Change 132140 by jb@jb_freebsd1 on 2007/12/31 01:35:52

	For the time being, force debug mode on so we can get a list of the
	leaked allocations (if any).
	
	Use stack_print_ddb() instead of stack_print() to avoid tripping over
	locks. It _is_ a debug routine anyway and of course this means that
	the module will only load into a kernel containing DDB.
	
	I'm not sure when the SYSUNINIT should run. If it runs too early it
	reports allocations that are still to be freed. Not all modules are
	device drivers, so SI_SUB_DRIVERS probably isn't correct. Certainly
	the DTrace modules have to operate as early in the kernel initialisation
	as possible to be useful tracing the boot process.
	
	Remove the 'static' from kmem_show() so that I can call it myself. I
	found that it was running after my symbols had been discarded, leaving
	the symbol names I was looking for defaulted to something unhelpful.
	
	Note that the ZFS references in this file will have to change. They
	don't belong here.

Affected files ...

.. //depot/projects/dtrace/src/sys/compat/opensolaris/kern/opensolaris_kmem.c#3 edit

Differences ...

==== //depot/projects/dtrace/src/sys/compat/opensolaris/kern/opensolaris_kmem.c#3 (text+ko) ====

@@ -40,6 +40,8 @@
 #include <vm/vm_kern.h>
 #include <vm/vm_map.h>
 
+#define KMEM_DEBUG
+
 #ifdef KMEM_DEBUG
 #include <sys/queue.h>
 #include <sys/stack.h>
@@ -236,7 +238,8 @@
 }
 
 #ifdef KMEM_DEBUG
-static void
+void kmem_show(void *);
+void
 kmem_show(void *dummy __unused)
 {
 	struct kmem_item *i;
@@ -248,12 +251,16 @@
 		printf("KMEM_DEBUG: Leaked elements:\n\n");
 		LIST_FOREACH(i, &kmem_items, next) {
 			printf("address=%p\n", i);
-			stack_print(&i->stack);
+			/*
+			 * Cheat and use the DDB routine
+			 * to avoid lock issues.
+			 */
+			stack_print_ddb(&i->stack);
 			printf("\n");
 		}
 	}
 	mtx_unlock(&kmem_items_mtx);
 }
 
-SYSUNINIT(sol_kmem, SI_SUB_DRIVERS, SI_ORDER_FIRST, kmem_show, NULL);
+SYSUNINIT(sol_kmem, SI_SUB_CPU, SI_ORDER_FIRST, kmem_show, NULL);
 #endif	/* KMEM_DEBUG */



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