Index: sys/kern/subr_pool.c
===================================================================
RCS file: /cvsroot/src/sys/kern/subr_pool.c,v
retrieving revision 1.178
diff -u -r1.178 subr_pool.c
--- sys/kern/subr_pool.c        30 Dec 2009 18:57:17 -0000      1.178
+++ sys/kern/subr_pool.c        2 Jan 2010 15:10:53 -0000
@@ -234,16 +234,28 @@
static inline void
pr_log(struct pool *pp, void *v, int action, const char *file, long line)
{
-       int n = pp->pr_curlogentry;
+       int n;
       struct pool_log *pl;

       if ((pp->pr_roflags & PR_LOGGING) == 0)
               return;

+       if (pp->pr_log == NULL) {
+               if (kmem_map != NULL)
+                       pp->pr_log = malloc(
+                               pool_logsize * sizeof(struct pool_log),
+                               M_TEMP, M_NOWAIT | M_ZERO);
+               if (pp->pr_log == NULL)
+                       return;
+               pp->pr_curlogentry = 0;
+               pp->pr_logsize = pool_logsize;
+       }
+
       /*
        * Fill in the current entry. Wrap around and overwrite
        * the oldest entry if necessary.
        */
+       n = pp->pr_curlogentry;
       pl = &pp->pr_log[n];
       pl->pl_file = file;
       pl->pl_line = line;
@@ -261,7 +273,7 @@
       int i = pp->pr_logsize;
       int n = pp->pr_curlogentry;

-       if ((pp->pr_roflags & PR_LOGGING) == 0)
+       if (pp->pr_log == NULL)
               return;

       /*
@@ -593,6 +605,7 @@
       struct pool_allocator *pa;

       mutex_init(&pool_head_lock, MUTEX_DEFAULT, IPL_NONE);
+       mutex_init(&pool_allocator_lock, MUTEX_DEFAULT, IPL_NONE);
       cv_init(&pool_busy, "poolbusy");

       while ((pa = SLIST_FIRST(&pa_deferinitq)) != NULL) {
@@ -607,8 +620,6 @@

       pool_init(&cache_cpu_pool, sizeof(pool_cache_cpu_t), coherency_unit,
           0, 0, "pcachecpu", &pool_allocator_nointr, IPL_NONE);
-
-       mutex_init(&pool_allocator_lock, MUTEX_DEFAULT, IPL_NONE);
}

/*
@@ -793,16 +804,7 @@
       pp->pr_nidle = 0;
       pp->pr_refcnt = 0;

-#ifdef POOL_DIAGNOSTIC
-       if (flags & PR_LOGGING) {
-               if (kmem_map == NULL ||
-                   (pp->pr_log = malloc(pool_logsize * sizeof(struct pool_log),
-                    M_TEMP, M_NOWAIT)) == NULL)
-                       pp->pr_roflags &= ~PR_LOGGING;
-               pp->pr_curlogentry = 0;
-               pp->pr_logsize = pool_logsize;
-       }
-#endif
+       pp->pr_log = NULL;

       pp->pr_entered_file = NULL;
       pp->pr_entered_line = 0;
@@ -928,8 +930,10 @@
       pr_pagelist_free(pp, &pq);

#ifdef POOL_DIAGNOSTIC
-       if ((pp->pr_roflags & PR_LOGGING) != 0)
+       if (pp->pr_log != NULL) {
               free(pp->pr_log, M_TEMP);
+               pp->pr_log = NULL;
+       }
#endif

       cv_destroy(&pp->pr_cv);