Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys G/C POOL_DIAGNOSTIC option. No objection on tech-kern@.



details:   https://anonhg.NetBSD.org/src/rev/1dc0b26ccfa7
branches:  trunk
changeset: 779128:1dc0b26ccfa7
user:      rmind <rmind%NetBSD.org@localhost>
date:      Sat May 05 19:15:10 2012 +0000

description:
G/C POOL_DIAGNOSTIC option.  No objection on tech-kern@.

diffstat:

 sys/conf/files       |    4 +-
 sys/kern/subr_pool.c |  240 +--------------------------------------------------
 sys/sys/pool.h       |   29 +-----
 3 files changed, 5 insertions(+), 268 deletions(-)

diffs (truncated from 573 to 300 lines):

diff -r 7fb0a0340bf9 -r 1dc0b26ccfa7 sys/conf/files
--- a/sys/conf/files    Sat May 05 17:54:13 2012 +0000
+++ b/sys/conf/files    Sat May 05 19:15:10 2012 +0000
@@ -1,4 +1,4 @@
-#      $NetBSD: files,v 1.1048 2012/04/28 23:03:39 rmind Exp $
+#      $NetBSD: files,v 1.1049 2012/05/05 19:15:10 rmind Exp $
 #      @(#)files.newconf       7.5 (Berkeley) 5/10/93
 
 version        20100430
@@ -69,8 +69,6 @@
 defflag        opt_ptm.h               NO_DEV_PTM COMPAT_BSDPTY
 
 defparam opt_kmempages.h       NKMEMPAGES NKMEMPAGES_MIN NKMEMPAGES_MAX
-defflag        opt_pool.h              POOL_DIAGNOSTIC
-defparam opt_poollog.h         POOL_LOGSIZE
 
 defflag        opt_revcache.h          NAMECACHE_ENTER_REVERSE
 
diff -r 7fb0a0340bf9 -r 1dc0b26ccfa7 sys/kern/subr_pool.c
--- a/sys/kern/subr_pool.c      Sat May 05 17:54:13 2012 +0000
+++ b/sys/kern/subr_pool.c      Sat May 05 19:15:10 2012 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: subr_pool.c,v 1.194 2012/02/04 22:11:42 para Exp $     */
+/*     $NetBSD: subr_pool.c,v 1.195 2012/05/05 19:15:10 rmind Exp $    */
 
 /*-
  * Copyright (c) 1997, 1999, 2000, 2002, 2007, 2008, 2010
@@ -32,11 +32,9 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: subr_pool.c,v 1.194 2012/02/04 22:11:42 para Exp $");
+__KERNEL_RCSID(0, "$NetBSD: subr_pool.c,v 1.195 2012/05/05 19:15:10 rmind Exp $");
 
 #include "opt_ddb.h"
-#include "opt_pool.h"
-#include "opt_poollog.h"
 #include "opt_lockdebug.h"
 
 #include <sys/param.h>
@@ -45,7 +43,6 @@
 #include <sys/proc.h>
 #include <sys/errno.h>
 #include <sys/kernel.h>
-#include <sys/malloc.h>
 #include <sys/vmem.h>
 #include <sys/pool.h>
 #include <sys/syslog.h>
@@ -213,136 +210,6 @@
 static int pool_chk_page(struct pool *, const char *,
                         struct pool_item_header *);
 
-/*
- * Pool log entry. An array of these is allocated in pool_init().
- */
-struct pool_log {
-       const char      *pl_file;
-       long            pl_line;
-       int             pl_action;
-#define        PRLOG_GET       1
-#define        PRLOG_PUT       2
-       void            *pl_addr;
-};
-
-#ifdef POOL_DIAGNOSTIC
-/* Number of entries in pool log buffers */
-#ifndef POOL_LOGSIZE
-#define        POOL_LOGSIZE    10
-#endif
-
-int pool_logsize = POOL_LOGSIZE;
-
-static inline void
-pr_log(struct pool *pp, void *v, int action, const char *file, long line)
-{
-       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;
-       pl->pl_action = action;
-       pl->pl_addr = v;
-       if (++n >= pp->pr_logsize)
-               n = 0;
-       pp->pr_curlogentry = n;
-}
-
-static void
-pr_printlog(struct pool *pp, struct pool_item *pi,
-    void (*pr)(const char *, ...))
-{
-       int i = pp->pr_logsize;
-       int n = pp->pr_curlogentry;
-
-       if (pp->pr_log == NULL)
-               return;
-
-       /*
-        * Print all entries in this pool's log.
-        */
-       while (i-- > 0) {
-               struct pool_log *pl = &pp->pr_log[n];
-               if (pl->pl_action != 0) {
-                       if (pi == NULL || pi == pl->pl_addr) {
-                               (*pr)("\tlog entry %d:\n", i);
-                               (*pr)("\t\taction = %s, addr = %p\n",
-                                   pl->pl_action == PRLOG_GET ? "get" : "put",
-                                   pl->pl_addr);
-                               (*pr)("\t\tfile: %s at line %lu\n",
-                                   pl->pl_file, pl->pl_line);
-                       }
-               }
-               if (++n >= pp->pr_logsize)
-                       n = 0;
-       }
-}
-
-static inline void
-pr_enter(struct pool *pp, const char *file, long line)
-{
-
-       if (__predict_false(pp->pr_entered_file != NULL)) {
-               printf("pool %s: reentrancy at file %s line %ld\n",
-                   pp->pr_wchan, file, line);
-               printf("         previous entry at file %s line %ld\n",
-                   pp->pr_entered_file, pp->pr_entered_line);
-               panic("pr_enter");
-       }
-
-       pp->pr_entered_file = file;
-       pp->pr_entered_line = line;
-}
-
-static inline void
-pr_leave(struct pool *pp)
-{
-
-       if (__predict_false(pp->pr_entered_file == NULL)) {
-               printf("pool %s not entered?\n", pp->pr_wchan);
-               panic("pr_leave");
-       }
-
-       pp->pr_entered_file = NULL;
-       pp->pr_entered_line = 0;
-}
-
-static inline void
-pr_enter_check(struct pool *pp, void (*pr)(const char *, ...))
-{
-
-       if (pp->pr_entered_file != NULL)
-               (*pr)("\n\tcurrently entered from file %s line %ld\n",
-                   pp->pr_entered_file, pp->pr_entered_line);
-}
-#else
-#define        pr_log(pp, v, action, file, line)
-#define        pr_printlog(pp, pi, pr)
-#define        pr_enter(pp, file, line)
-#define        pr_leave(pp)
-#define        pr_enter_check(pp, pr)
-#endif /* POOL_DIAGNOSTIC */
-
 static inline unsigned int
 pr_item_notouch_index(const struct pool *pp, const struct pool_item_header *ph,
     const void *v)
