Source-Changes-HG archive

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

[src/trunk]: src/sys Remove MALLOC_DEBUG and MALLOCLOG, which is dead code af...



details:   https://anonhg.NetBSD.org/src/rev/d0ab02c6e665
branches:  trunk
changeset: 779048:d0ab02c6e665
user:      rmind <rmind%NetBSD.org@localhost>
date:      Sat Apr 28 23:03:39 2012 +0000

description:
Remove MALLOC_DEBUG and MALLOCLOG, which is dead code after malloc(9) move
to kmem(9).  Note: kmem(9) has debugging facilities under DEBUG/DIAGNOSTIC.
However, expensive kmguard and debug_freecheck have to be enabled manually.

diffstat:

 sys/arch/ia64/conf/GENERIC     |    6 +-
 sys/arch/ia64/conf/GENERIC.SKI |    6 +-
 sys/conf/files                 |    7 +-
 sys/ddb/db_command.c           |   23 +--
 sys/kern/kern_malloc.c         |  237 ++++-------------------------
 sys/kern/kern_malloc_debug.c   |  327 -----------------------------------------
 sys/kern/kern_malloc_stdtype.c |   58 -------
 sys/sys/malloc.h               |   51 +-----
 sys/sys/mallocvar.h            |    3 +-
 9 files changed, 52 insertions(+), 666 deletions(-)

diffs (truncated from 979 to 300 lines):

diff -r 75c77f2105bf -r d0ab02c6e665 sys/arch/ia64/conf/GENERIC
--- a/sys/arch/ia64/conf/GENERIC        Sat Apr 28 20:15:07 2012 +0000
+++ b/sys/arch/ia64/conf/GENERIC        Sat Apr 28 23:03:39 2012 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: GENERIC,v 1.4 2010/05/17 11:41:28 kiyohara Exp $
+# $NetBSD: GENERIC,v 1.5 2012/04/28 23:03:40 rmind Exp $
 #
 # GENERIC machine description file
 #
@@ -22,7 +22,7 @@
 
 options        INCLUDE_CONFIG_FILE     # embed config file in kernel binary
 
-#ident                 "GENERIC-$Revision: 1.4 $"
+#ident                 "GENERIC-$Revision: 1.5 $"
 
 maxusers       32              # estimated number of users
 
@@ -45,8 +45,6 @@
 options        DDB_HISTORY_SIZE=512    # enable history editing in DDB
 #options       KGDB            # remote debugger
 #options       KGDB_DEVNAME="\"com\"",KGDB_DEVADDR=0x3f8,KGDB_DEVRATE=9600
-#options               MALLOC_DEBUG
-#options               MALLOCLOG
 makeoptions    DEBUG="-g"      # compile full symbol table
 
 # File systems
diff -r 75c77f2105bf -r d0ab02c6e665 sys/arch/ia64/conf/GENERIC.SKI
--- a/sys/arch/ia64/conf/GENERIC.SKI    Sat Apr 28 20:15:07 2012 +0000
+++ b/sys/arch/ia64/conf/GENERIC.SKI    Sat Apr 28 23:03:39 2012 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: GENERIC.SKI,v 1.7 2010/11/23 11:14:00 hannken Exp $
+# $NetBSD: GENERIC.SKI,v 1.8 2012/04/28 23:03:40 rmind Exp $
 #
 # GENERIC machine description file
 #
@@ -22,7 +22,7 @@
 
 options        INCLUDE_CONFIG_FILE     # embed config file in kernel binary
 
-#ident                 "GENERIC-$Revision: 1.7 $"
+#ident                 "GENERIC-$Revision: 1.8 $"
 
 maxusers       32              # estimated number of users
 
@@ -44,8 +44,6 @@
 #options       DDB_HISTORY_SIZE=512    # enable history editing in DDB
 #options       KGDB            # remote debugger
 #options       KGDB_DEVNAME="\"com\"",KGDB_DEVADDR=0x3f8,KGDB_DEVRATE=9600
-#options               MALLOC_DEBUG
-#options               MALLOCLOG
 makeoptions    DEBUG="-g"      # compile full symbol table
 
 # File systems
diff -r 75c77f2105bf -r d0ab02c6e665 sys/conf/files
--- a/sys/conf/files    Sat Apr 28 20:15:07 2012 +0000
+++ b/sys/conf/files    Sat Apr 28 23:03:39 2012 +0000
@@ -1,4 +1,4 @@
-#      $NetBSD: files,v 1.1047 2012/04/07 05:36:49 christos Exp $
+#      $NetBSD: files,v 1.1048 2012/04/28 23:03:39 rmind Exp $
 #      @(#)files.newconf       7.5 (Berkeley) 5/10/93
 
 version        20100430
