Autoconf --enable-debug-* cleanup

Cleanup the --enable-debug-* configure options, this has been pending
for quite some time and I am glad I finally got to it.  To summerize:

1) All SPL_AC_DEBUG_* macros were updated to be a more autoconf
friendly.  This mainly involved shift to the GNU approved usage of
AC_ARG_ENABLE and ensuring AS_IF is used rather than directly using
an if [ test ] construct.

2) --enable-debug-kmem=yes by default.  This simply enabled keeping
a running tally of total memory allocated and freed and reporting a
memory leak if there was one at module unload.  Additionally, it
ensure /proc/spl/kmem/slab will exist by default which is handy.
The overhead is low for this and it should not impact performance.

3) --enable-debug-kmem-tracking=no by default.  This option was added
to provide a configure option to enable to detailed memory allocation
tracking.  This support was always there but you had to know where to
turn it on.  By default this support is disabled because it is known
to badly hurt performence, however it is invaluable when chasing a
memory leak.

4) --enable-debug-kstat removed.  After further reflection I can't see
why you would ever really want to turn this support off.  It is now
always on which had the nice side effect of simplifying the proc handling
code in spl-proc.c.  We can now always assume the top level directory
will be there.

5) --enable-debug-callb removed.  This never really did anything, it was
put in provisionally because it might have been needed.  It turns out
it was not so I am just removing it to prevent confusion.
This commit is contained in:
Brian Behlendorf
2009-10-30 13:58:51 -07:00
parent 302b88e6ab
commit 055ffd98cf
10 changed files with 159 additions and 330 deletions
+14 -12
View File
@@ -210,12 +210,9 @@ EXPORT_SYMBOL(vmem_size);
/*
* Memory allocation interfaces and debugging for basic kmem_*
* and vmem_* style memory allocation. When DEBUG_KMEM is enable
* all allocations will be tracked when they are allocated and
* freed. When the SPL module is unload a list of all leaked
* addresses and where they were allocated will be dumped to the
* console. Enabling this feature has a significant impant on
* performance but it makes finding memory leaks staight forward.
* and vmem_* style memory allocation. When DEBUG_KMEM is enabled
* the SPL will keep track of the total memory allocated, and
* report any memory leaked when the module is unloaded.
*/
#ifdef DEBUG_KMEM
/* Shim layer memory accounting */
@@ -231,13 +228,18 @@ EXPORT_SYMBOL(vmem_alloc_used);
EXPORT_SYMBOL(vmem_alloc_max);
EXPORT_SYMBOL(kmem_warning_flag);
# ifdef DEBUG_KMEM_TRACKING
/* XXX - Not to surprisingly with debugging enabled the xmem_locks are very
* highly contended particularly on xfree(). If we want to run with this
* detailed debugging enabled for anything other than debugging we need to
* minimize the contention by moving to a lock per xmem_table entry model.
/* When DEBUG_KMEM_TRACKING is enabled not only will total bytes be tracked
* but also the location of every alloc and free. When the SPL module is
* unloaded a list of all leaked addresses and where they were allocated
* will be dumped to the console. Enabling this feature has a significant
* impact on performance but it makes finding memory leaks straight forward.
*
* Not surprisingly with debugging enabled the xmem_locks are very highly
* contended particularly on xfree(). If we want to run with this detailed
* debugging enabled for anything other than debugging we need to minimize
* the contention by moving to a lock per xmem_table entry model.
*/
# ifdef DEBUG_KMEM_TRACKING
# define KMEM_HASH_BITS 10
# define KMEM_TABLE_SIZE (1 << KMEM_HASH_BITS)
-8
View File
@@ -26,8 +26,6 @@
#include <sys/kstat.h>
#ifdef DEBUG_KSTAT
static spinlock_t kstat_lock;
static struct list_head kstat_list;
static kid_t kstat_id;
@@ -470,17 +468,13 @@ __kstat_delete(kstat_t *ksp)
}
EXPORT_SYMBOL(__kstat_delete);
#endif /* DEBUG_KSTAT */
int
kstat_init(void)
{
ENTRY;
#ifdef DEBUG_KSTAT
spin_lock_init(&kstat_lock);
INIT_LIST_HEAD(&kstat_list);
kstat_id = 0;
#endif /* DEBUG_KSTAT */
RETURN(0);
}
@@ -488,9 +482,7 @@ void
kstat_fini(void)
{
ENTRY;
#ifdef DEBUG_KSTAT
ASSERT(list_empty(&kstat_list));
#endif /* DEBUG_KSTAT */
EXIT;
}
+2 -17
View File
@@ -41,16 +41,12 @@ static unsigned long table_max = ~0;
static struct ctl_table_header *spl_header = NULL;
#endif /* CONFIG_SYSCTL */
#if defined(DEBUG_KMEM) || defined(DEBUG_KSTAT)
static struct proc_dir_entry *proc_spl = NULL;
#ifdef DEBUG_KMEM
static struct proc_dir_entry *proc_spl_kmem = NULL;
static struct proc_dir_entry *proc_spl_kmem_slab = NULL;
#endif /* DEBUG_KMEM */
#ifdef DEBUG_KSTAT
struct proc_dir_entry *proc_spl_kstat = NULL;
#endif /* DEBUG_KSTAT */
#endif /* DEBUG_KMEM || DEBUG_KSTAT */
#ifdef HAVE_CTL_UNNUMBERED
@@ -901,11 +897,9 @@ static struct ctl_table spl_kmem_table[] = {
};
#endif /* DEBUG_KMEM */
#ifdef DEBUG_KSTAT
static struct ctl_table spl_kstat_table[] = {
{0},
};
#endif /* DEBUG_KSTAT */
static struct ctl_table spl_table[] = {
/* NB No .strategy entries have been provided since
@@ -965,14 +959,12 @@ static struct ctl_table spl_table[] = {
.child = spl_kmem_table,
},
#endif
#ifdef DEBUG_KSTAT
{
.ctl_name = CTL_SPL_KSTAT,
.procname = "kstat",
.mode = 0555,
.child = spl_kstat_table,
},
#endif
{ 0 },
};
@@ -1041,7 +1033,6 @@ proc_init(void)
RETURN(-EUNATCH);
#endif /* CONFIG_SYSCTL */
#if defined(DEBUG_KMEM) || defined(DEBUG_KSTAT)
proc_spl = proc_mkdir("spl", NULL);
if (proc_spl == NULL)
GOTO(out, rc = -EUNATCH);
@@ -1058,25 +1049,21 @@ proc_init(void)
proc_spl_kmem_slab->proc_fops = &proc_slab_operations;
#endif /* DEBUG_KMEM */
#ifdef DEBUG_KSTAT
proc_spl_kstat = proc_mkdir("kstat", proc_spl);
if (proc_spl_kstat == NULL)
GOTO(out, rc = -EUNATCH);
#endif /* DEBUG_KSTAT */
out:
if (rc) {
remove_proc_entry("kstat", proc_spl);
#ifdef DEBUG_KMEM
remove_proc_entry("slab", proc_spl_kmem);
#endif
remove_proc_entry("kmem", proc_spl);
#endif
remove_proc_entry("spl", NULL);
#ifdef CONFIG_SYSCTL
spl_unregister_sysctl_table(spl_header);
#endif /* CONFIG_SYSCTL */
}
#endif /* DEBUG_KMEM || DEBUG_KSTAT */
RETURN(rc);
}
@@ -1086,14 +1073,12 @@ proc_fini(void)
{
ENTRY;
#if defined(DEBUG_KMEM) || defined(DEBUG_KSTAT)
remove_proc_entry("kstat", proc_spl);
#ifdef DEBUG_KMEM
remove_proc_entry("slab", proc_spl_kmem);
#endif
remove_proc_entry("kmem", proc_spl);
#endif
remove_proc_entry("spl", NULL);
#endif /* DEBUG_KMEM || DEBUG_KSTAT */
#ifdef CONFIG_SYSCTL
ASSERT(spl_header != NULL);