@@ -584,7 +451,7 @@
  * Initialize the given pool resource structure.
  *
  * We export this routine to allow other kernel parts to declare
- * static pools that must be initialized before malloc() is available.
+ * static pools that must be initialized before kmem(9) is available.
  */
 void
 pool_init(struct pool *pp, size_t size, u_int align, u_int ioff, int flags,
@@ -606,14 +473,6 @@
        }
 #endif
 
-#ifdef POOL_DIAGNOSTIC
-       /*
-        * Always log if POOL_DIAGNOSTIC is defined.
-        */
-       if (pool_logsize != 0)
-               flags |= PR_LOGGING;
-#endif
-
        if (palloc == NULL)
                palloc = &pool_allocator_kmem;
 #ifdef POOL_SUBPAGE
@@ -760,11 +619,6 @@
        pp->pr_nidle = 0;
        pp->pr_refcnt = 0;
 
-       pp->pr_log = NULL;
-
-       pp->pr_entered_file = NULL;
-       pp->pr_entered_line = 0;
-
        mutex_init(&pp->pr_lock, MUTEX_DEFAULT, ipl);
        cv_init(&pp->pr_cv, wchan);
        pp->pr_ipl = ipl;
@@ -825,7 +679,6 @@
 
 #ifdef DIAGNOSTIC
        if (pp->pr_nout != 0) {
-               pr_printlog(pp, NULL, printf);
                panic("pool_destroy: pool busy: still out: %u",
                    pp->pr_nout);
        }
@@ -842,14 +695,6 @@
        mutex_exit(&pp->pr_lock);
 
        pr_pagelist_free(pp, &pq);
-
-#ifdef POOL_DIAGNOSTIC
-       if (pp->pr_log != NULL) {
-               free(pp->pr_log, M_TEMP);
-               pp->pr_log = NULL;
-       }
-#endif
-
        cv_destroy(&pp->pr_cv);
        mutex_destroy(&pp->pr_lock);
 }
@@ -884,11 +729,7 @@
  * Grab an item from the pool.
  */
 void *
-#ifdef POOL_DIAGNOSTIC
-_pool_get(struct pool *pp, int flags, const char *file, long line)
-#else
 pool_get(struct pool *pp, int flags)
-#endif
 {
        struct pool_item *pi;
        struct pool_item_header *ph;
@@ -908,8 +749,6 @@
        }
 
        mutex_enter(&pp->pr_lock);
-       pr_enter(pp, file, line);
-
  startover:
        /*
         * Check to see if we've reached the hard limit.  If we have,
@@ -918,7 +757,6 @@
         */
 #ifdef DIAGNOSTIC
        if (__predict_false(pp->pr_nout > pp->pr_hardlimit)) {
-               pr_leave(pp);
                mutex_exit(&pp->pr_lock);
                panic("pool_get: %s: crossed hard limit", pp->pr_wchan);
        }
@@ -930,11 +768,9 @@
                         * back to the pool, unlock, call the hook, re-lock,
                         * and check the hardlimit condition again.
                         */
-                       pr_leave(pp);
                        mutex_exit(&pp->pr_lock);
                        (*pp->pr_drain_hook)(pp->pr_drain_hook_arg, flags);
                        mutex_enter(&pp->pr_lock);
-                       pr_enter(pp, file, line);
                        if (pp->pr_nout < pp->pr_hardlimit)
                                goto startover;
                }
@@ -945,9 +781,7 @@
                         * it be?
                         */
                        pp->pr_flags |= PR_WANTED;
-                       pr_leave(pp);
                        cv_wait(&pp->pr_cv, &pp->pr_lock);
-                       pr_enter(pp, file, line);
                        goto startover;
                }
 
@@ -961,7 +795,6 @@
 
                pp->pr_nfail++;
 
-               pr_leave(pp);



Home | Main Index | Thread Index | Old Index