@@ -69,9 +69,6 @@
 defflag        opt_ptm.h               NO_DEV_PTM COMPAT_BSDPTY
 
 defparam opt_kmempages.h       NKMEMPAGES NKMEMPAGES_MIN NKMEMPAGES_MAX
-defflag        opt_malloclog.h         MALLOCLOG
-defparam opt_malloclog.h       MALLOCLOGSIZE
-defflag        opt_malloc_debug.h      MALLOC_DEBUG
 defflag        opt_pool.h              POOL_DIAGNOSTIC
 defparam opt_poollog.h         POOL_LOGSIZE
 
@@ -1490,8 +1487,6 @@
 file   kern/kern_lock.c
 file   kern/kern_lwp.c
 file   kern/kern_malloc.c
-file   kern/kern_malloc_stdtype.c
-file   kern/kern_malloc_debug.c        malloc_debug
 file   kern/kern_module.c
 file   kern/kern_module_vfs.c
 file   kern/kern_mutex.c
diff -r 75c77f2105bf -r d0ab02c6e665 sys/ddb/db_command.c
--- a/sys/ddb/db_command.c      Sat Apr 28 20:15:07 2012 +0000
+++ b/sys/ddb/db_command.c      Sat Apr 28 23:03:39 2012 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: db_command.c,v 1.137 2011/11/13 03:21:51 mrg Exp $     */
+/*     $NetBSD: db_command.c,v 1.138 2012/04/28 23:03:39 rmind Exp $   */
 
 /*
  * Copyright (c) 1996, 1997, 1998, 1999, 2002, 2009 The NetBSD Foundation, Inc.
@@ -60,7 +60,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: db_command.c,v 1.137 2011/11/13 03:21:51 mrg Exp $");
+__KERNEL_RCSID(0, "$NetBSD: db_command.c,v 1.138 2012/04/28 23:03:39 rmind Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_aio.h"
@@ -79,7 +79,6 @@
 #include <sys/reboot.h>
 #include <sys/device.h>
 #include <sys/lwp.h>
-#include <sys/malloc.h>
 #include <sys/mbuf.h>
 #include <sys/namei.h>
 #include <sys/pool.h>
@@ -192,7 +191,6 @@
 static void    db_lock_print_cmd(db_expr_t, bool, db_expr_t, const char *);
 static void    db_mount_print_cmd(db_expr_t, bool, db_expr_t, const char *);
 static void    db_mbuf_print_cmd(db_expr_t, bool, db_expr_t, const char *);
-static void    db_malloc_print_cmd(db_expr_t, bool, db_expr_t, const char *);
 static void    db_map_print_cmd(db_expr_t, bool, db_expr_t, const char *);
 static void    db_namecache_print_cmd(db_expr_t, bool, db_expr_t,
                    const char *);
@@ -248,7 +246,6 @@
            "Print the files open by process at address",
            "[/f] address", NULL) },
        { DDB_ADD_CMD("lock",   db_lock_print_cmd,      0,NULL,NULL,NULL) },
-       { DDB_ADD_CMD("malloc", db_malloc_print_cmd,0,NULL,NULL,NULL) },
        { DDB_ADD_CMD("map",    db_map_print_cmd,       0,
            "Print the vm_map at address.", "[/f] address",NULL) },
        { DDB_ADD_CMD("module", db_show_module_cmd,     0,
@@ -985,22 +982,6 @@
 
 /*ARGSUSED*/
 static void
-db_malloc_print_cmd(db_expr_t addr, bool have_addr,
-    db_expr_t count, const char *modif)
-{
-
-#ifdef MALLOC_DEBUG
-       if (!have_addr)
-               addr = 0;
-
-       debug_malloc_printit(db_printf, (vaddr_t) addr);
-#else
-       db_printf("The kernel is not built with the MALLOC_DEBUG option.\n");
-#endif /* MALLOC_DEBUG */
-}
-
-/*ARGSUSED*/
-static void
 db_object_print_cmd(db_expr_t addr, bool have_addr,
     db_expr_t count, const char *modif)
 {
diff -r 75c77f2105bf -r d0ab02c6e665 sys/kern/kern_malloc.c
--- a/sys/kern/kern_malloc.c    Sat Apr 28 20:15:07 2012 +0000
+++ b/sys/kern/kern_malloc.c    Sat Apr 28 23:03:39 2012 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: kern_malloc.c,v 1.138 2012/02/06 12:13:44 drochner Exp $       */
+/*     $NetBSD: kern_malloc.c,v 1.139 2012/04/28 23:03:40 rmind Exp $  */
 
 /*
  * Copyright (c) 1987, 1991, 1993
@@ -65,47 +65,45 @@
  *     @(#)kern_malloc.c       8.4 (Berkeley) 5/20/95
  */
 
+/*
+ * Wrapper interface for obsolete malloc(9).
+ */
+
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: kern_malloc.c,v 1.138 2012/02/06 12:13:44 drochner Exp $");
+__KERNEL_RCSID(0, "$NetBSD: kern_malloc.c,v 1.139 2012/04/28 23:03:40 rmind Exp $");
 
 #include <sys/param.h>
-#include <sys/proc.h>
-#include <sys/kernel.h>
 #include <sys/malloc.h>
 #include <sys/kmem.h>
-#include <sys/systm.h>
-#include <sys/debug.h>
-#include <sys/mutex.h>
-#include <sys/lockdebug.h>
 
 #include <uvm/uvm_extern.h>
 
-#include "opt_kmemstats.h"
-#include "opt_malloclog.h"
-#include "opt_malloc_debug.h"
-
-struct kmembuckets kmembuckets[MINBUCKET + 16];
-struct kmemusage *kmemusage;
-struct malloc_type *kmemstatistics;
-
-kmutex_t malloc_lock;
-
-struct malloc_header {
-       /* Total size, include the header. */
-       size_t          mh_size;
-} __aligned(ALIGNBYTES+1);
+/*
+ * Built-in malloc types.  Note: ought to be removed.
+ */
+MALLOC_DEFINE(M_DEVBUF, "devbuf", "device driver memory");
+MALLOC_DEFINE(M_DMAMAP, "DMA map", "bus_dma(9) structures");
+MALLOC_DEFINE(M_FREE, "free", "should be on free list");
+MALLOC_DEFINE(M_PCB, "pcb", "protocol control block");
+MALLOC_DEFINE(M_TEMP, "temp", "misc. temporary data buffers");
+MALLOC_DEFINE(M_RTABLE, "routetbl", "routing tables");
+MALLOC_DEFINE(M_FTABLE, "fragtbl", "fragment reassembly header");
+MALLOC_DEFINE(M_UFSMNT, "UFS mount", "UFS mount structure");
+MALLOC_DEFINE(M_NETADDR, "Export Host", "Export host address structure");
+MALLOC_DEFINE(M_IPMOPTS, "ip_moptions", "internet multicast options");
+MALLOC_DEFINE(M_IPMADDR, "in_multi", "internet multicast address");
+MALLOC_DEFINE(M_MRTABLE, "mrt", "multicast routing tables");
+MALLOC_DEFINE(M_BWMETER, "bwmeter", "multicast upcall bw meters");
 
 /*
- * Allocate a block of memory
+ * Header contains total size, including the header itself.
  */
-#ifdef MALLOCLOG
-void *
-_kern_malloc(unsigned long size, struct malloc_type *ksp, int flags,
-    const char *file, long line)
-#else
+struct malloc_header {
+       size_t          mh_size;
+} __aligned(ALIGNBYTES + 1);
+
 void *
 kern_malloc(unsigned long size, struct malloc_type *ksp, int flags)
-#endif /* MALLOCLOG */
 {
        const int kmflags = (flags & M_NOWAIT) ? KM_NOSLEEP : KM_SLEEP;
        size_t allocsize, hdroffset;
@@ -133,16 +131,8 @@
        return mh + 1;
 }
 
-/*
- * Free a block of memory allocated by malloc.
- */
-#ifdef MALLOCLOG
-void
-_kern_free(void *addr, struct malloc_type *ksp, const char *file, long line)
-#else
 void
 kern_free(void *addr, struct malloc_type *ksp)
-#endif /* MALLOCLOG */
 {
        struct malloc_header *mh;
 
@@ -156,9 +146,6 @@
                kmem_intr_free(mh, mh->mh_size);
 }
 
-/*
- * Change the size of a block of memory.
- */
 void *
 kern_realloc(void *curaddr, unsigned long newsize, struct malloc_type *ksp,
     int flags)
@@ -171,21 +158,19 @@
         * realloc() with a NULL pointer is the same as malloc().
         */
        if (curaddr == NULL)
-               return (malloc(newsize, ksp, flags));
+               return malloc(newsize, ksp, flags);
 
        /*
         * realloc() with zero size is the same as free().
         */
        if (newsize == 0) {
                free(curaddr, ksp);
-               return (NULL);
+               return NULL;
        }
 
-#ifdef LOCKDEBUG
        if ((flags & M_NOWAIT) == 0) {
                ASSERT_SLEEPABLE();
        }
-#endif
 
        mh = curaddr;
        mh--;
@@ -196,7 +181,7 @@
         * If we already actually have as much as they want, we're done.
         */
        if (newsize <= cursize)
-               return (curaddr);
+               return curaddr;
 
        /*
         * Can't satisfy the allocation with the existing block.
@@ -209,7 +194,7 @@
                 * Return NULL to indicate that failure.  The old
                 * pointer is still valid.
                 */
-               return (NULL);
+               return NULL;
        }
        memcpy(newaddr, curaddr, cursize);
 
@@ -218,81 +203,19 @@



Home | Main Index | Thread Index | Old Index